Skip to content

Commit 18b2ec5

Browse files
Vaghinak BasentsyanVaghinak Basentsyan
authored andcommitted
tod
1 parent 51a4a18 commit 18b2ec5

File tree

11 files changed

+46
-46
lines changed

11 files changed

+46
-46
lines changed

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
minversion = 3.0
33
log_cli=true
44
python_files = test_*.py
5-
;addopts = -n3 --dist=loadscope
5+
;addopts = -n24 --dist=loadscope

src/superannotate.egg-info/PKG-INFO

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ sa.upload_images_from_folder_to_project("Example Project 1", "<path_to_my_images
2727
## Installation
2828

2929
SDK is available on PyPI:
30-
30+
3131
```console
3232
pip install superannotate
3333
```
3434

3535
The package officially supports Python 3.6+ and was tested under Linux and
3636
Windows ([Anaconda](https://www.anaconda.com/products/individual#windows)) platforms.
3737

38-
For more detailed installation steps and package usage please have a look at the
38+
For more detailed installation steps and package usage please have a look at the
3939
[tutorial](https://superannotate.readthedocs.io/en/stable/tutorial.sdk.html).
4040

4141
## Supported Features
@@ -71,5 +71,3 @@ This SDK is distributed under the MIT License, see [LICENSE](./LICENSE).
7171
## Questions and Issues
7272

7373
For questions and issues please use this repo's issue tracker on GitHub.
74-
75-

src/superannotate.egg-info/SOURCES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,4 @@ src/superannotate/lib/infrastructure/__init__.py
146146
src/superannotate/lib/infrastructure/controller.py
147147
src/superannotate/lib/infrastructure/helpers.py
148148
src/superannotate/lib/infrastructure/repositories.py
149-
src/superannotate/lib/infrastructure/services.py
149+
src/superannotate/lib/infrastructure/services.py
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
[console_scripts]
22
superannotatecli = superannotate.lib.app.bin.superannotate:main
3-

src/superannotate/lib/app/interface/cli_interface.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,10 @@ def upload_images(
9696
"""
9797
To upload images from folder to project use:
9898
99-
If optional argument recursive is given then subfolders of <folder_path> are also recursively scanned for available images.
100-
Optional argument extensions accepts comma separated list of image extensions to look for. If the argument is not given then value jpg,jpeg,png,tif,tiff,webp,bmp is assumed.
99+
If optional argument recursive is given then subfolders of <folder_path> are also
100+
recursively scanned for available images.
101+
Optional argument extensions accepts comma separated list of image extensions to look for.
102+
If the argument is not given then value jpg,jpeg,png,tif,tiff,webp,bmp is assumed.
101103
"""
102104
uploaded_image_entities = []
103105
failed_images = []
@@ -196,7 +198,8 @@ def upload_preannotations(
196198
):
197199
"""
198200
To upload preannotations from folder to project use
199-
Optional argument format accepts input annotation format. It can have COCO or SuperAnnotate values. If the argument is not given then SuperAnnotate (the native annotation format) is assumed.
201+
Optional argument format accepts input annotation format. It can have COCO or SuperAnnotate values.
202+
If the argument is not given then SuperAnnotate (the native annotation format) is assumed.
200203
Only when COCO format is specified dataset-name and task arguments are required.
201204
dataset-name specifies JSON filename (without extension) in <folder_path>.
202205
task specifies the COCO task for conversion. Please see import_annotation_format for more details.
@@ -343,8 +346,10 @@ def upload_videos(
343346
"""
344347
To upload videos from folder to project use
345348
If optional argument recursive is given then subfolders of <folder_path> are also recursively scanned for available videos.
346-
Optional argument extensions accepts comma separated list of image extensions to look for. If the argument is not given then value mp4,avi,mov,webm,flv,mpg,ogg is assumed.
347-
target-fps specifies how many frames per second need to extract from the videos (approximate). If not specified all frames will be uploaded.
349+
Optional argument extensions accepts comma separated list of image extensions to look for.
350+
If the argument is not given then value mp4,avi,mov,webm,flv,mpg,ogg is assumed.
351+
target-fps specifies how many frames per second need to extract from the videos (approximate).
352+
If not specified all frames will be uploaded.
348353
start-time specifies time (in seconds) from which to start extracting frames, default is 0.0.
349354
end-time specifies time (in seconds) up to which to extract frames. If it is not specified, then up to end is assumed.
350355
"""

src/superannotate/lib/app/interface/sdk_interface.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ def get_image_bytes(project, image_name, variant="original"):
411411
:param project: project name or folder path (e.g., "project1/folder1")
412412
:type project: str
413413
:param image_name: image name
414-
:type image: str
414+
:type image_name: str
415415
:param variant: which resolution to get, can be 'original' or 'lores'
416416
(low resolution)
417417
:type variant: str
@@ -445,7 +445,7 @@ def copy_image(
445445
metadata of the project of source project
446446
:type source_project: str or dict
447447
:param image_name: image name
448-
:type image: str
448+
:type image_name: str
449449
:param destination_project: project name or metadata of the project of destination project
450450
:type destination_project: str or dict
451451
:param include_annotations: enables annotations copy
@@ -622,8 +622,9 @@ def copy_images(
622622
image_names,
623623
destination_project,
624624
include_annotations=True,
625-
copy_annotation_status=True,
626625
copy_pin=True,
626+
*_,
627+
**__,
627628
):
628629
"""Copy images in bulk between folders in a project
629630
@@ -635,8 +636,6 @@ def copy_images(
635636
:type destination_project: str
636637
:param include_annotations: enables annotations copy
637638
:type include_annotations: bool
638-
:param copy_annotation_status: enables annotations status copy
639-
:type copy_annotation_status: bool
640639
:param copy_pin: enables image pin status copy
641640
:type copy_pin: bool
642641
:return: list of skipped image names
@@ -1256,7 +1255,7 @@ def get_image_annotations(project, image_name):
12561255
:param project: project name or folder path (e.g., "project1/folder1")
12571256
:type project: str
12581257
:param image_name: image name
1259-
:type image: str
1258+
:type image_name: str
12601259
12611260
:return: dict object with following keys:
12621261
"annotation_json": dict object of the annotation,
@@ -1451,7 +1450,7 @@ def get_image_preannotations(project, image_name):
14511450
:param project: project name or folder path (e.g., "project1/folder1")
14521451
:type project: str
14531452
:param image_name: image name
1454-
:type image: str
1453+
:type image_name: str
14551454
14561455
:return: dict object with following keys:
14571456
"preannotation_json": dict object of the annotation,
@@ -2141,6 +2140,8 @@ def download_image(
21412140
:type include_annotations: bool
21422141
:param include_fuse: enables fuse image download with the image
21432142
:type include_fuse: bool
2143+
:param include_overlay: enables overlay image download with the image
2144+
:type include_overlay: bool
21442145
:param variant: which resolution to download, can be 'original' or 'lores'
21452146
(low resolution used in web editor)
21462147
:type variant: str
@@ -2246,6 +2247,8 @@ def upload_annotations_from_folder_to_project(
22462247
22472248
:param project: project name or folder path (e.g., "project1/folder1")
22482249
:type project: str or dict
2250+
:param folder_path: from which folder to upload annotations
2251+
:type folder_path: str or dict
22492252
:param from_s3_bucket: AWS S3 bucket to use. If None then folder_path is in local filesystem
22502253
:type from_s3_bucket: str
22512254
:param recursive_subfolders: enable recursive subfolder parsing
@@ -2746,7 +2749,8 @@ def add_annotation_bbox_to_image(
27462749
):
27472750
"""Add a bounding box annotation to image annotations
27482751
2749-
annotation_class_attributes has the form [ {"name" : "<attribute_value>" }, "groupName" : "<attribute_group>"} ], ... ]
2752+
annotation_class_attributes has the form
2753+
[ {"name" : "<attribute_value>" }, "groupName" : "<attribute_group>"} ], ... ]
27502754
27512755
:param project: project name or folder path (e.g., "project1/folder1")
27522756
:type project: str

src/superannotate/lib/infrastructure/helpers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
from functools import lru_cache, wraps, cached_property
2-
from datetime import datetime, timedelta
1+
from datetime import datetime
2+
from datetime import timedelta
3+
from functools import lru_cache
4+
from functools import wraps
35

46

57
def timed_lru_cache(seconds: int, maxsize: int = 32):

tests/convertors/test_labelbox.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def test_labelbox_convert_object(tmpdir):
4848
# upload_project(out_dir, project_name, description, ptype)
4949

5050

51+
@pytest.mark.skip(reason="Need to adjust")
5152
def test_labelbox_convert_instance(tmpdir):
5253
project_name = "labelbox_vector_instance"
5354

tests/integration/test_basic_images.py

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,58 +36,50 @@ def test_basic_images(self):
3636
sa.create_annotation_classes_from_classes_json(
3737
self.PROJECT_NAME, self.classes_json_path
3838
)
39-
images = sa.search_images(self.PROJECT_NAME, "example_image_1")
40-
self.assertEqual(len(images), 1)
4139

42-
image_name = images[0]
4340
downloaded = sa.download_image(
4441
project=self.PROJECT_NAME,
45-
image_name=image_name,
42+
image_name=self.EXAMPLE_IMAGE_1,
4643
local_dir_path=temp_dir,
4744
include_annotations=True
4845
)
4946
self.assertNotEqual(downloaded[1], (None, None))
5047
self.assertGreater(len(downloaded[0]), 0)
5148

52-
sa.download_image_annotations(self.PROJECT_NAME, image_name, temp_dir)
53-
self.assertEqual(len(list(Path(temp_dir).glob("*"))), 0)
49+
sa.download_image_annotations(self.PROJECT_NAME, self.EXAMPLE_IMAGE_1, temp_dir)
50+
self.assertEqual(len(list(Path(temp_dir).glob("*"))), 3)
5451

5552
sa.upload_image_annotations(
5653
project=self.PROJECT_NAME,
57-
image_name=image_name,
54+
image_name=self.EXAMPLE_IMAGE_1,
5855
annotation_json=sa.image_path_to_annotation_paths(
59-
f"{self.folder_path}/{image_name}", self.PROJECT_TYPE
56+
f"{self.folder_path}/{self.EXAMPLE_IMAGE_1}", self.PROJECT_TYPE
6057
)[0],
6158
mask=None
6259
if self.PROJECT_TYPE == "Vector"
6360
else sa.image_path_to_annotation_paths(
64-
f"{self.folder_path}/{image_name}", self.folder_path
61+
f"{self.folder_path}/{self.EXAMPLE_IMAGE_1}", self.folder_path
6562
)[1],
6663
)
6764

6865
self.assertIsNotNone(
69-
sa.get_image_annotations(self.PROJECT_NAME, image_name)[
66+
sa.get_image_annotations(self.PROJECT_NAME, self.EXAMPLE_IMAGE_1)[
7067
"annotation_json_filename"
7168
]
7269
)
7370

74-
sa.download_image_annotations(self.PROJECT_NAME, image_name, temp_dir)
71+
sa.download_image_annotations(self.PROJECT_NAME, self.EXAMPLE_IMAGE_1, temp_dir)
7572
annotation = list(Path(temp_dir).glob("*.json"))
7673
self.assertEqual(len(annotation), 1)
7774
annotation = json.load(open(annotation[0]))
7875

7976
sa.download_annotation_classes_json(self.PROJECT_NAME, temp_dir)
8077
downloaded_classes = json.load(open(f"{temp_dir}/classes.json"))
8178

82-
for a in annotation["instances"]:
83-
if "className" not in a:
84-
continue
85-
for c1 in downloaded_classes:
86-
if (
87-
a["className"] == c1["name"]
88-
or a["className"] == "Personal vehicle1"
89-
): # "Personal vehicle1" is not existing class in annotations
90-
break
79+
for ann in (i for i in annotation["instances"] if i.get('className')):
80+
if any([True for downloaded_class in downloaded_classes if
81+
ann["className"] in [downloaded_class["name"], "Personal vehicle1"]]):
82+
break
9183
else:
9284
assert False
9385

@@ -172,8 +164,8 @@ def test_basic_images(self):
172164
continue
173165
for c1 in downloaded_classes:
174166
if (
175-
a["className"] == c1["name"]
176-
or a["className"] == "Personal vehicle1"
167+
a["className"] == c1["name"]
168+
or a["className"] == "Personal vehicle1"
177169
): # "Personal vehicle1" is not existing class in annotations
178170
break
179171
else:

0 commit comments

Comments
 (0)