Skip to content

Commit bb1a53b

Browse files
authored
Merge pull request #439 from superannotateai/develop
Develop
2 parents d7e2f97 + 6f0b2a8 commit bb1a53b

File tree

71 files changed

+2508
-2634
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2508
-2634
lines changed

docs/source/superannotate.sdk.rst

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,16 @@ ________
3434
.. autofunction:: superannotate.create_folder
3535
.. autofunction:: superannotate.delete_folders
3636
.. autofunction:: superannotate.upload_images_to_project
37-
.. autofunction:: superannotate.attach_image_urls_to_project
38-
.. autofunction:: superannotate.attach_document_urls_to_project
3937
.. autofunction:: superannotate.attach_items_from_integrated_storage
4038
.. autofunction:: superannotate.upload_image_to_project
4139
.. autofunction:: superannotate.delete_annotations
4240
.. _ref_upload_images_from_folder_to_project:
4341
.. autofunction:: superannotate.upload_images_from_folder_to_project
4442
.. autofunction:: superannotate.upload_video_to_project
4543
.. autofunction:: superannotate.upload_videos_from_folder_to_project
46-
.. autofunction:: superannotate.attach_video_urls_to_project
4744
.. _ref_upload_annotations_from_folder_to_project:
4845
.. autofunction:: superannotate.upload_annotations_from_folder_to_project
4946
.. autofunction:: superannotate.upload_preannotations_from_folder_to_project
50-
.. autofunction:: superannotate.share_project
5147
.. autofunction:: superannotate.add_contributors_to_project
5248
.. autofunction:: superannotate.get_project_settings
5349
.. autofunction:: superannotate.set_project_default_image_quality_in_editor
@@ -73,6 +69,7 @@ ______
7369

7470
.. autofunction:: superannotate.query
7571
.. autofunction:: superannotate.search_items
72+
.. autofunction:: superannotate.download_annotations
7673
.. autofunction:: superannotate.attach_items
7774
.. autofunction:: superannotate.copy_items
7875
.. autofunction:: superannotate.move_items
@@ -92,8 +89,6 @@ ______
9289
.. autofunction:: superannotate.download_image_annotations
9390
.. autofunction:: superannotate.upload_image_annotations
9491
.. autofunction:: superannotate.copy_image
95-
.. autofunction:: superannotate.copy_images
96-
.. autofunction:: superannotate.move_images
9792
.. autofunction:: superannotate.pin_image
9893
.. autofunction:: superannotate.assign_images
9994
.. autofunction:: superannotate.delete_images
@@ -159,11 +154,26 @@ Project metadata example:
159154
"attachment_name": None,
160155
"attachment_path": None,
161156
"entropy_status": 1,
162-
"status": 0,
157+
"status": "NotStarted",
163158
"...": "..."
164159
}
165160
166161
162+
----------
163+
164+
Setting metadata
165+
_________________
166+
167+
Setting metadata example:
168+
169+
.. code-block:: python
170+
171+
{
172+
"attribute": "FrameRate",
173+
"value": 3
174+
}
175+
176+
167177
----------
168178

169179
Export metadata
@@ -250,6 +260,38 @@ Image metadata example:
250260
}
251261
252262
263+
----------
264+
265+
Priority score
266+
_______________
267+
268+
269+
Priority score example:
270+
271+
.. code-block:: python
272+
273+
{
274+
"name" : "image1.png",
275+
"priority": 0.567
276+
}
277+
278+
279+
----------
280+
281+
Attachment
282+
_______________
283+
284+
285+
Attachment example:
286+
287+
.. code-block:: python
288+
289+
{
290+
"url": "https://sa-public-files.s3.../text_file_example_1.jpeg",
291+
"name": "example.jpeg"
292+
}
293+
294+
253295
----------
254296

255297
.. _ref_class:

docs/source/tutorial.sdk.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -390,16 +390,6 @@ A team contributor can be invited to the team with:
390390
391391
sa.invite_contributors_to_team(emails=["admin@superannotate.com"], admin=False)
392392
393-
394-
This invitation should be accepted by the contributor. After which, to share the
395-
project with the found contributor as an QA:
396-
397-
.. code-block:: python
398-
399-
sa.share_project(project, "admin@superannotate.com", user_role="QA")
400-
401-
402-
403393
----------
404394

405395

pytest.ini

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

requirements_dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
superannotate_schemas>=v1.0.42dev2
1+
superannotate_schemas>=v1.0.43dev5
22

requirements_extra.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ pytest==6.2.4
55
pytest-xdist==2.3.0
66
pytest-parallel==0.1.0
77
pytest-rerunfailures==10.2
8-
sphinx_rtd_theme==1.0.0
8+
sphinx_rtd_theme==1.0.0
9+
pytest-cov

src/superannotate/__init__.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import sys
44

55
import requests
6-
import superannotate.lib.core as constances
76
from packaging.version import parse
7+
from superannotate.lib import core as constances
88
from superannotate.lib import get_default_controller
99
from superannotate.lib.app.analytics.class_analytics import class_distribution
1010
from superannotate.lib.app.exceptions import AppException
@@ -21,20 +21,14 @@
2121
from superannotate.lib.app.interface.sdk_interface import aggregate_annotations_as_df
2222
from superannotate.lib.app.interface.sdk_interface import assign_folder
2323
from superannotate.lib.app.interface.sdk_interface import assign_images
24-
from superannotate.lib.app.interface.sdk_interface import (
25-
attach_document_urls_to_project,
26-
)
27-
from superannotate.lib.app.interface.sdk_interface import attach_image_urls_to_project
2824
from superannotate.lib.app.interface.sdk_interface import attach_items
2925
from superannotate.lib.app.interface.sdk_interface import (
3026
attach_items_from_integrated_storage,
3127
)
32-
from superannotate.lib.app.interface.sdk_interface import attach_video_urls_to_project
3328
from superannotate.lib.app.interface.sdk_interface import benchmark
3429
from superannotate.lib.app.interface.sdk_interface import clone_project
3530
from superannotate.lib.app.interface.sdk_interface import consensus
3631
from superannotate.lib.app.interface.sdk_interface import copy_image
37-
from superannotate.lib.app.interface.sdk_interface import copy_images
3832
from superannotate.lib.app.interface.sdk_interface import copy_items
3933
from superannotate.lib.app.interface.sdk_interface import create_annotation_class
4034
from superannotate.lib.app.interface.sdk_interface import (
@@ -68,7 +62,6 @@
6862
from superannotate.lib.app.interface.sdk_interface import get_team_metadata
6963
from superannotate.lib.app.interface.sdk_interface import init
7064
from superannotate.lib.app.interface.sdk_interface import invite_contributors_to_team
71-
from superannotate.lib.app.interface.sdk_interface import move_images
7265
from superannotate.lib.app.interface.sdk_interface import move_items
7366
from superannotate.lib.app.interface.sdk_interface import pin_image
7467
from superannotate.lib.app.interface.sdk_interface import prepare_export
@@ -89,7 +82,6 @@
8982
set_project_default_image_quality_in_editor,
9083
)
9184
from superannotate.lib.app.interface.sdk_interface import set_project_workflow
92-
from superannotate.lib.app.interface.sdk_interface import share_project
9385
from superannotate.lib.app.interface.sdk_interface import unassign_folder
9486
from superannotate.lib.app.interface.sdk_interface import unassign_images
9587
from superannotate.lib.app.interface.sdk_interface import (
@@ -154,7 +146,6 @@
154146
"search_projects",
155147
"create_project",
156148
"clone_project",
157-
"share_project",
158149
"delete_project",
159150
"rename_project",
160151
"upload_priority_scores",
@@ -176,8 +167,6 @@
176167
"move_items",
177168
"set_annotation_statuses",
178169
# Image Section
179-
"copy_images",
180-
"move_images",
181170
"delete_images",
182171
"download_image",
183172
"pin_image",
@@ -189,9 +178,6 @@
189178
"upload_image_to_project",
190179
"upload_image_annotations",
191180
"upload_images_from_folder_to_project",
192-
"attach_image_urls_to_project",
193-
"attach_video_urls_to_project",
194-
"attach_document_urls_to_project",
195181
# Video Section
196182
"upload_videos_from_folder_to_project",
197183
# Annotation Section
@@ -223,8 +209,7 @@
223209

224210
__author__ = "Superannotate"
225211

226-
WORKING_DIR = os.path.split(os.path.realpath(__file__))[0]
227-
sys.path.append(WORKING_DIR)
212+
sys.path.append(os.path.split(os.path.realpath(__file__))[0])
228213
logging.getLogger("botocore").setLevel(logging.CRITICAL)
229214
logger = get_default_logger()
230215

src/superannotate/lib/app/analytics/aggregators.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@ class DocumentRawData:
8585

8686

8787
class DataAggregator:
88+
MAPPERS = {
89+
"event": lambda annotation: None,
90+
"bbox": lambda annotation: annotation["points"],
91+
"polygon": lambda annotation: annotation["points"],
92+
"polyline": lambda annotation: annotation["points"],
93+
"cuboid": lambda annotation: annotation["points"],
94+
"point": lambda annotation: {"x": annotation["x"], "y": annotation["y"]},
95+
"annotation_type": lambda annotation: dict(
96+
cx=annotation["cx"],
97+
cy=annotation["cy"],
98+
rx=annotation["rx"],
99+
ry=annotation["ry"],
100+
angle=annotation["angle"],
101+
),
102+
}
103+
88104
def __init__(
89105
self,
90106
project_type: str,
@@ -186,11 +202,12 @@ def aggregate_video_annotations_as_df(self, annotation_paths: List[str]):
186202
# append instances
187203
instances = annotation_data.get("instances", [])
188204
for idx, instance in enumerate(instances):
205+
instance_type = instance["meta"].get("type", "event")
189206
instance_raw = copy.copy(raw_data)
190207
instance_raw.instanceId = int(idx)
191208
instance_raw.instanceStart = instance["meta"].get("start")
192209
instance_raw.instanceEnd = instance["meta"].get("end")
193-
instance_raw.type = instance["meta"].get("type")
210+
instance_raw.type = instance_type
194211
instance_raw.className = instance["meta"].get("className")
195212
instance_raw.createdAt = instance["meta"].get("createdAt")
196213
instance_raw.createdBy = (
@@ -217,7 +234,7 @@ def aggregate_video_annotations_as_df(self, annotation_paths: List[str]):
217234
for timestamp_id, timestamp in enumerate(timestamps):
218235
timestamp_raw = copy.copy(parameter_raw)
219236
timestamp_raw.timestampId = timestamp_id
220-
timestamp_raw.meta = timestamp.get("points")
237+
timestamp_raw.meta = self.MAPPERS[instance_type](timestamp)
221238
attributes = timestamp.get("attributes", [])
222239
for attribute_id, attribute in enumerate(attributes):
223240
attribute_raw = copy.copy(timestamp_raw)
@@ -467,8 +484,7 @@ def __append_annotation(annotation_dict):
467484
]
468485
):
469486
logger.warning(
470-
"Annotation class group value %s not in classes json. Skipping.",
471-
attribute_name,
487+
f"Annotation class group value {attribute_name} not in classes json. Skipping."
472488
)
473489
continue
474490
annotation_dict = {

src/superannotate/lib/app/common.py

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,11 @@
11
import json
2-
import os
3-
import sys
4-
import time
52

63
import numpy as np
7-
from PIL import Image
84
from superannotate.logger import get_default_logger
95
from tqdm import tqdm
106

117
logger = get_default_logger()
128

13-
_PROJECT_TYPES = {"Vector": 1, "Pixel": 2}
14-
15-
_ANNOTATION_STATUSES = {
16-
"NotStarted": 1,
17-
"InProgress": 2,
18-
"QualityCheck": 3,
19-
"Returned": 4,
20-
"Completed": 5,
21-
"Skipped": 6,
22-
}
23-
249

2510
def hex_to_rgb(hex_string):
2611
"""Converts HEX values to RGB values
@@ -68,73 +53,6 @@ def id2rgb(id_map):
6853
return color
6954

7055

71-
def save_desktop_format(output_dir, classes, files_dict):
72-
cat_id_map = {}
73-
new_classes = []
74-
for idx, class_ in enumerate(classes):
75-
cat_id_map[class_["name"]] = idx + 2
76-
class_["id"] = idx + 2
77-
new_classes.append(class_)
78-
with open(output_dir.joinpath("classes.json"), "w") as fw:
79-
json.dump(new_classes, fw)
80-
81-
meta = {
82-
"type": "meta",
83-
"name": "lastAction",
84-
"timestamp": int(round(time.time() * 1000)),
85-
}
86-
new_json = {}
87-
files_path = []
88-
(output_dir / "images" / "thumb").mkdir()
89-
for file_name, json_data in files_dict.items():
90-
file_name = file_name.replace("___objects.json", "")
91-
if not (output_dir / "images" / file_name).exists():
92-
continue
93-
94-
for js_data in json_data:
95-
if "className" in js_data:
96-
js_data["classId"] = cat_id_map[js_data["className"]]
97-
json_data.append(meta)
98-
new_json[file_name] = json_data
99-
100-
files_path.append(
101-
{
102-
"srcPath": str(output_dir.resolve() / file_name),
103-
"name": file_name,
104-
"imagePath": str(output_dir.resolve() / file_name),
105-
"thumbPath": str(
106-
output_dir.resolve()
107-
/ "images"
108-
/ "thumb"
109-
/ ("thmb_" + file_name + ".jpg")
110-
),
111-
"valid": True,
112-
}
113-
)
114-
115-
img = Image.open(output_dir / "images" / file_name)
116-
img.thumbnail((168, 120), Image.ANTIALIAS)
117-
img.save(output_dir / "images" / "thumb" / ("thmb_" + file_name + ".jpg"))
118-
119-
with open(output_dir / "images" / "images.sa", "w") as fw:
120-
fw.write(json.dumps(files_path))
121-
122-
with open(output_dir.joinpath("annotations.json"), "w") as fw:
123-
json.dump(new_json, fw)
124-
125-
with open(output_dir / "config.json", "w") as fw:
126-
json.dump({"pathSeparator": os.sep, "os": sys.platform}, fw)
127-
128-
129-
def save_web_format(output_dir, classes, files_dict):
130-
for key, value in files_dict.items():
131-
with open(output_dir.joinpath(key), "w") as fw:
132-
json.dump(value, fw, indent=2)
133-
134-
with open(output_dir.joinpath("classes", "classes.json"), "w") as fw:
135-
json.dump(classes, fw)
136-
137-
13856
def write_to_json(output_path, json_data):
13957
with open(output_path, "w") as fw:
14058
json.dump(json_data, fw, indent=2)

0 commit comments

Comments
 (0)