Skip to content

Commit 5e874ae

Browse files
committed
2 parents 4b51ef5 + d2fa601 commit 5e874ae

File tree

8 files changed

+3102
-13
lines changed

8 files changed

+3102
-13
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ clean:
2424
coverage: test_coverage
2525

2626
test_coverage:
27-
$(PYTESTS) --cov=superannotate -n 8
27+
-$(PYTESTS) --cov=superannotate -n 8
2828
$(COVERAGE) html
2929
@echo "\033[95m\n\nCoverage successful! View the output at file://htmlcov/index.html.\n\033[0m"
3030

docs/source/cli.rst

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,22 @@ To upload preannotations from folder to project use:
9696
.. code-block:: bash
9797
9898
superannotate upload-preannotations --project <project_name> --folder <folder_path>
99-
[--format "COCO" or "SA"] [--dataset-name "<dataset_name_for_COCO_projects>"]
99+
[--format "COCO" or "SuperAnnotate"]
100+
[--dataset-name "<dataset_name_for_COCO_projects>"]
100101
[--task "<task_type_for_COCO_projects>]
101102
102103
103-
Optional argument *format* accepts input preannotation format. It can have COCO or SuperAnnotate values.
104-
If the argument is not given then SuperAnnotate (the native preannotation format) assumed.
104+
Optional argument *format* accepts input annotation format. It can have COCO or SuperAnnotate values.
105+
If the argument is not given then SuperAnnotate (the native annotation format) is assumed.
106+
107+
Only when COCO format is specified *dataset-name* and *task* arguments are required.
108+
109+
*dataset-name* specifies JSON filename (without extension) in <folder_path>.
110+
111+
*task* specifies the COCO task for conversion. Please see
112+
:ref:`import_annotation_format <ref_import_annotation_format>` for more details.
113+
114+
The annotation classes will be created during the execution of this command.
105115
106116
----------
107117
@@ -115,11 +125,22 @@ To upload annotations from folder to project use:
115125
.. code-block:: bash
116126
117127
superannotate upload-annotations --project <project_name> --folder <folder_path>
118-
[--format "COCO" or "SA"] [--dataset-name "<dataset_name_for_COCO_projects>"]
128+
[--format "COCO" or "SuperAnnotate"]
129+
[--dataset-name "<dataset_name_for_COCO_projects>"]
119130
[--task "<task_type_for_COCO_projects>]
120131
121-
Optional argument *format* accepts input preannotation format. It can have COCO or SuperAnnotate values.
122-
If the argument is not given then SuperAnnotate (the native preannotation format) assumed.
132+
Optional argument *format* accepts input annotation format. It can have COCO or SuperAnnotate values.
133+
If the argument is not given then SuperAnnotate (the native annotation format) is assumed.
134+
135+
Only when COCO format is specified *dataset-name* and *task* arguments are required.
136+
137+
*dataset-name* specifies JSON filename (without extension) in <folder_path>.
138+
139+
*task* specifies the COCO task for conversion. Please see
140+
:ref:`import_annotation_format <ref_import_annotation_format>` for more details.
141+
142+
The annotation classes will be created during the execution of this command.
143+
123144

124145
----------
125146

docs/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020

2121
project = 'SuperAnnotate Python SDK'
2222
copyright = '2020, SuperAnnotate AI'
23-
author = 'Hovnatan Karapetyan, Vahagn Tumanyan, Armen Gyurjinyan, Shabin Dilanchian'
23+
author = 'Hovnatan Karapetyan, Vahagn Tumanyan, Armen Gyurjinyan, Shabin Dilanchian, Erik Harutyunyan, Arsine Mangasaryan'
2424

2525
# The full version, including alpha/beta/rc tags
26-
release = '1.0'
26+
release = superannotate.__version__
2727

2828
# -- General configuration ---------------------------------------------------
2929
master_doc = 'index'

docs/source/superannotate.sdk.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ Converting annotation format to and from SuperAnnotate format
282282
_____________________________________________________________
283283

284284

285+
.. _ref_import_annotation_format:
285286
.. autofunction:: superannotate.import_annotation_format
286287
.. autofunction:: superannotate.export_annotation_format
287288
.. autofunction:: superannotate.convert_project_type
@@ -302,7 +303,6 @@ ________________________
302303
.. autofunction:: superannotate.add_annotation_cuboid_to_json
303304
.. autofunction:: superannotate.add_annotation_comment_to_json
304305
.. autofunction:: superannotate.aggregate_annotations_as_df
305-
.. autofunction:: superannotate.consensus
306306
.. autofunction:: superannotate.df_to_annotations
307307
.. _ref_filter_annotation_instances:
308308
.. autofunction:: superannotate.filter_annotation_instances

superannotate/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.3.2"
1+
__version__ = "2.3.5"

tests/sample_project_vector/example_image_1.jpg___objects.json

Lines changed: 2996 additions & 1 deletion
Large diffs are not rendered by default.

tests/test_annotation_adding.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from pathlib import Path
22
import json
3-
import time
43

54
import pytest
65

@@ -133,3 +132,39 @@ def test_add_bbox_noinit(tmpdir):
133132
export = sa.prepare_export(project, include_fuse=True)
134133
sa.download_export(project, export, tmpdir)
135134
assert len(list(Path(tmpdir).rglob("*.*"))) == 4
135+
136+
137+
def test_add_bbox_json(tmpdir):
138+
tmpdir = Path(tmpdir)
139+
140+
dest = tmpdir / "test.json"
141+
src = Path(
142+
"./tests/sample_project_vector/example_image_1.jpg___objects.json"
143+
)
144+
dest.write_text(src.read_text())
145+
annotations = json.load(open(dest))
146+
sa.add_annotation_bbox_to_json(dest, [10, 10, 500, 100], "test_add")
147+
sa.add_annotation_polyline_to_json(
148+
dest, [110, 110, 510, 510, 600, 510], "test_add"
149+
)
150+
sa.add_annotation_polygon_to_json(
151+
dest, [100, 100, 500, 500, 200, 300], "test_add",
152+
[{
153+
"name": "tall",
154+
"groupName": "height"
155+
}]
156+
)
157+
sa.add_annotation_point_to_json(dest, [250, 250], "test_add")
158+
sa.add_annotation_ellipse_to_json(dest, [405, 405, 20, 70, 15], "test_add")
159+
sa.add_annotation_template_to_json(
160+
dest, [600, 30, 630, 30, 615, 60], [1, 3, 2, 3], "test_add"
161+
)
162+
sa.add_annotation_cuboid_to_json(
163+
dest, [800, 500, 900, 600, 850, 450, 950, 700], "test_add"
164+
)
165+
sa.add_annotation_comment_to_json(
166+
dest, "hey", [100, 100], "hovnatan@superannotate.com", True
167+
)
168+
annotations_new = json.load(open(dest))
169+
170+
assert len(annotations_new) == len(annotations) + 8

tests/test_preannotation_upload_cli.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,44 @@ def test_preannotation_folder_upload_download_cli(
5252
assert count_in == count_out
5353

5454

55+
def test_annotation_folder_upload_download_cli_vector_COCO(tmpdir):
56+
project_type = "Vector"
57+
name = "Example Project test vector2 annotation cli upload coco vector"
58+
description = "test"
59+
from_folder = "./tests/converter_test/COCO/input/toSuperAnnotate/keypoint_detection"
60+
task = "keypoint_detection"
61+
dataset_name = "person_keypoints_test"
62+
63+
projects_found = sa.search_projects(name, return_metadata=True)
64+
for pr in projects_found:
65+
sa.delete_project(pr)
66+
67+
project = sa.create_project(name, description, project_type)
68+
sa.upload_images_from_folder_to_project(
69+
project, from_folder, annotation_status="InProgress"
70+
)
71+
# sa.create_annotation_classes_from_classes_json(
72+
# project, from_folder / "classes" / "classes.json"
73+
# )
74+
subprocess.run(
75+
[
76+
f"superannotate upload-annotations --project '{name}' --folder '{from_folder}' --format COCO --task {task} --dataset-name {dataset_name}"
77+
],
78+
check=True,
79+
shell=True
80+
)
81+
# time.sleep(5)
82+
# count_in = len(list(from_folder.glob("*.json")))
83+
84+
# images = sa.search_images(project)
85+
# for image_name in images:
86+
# sa.download_image_preannotations(project, image_name, tmpdir)
87+
88+
# count_out = len(list(Path(tmpdir).glob("*.json")))
89+
90+
# assert count_in == count_out
91+
92+
5593
def test_preannotation_folder_upload_download_cli_vector_COCO(tmpdir):
5694
project_type = "Vector"
5795
name = "Example Project test vector2 preannotation cli upload coco vector"

0 commit comments

Comments
 (0)