Skip to content

Commit 6778f6f

Browse files
committed
Remove image upload size limit
1 parent 34c7ab0 commit 6778f6f

File tree

7 files changed

+54
-16
lines changed

7 files changed

+54
-16
lines changed

docs/source/cli.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ To upload images from folder to project use:
5050
If optional argument *recursive* is given then subfolders of :file:`<folder_path>` are also recursively
5151
scanned for available images.
5252

53-
Optional argument *extensions* accepts comma separated list of image extensions to look for. If the argument is not given then value *jpg,png* is assumed.
53+
Optional argument *extensions* accepts comma separated list of image extensions
54+
to look for. If the argument is not given then value *jpg,png* is assumed.
5455

5556
----------
5657

@@ -69,7 +70,7 @@ To upload videos from folder to project use:
6970
[--end-time <float>]
7071
7172
If optional argument *recursive* is given then subfolders of :file:`<folder_path>` are also recursively
72-
scanned for available images.
73+
scanned for available videos.
7374

7475
Optional argument *extensions* accepts comma separated list of image extensions
7576
to look for. If the argument is not given then value *mp4,avi,mov,webm,flv,mpg,ogg* is assumed.

superannotate/__main__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,23 @@ def video_upload(args):
9494
'--target-fps',
9595
required=False,
9696
default=None,
97+
type=float,
9798
help=
9899
'How many frames per second need to extract from the videos (approximate). If not specified all frames will be uploaded'
99100
)
100101
parser.add_argument(
101102
'--start-time',
102103
required=False,
103104
default=0.0,
105+
type=float,
104106
help=
105107
'Time (in seconds) from which to start extracting frames. Default is 0.0'
106108
)
107109
parser.add_argument(
108110
'--end-time',
109111
required=False,
110112
default=None,
113+
type=float,
111114
help=
112115
'Time (in seconds) up to which to extract frames. If it is not specified, then up to end'
113116
)

superannotate/db/projects.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
_api = API.get_instance()
3737
_NUM_THREADS = 10
3838

39-
_RESIZE_CONFIG = {2: 4_000_000, 1: 100_000_000} # 1: vector 2: pixel
40-
4139

4240
def create_project(project_name, project_description, project_type):
4341
"""Create a new project in the team.
@@ -579,15 +577,6 @@ def get_image_array_to_upload(
579577
im_format = im.format
580578
im = im.convert("RGB")
581579
width, height = im.size
582-
max_size = _RESIZE_CONFIG[project_type]
583-
if (width * height) > max_size:
584-
logger.warning("One of the images is being resized to smaller size.")
585-
max_size_root = math.sqrt(max_size)
586-
nwidth = math.floor(max_size_root * math.sqrt(width / height))
587-
nheight = math.floor(max_size_root * math.sqrt(height / width))
588-
im = im.resize((nwidth, nheight))
589-
byte_io_orig = io.BytesIO()
590-
im.save(byte_io_orig, im_format, subsampling=0, quality=100)
591580

592581
if not image_quality_in_editor == 100 or im_format != "JPEG":
593582
byte_io_lores = io.BytesIO()
@@ -1637,10 +1626,11 @@ def _get_project_image_quality_in_editor(project, image_quality_in_editor):
16371626
for setting in get_project_settings(project):
16381627
if "attribute" in setting and setting["attribute"] == "ImageQuality":
16391628
return setting["value"]
1629+
return 60
16401630
elif image_quality_in_editor == "compressed":
1641-
image_quality_in_editor = 60
1631+
return 60
16421632
elif image_quality_in_editor == "original":
1643-
image_quality_in_editor = 100
1633+
return 100
16441634
else:
16451635
raise SABaseException(
16461636
0,

superannotate/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.2.4"
1+
__version__ = "2.2.5"
1.76 MB
Binary file not shown.
1.45 MB
Binary file not shown.

tests/test_video.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from pathlib import Path
2+
import filecmp
3+
import subprocess
4+
import time
5+
6+
import superannotate as sa
7+
8+
import pytest
9+
10+
PROJECT_NAME1 = "test video upload1"
11+
PROJECT_NAME2 = "test video upload2"
12+
13+
14+
def test_image_quality_setting1(tmpdir):
15+
tmpdir = Path(tmpdir)
16+
17+
projects = sa.search_projects(PROJECT_NAME1, return_metadata=True)
18+
for project in projects:
19+
sa.delete_project(project)
20+
21+
project = sa.create_project(PROJECT_NAME1, "test", "Vector")
22+
23+
sa.upload_videos_from_folder_to_project(
24+
project, "./tests/sample_videos", target_fps=2
25+
)
26+
27+
projects = sa.search_projects(PROJECT_NAME2, return_metadata=True)
28+
for project in projects:
29+
sa.delete_project(project)
30+
31+
project2 = sa.create_project(PROJECT_NAME2, "test", "Vector")
32+
33+
subprocess.run(
34+
[
35+
f"superannotate upload-videos --project '{PROJECT_NAME2}' --folder ./tests/sample_videos --target-fps 2"
36+
],
37+
check=True,
38+
shell=True
39+
)
40+
time.sleep(5)
41+
42+
assert len(sa.search_images(PROJECT_NAME1)) == len(
43+
sa.search_images(PROJECT_NAME2)
44+
)

0 commit comments

Comments
 (0)