Skip to content

Commit 0949a98

Browse files
committed
settings
1 parent 4226a1e commit 0949a98

File tree

5 files changed

+53
-40
lines changed

5 files changed

+53
-40
lines changed

install.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/bin/bash
22

3-
PYTHON_VER="3.6"
3+
PYTHON_VER="3.7"
44

55
# ubuntu install dependencies
6-
# sudo add-apt-repository ppa:deadsnakes/ppa
7-
# sudo apt update
8-
# sudo apt install python${PYTHON_VER} python${PYTHON_VER}-venv python${PYTHON_VER}-dev
6+
sudo add-apt-repository ppa:deadsnakes/ppa
7+
sudo apt update
8+
sudo apt install python${PYTHON_VER} python${PYTHON_VER}-venv python${PYTHON_VER}-dev
99

1010
rm -rf venv_sa_conv
1111
python${PYTHON_VER} -m venv venv_sa_conv
@@ -16,3 +16,6 @@ pip install 'git+https://github.com/cocodataset/panopticapi.git'
1616
pip install 'git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI'
1717

1818
pip install -e .
19+
20+
# for testing
21+
pip install pytest pytest-xdist

superannotate/__main__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ def image_upload(args):
8989
args = parser.parse_args(args)
9090

9191
sa.upload_images_from_folder_to_project(
92-
args.project,
93-
args.folder,
94-
args.extensions,
95-
args.set_annotation_status,
92+
project=args.project,
93+
folder_path=args.folder,
94+
extensions=args.extensions,
95+
annotation_status=args.set_annotation_status,
9696
recursive_subfolders=args.recursive
9797
)
9898

superannotate/db/project_images.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
set_image_annotation_status, upload_annotations_from_json_to_image
1515
)
1616
from .projects import (
17-
__create_image, _get_project_default_image_quality_in_editor,
17+
__create_image, _get_project_image_quality_in_editor,
1818
get_image_array_to_upload, get_project_metadata
1919
)
2020

@@ -44,16 +44,16 @@ def upload_image_to_project(
4444
:type annotation_status: str
4545
:param from_s3_bucket: AWS S3 bucket to use. If None then folder_path is in local filesystem
4646
:type from_s3_bucket: str
47-
:param image_quality_in_editor: image quality (in percents) that will be seen in SuperAnnotate web annotation editor. If None default value will be used.
48-
:type image_quality_in_editor: int
47+
:param image_quality_in_editor: image quality be seen in SuperAnnotate web annotation editor.
48+
Can be either "compressed" or "original". If None then the default value in project settings will be used.
49+
:type image_quality_in_editor: str
4950
"""
5051
if not isinstance(project, dict):
5152
project = get_project_metadata(project)
5253
annotation_status = annotation_status_str_to_int(annotation_status)
53-
if image_quality_in_editor is None:
54-
image_quality_in_editor = _get_project_default_image_quality_in_editor(
55-
project
56-
)
54+
image_quality_in_editor = _get_project_image_quality_in_editor(
55+
project, image_quality_in_editor
56+
)
5757

5858
img_name = None
5959
if not isinstance(img, io.BytesIO):

superannotate/db/projects.py

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,9 @@ def upload_video_to_project(
272272
:param annotation_status: value to set the annotation statuses of the uploaded
273273
video frames NotStarted InProgress QualityCheck Returned Completed Skipped
274274
:type annotation_status: str
275-
:param image_quality_in_editor: image quality (in percents) that will be
276-
seen in SuperAnnotate web annotation editor.
277-
If None default value will be used
278-
:type image_quality_in_editor: int
275+
:param image_quality_in_editor: image quality be seen in SuperAnnotate web annotation editor.
276+
Can be either "compressed" or "original". If None then the default value in project settings will be used.
277+
:type image_quality_in_editor: str
279278
280279
:return: filenames of uploaded images
281280
:rtype: list of strs
@@ -502,8 +501,9 @@ def upload_images_from_folder_to_project(
502501
:type exclude_file_patterns: list of strs
503502
:param recursive_subfolders: enable recursive subfolder parsing
504503
:type recursive_subfolders: bool
505-
:param image_quality_in_editor: image quality (in percents) that will be seen in SuperAnnotate web annotation editor. If None default value will be used.
506-
:type image_quality_in_editor: int
504+
:param image_quality_in_editor: image quality be seen in SuperAnnotate web annotation editor.
505+
Can be either "compressed" or "original". If None then the default value in project settings will be used.
506+
:type image_quality_in_editor: str
507507
508508
:return: uploaded and not-uploaded images' filepaths
509509
:rtype: tuple of list of strs
@@ -727,19 +727,19 @@ def upload_images_to_project(
727727
:type annotation_status: str
728728
:param from_s3_bucket: AWS S3 bucket to use. If None then folder_path is in local filesystem
729729
:type from_s3_bucket: str
730-
:param image_quality_in_editor: image quality (in percents) that will be seen in SuperAnnotate web annotation editor. If None default value will be used.
731-
:type image_quality_in_editor: int
730+
:param image_quality_in_editor: image quality be seen in SuperAnnotate web annotation editor.
731+
Can be either "compressed" or "original". If None then the default value in project settings will be used.
732+
:type image_quality_in_editor: str
732733
733734
:return: uploaded and not-uploaded images' filepaths
734735
:rtype: tuple of list of strs
735736
"""
736737
if not isinstance(project, dict):
737738
project = get_project_metadata(project)
738739
annotation_status = annotation_status_str_to_int(annotation_status)
739-
if image_quality_in_editor is None:
740-
image_quality_in_editor = _get_project_default_image_quality_in_editor(
741-
project
742-
)
740+
image_quality_in_editor = _get_project_image_quality_in_editor(
741+
project, image_quality_in_editor
742+
)
743743
team_id, project_id = project["team_id"], project["id"]
744744
len_img_paths = len(img_paths)
745745
logger.info(
@@ -1371,15 +1371,19 @@ def upload_images_from_s3_bucket_to_project(
13711371
:type bucket_name: str
13721372
:param folder_path: from which folder to upload the images
13731373
:type folder_path: str
1374-
:param image_quality_in_editor: image quality (in percents) that will be seen in SuperAnnotate web annotation editor, if None default value will be used
1375-
:type image_quality_in_editor: int
1374+
:param image_quality_in_editor: image quality be seen in SuperAnnotate web annotation editor.
1375+
Can be either "compressed" or "original". If None then the default value in project settings will be used.
1376+
:type image_quality_in_editor: str
13761377
"""
13771378
if not isinstance(project, dict):
13781379
project = get_project_metadata(project)
13791380
if image_quality_in_editor is not None:
1380-
old_quality = _get_project_default_image_quality_in_editor(project)
1381+
old_quality = _get_project_image_quality_in_editor(project, None)
13811382
_set_project_default_image_quality_in_editor(
1382-
project, image_quality_in_editor
1383+
project,
1384+
_get_project_image_quality_in_editor(
1385+
project, image_quality_in_editor
1386+
)
13831387
)
13841388
team_id, project_id = project["team_id"], project["id"]
13851389
params = {
@@ -1624,15 +1628,20 @@ def set_project_settings(project, new_settings):
16241628
return response.json()
16251629

16261630

1627-
def _get_project_default_image_quality_in_editor(project):
1628-
for setting in get_project_settings(project):
1629-
if "attribute" in setting and setting["attribute"] == "ImageQuality":
1630-
return setting["value"]
1631-
return 60
1632-
# raise SABaseException(
1633-
# response.status_code,
1634-
# "Couldn't get project default image quality " + response.text
1635-
# )
1631+
def _get_project_image_quality_in_editor(project, image_quality_in_editor):
1632+
if image_quality_in_editor is None:
1633+
for setting in get_project_settings(project):
1634+
if "attribute" in setting and setting["attribute"] == "ImageQuality":
1635+
return setting["value"]
1636+
elif image_quality_in_editor == "compressed":
1637+
image_quality_in_editor = 60
1638+
elif image_quality_in_editor == "original":
1639+
image_quality_in_editor = 100
1640+
else:
1641+
raise SABaseException(
1642+
0,
1643+
"Image quality in editor should be 'compressed', 'original' or None for project settings value"
1644+
)
16361645

16371646

16381647
def _set_project_default_image_quality_in_editor(project, quality):

tests/test_project_settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def test_get_set_settings(tmpdir):
1616
sa.create_project(PROJECT_NAME, "tt", "Vector")
1717

1818
old_settings = sa.get_project_settings(PROJECT_NAME)
19+
print(old_settings)
1920
for setting in old_settings:
2021
if "attribute" in setting and setting["attribute"] == "Brightness":
2122
brightness_value = setting["value"]

0 commit comments

Comments
 (0)