Skip to content

Commit 233f19c

Browse files
authored
Merge pull request #488 from superannotateai/develop
Develop
2 parents 3088ed5 + f9837c3 commit 233f19c

File tree

76 files changed

+2656
-3457
lines changed

Some content is hidden

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

76 files changed

+2656
-3457
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ jobs:
1414
uses: actions/setup-python@v1
1515
with:
1616
python-version: "3.7"
17+
- name: Upgrade pip
18+
run: >-
19+
python -m
20+
pip install
21+
pip --upgrade
22+
--user
1723
- name: Install pypi/build
1824
run: >-
1925
python -m

pytest.ini

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

requirements.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ pydicom>=2.0.0
22
boto3>=1.14.53
33
requests==2.26.0
44
requests-toolbelt>=0.9.1
5-
tqdm==4.48.2
5+
tqdm==4.64.0
66
pillow>=7.2.0
7-
numpy>=1.19.0
87
matplotlib>=3.3.1
98
xmltodict==0.12.0
109
opencv-python>=4.4.0.42
1110
wheel==0.35.1
1211
packaging>=20.4
13-
pandas>=1.1.4
1412
plotly==4.1.0
1513
ffmpeg-python>=0.2.0
1614
fire==0.4.0
@@ -20,3 +18,7 @@ setuptools~=57.4.0
2018
aiohttp==3.8.1
2119
email-validator>=1.0.3
2220
nest-asyncio==1.5.4
21+
jsonschema==3.2.0
22+
pandas>=1.1.4
23+
aiofiles==0.8.0
24+

src/superannotate/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import sys
33

4-
__version__ = "4.4.1"
4+
__version__ = "4.4.2b1"
55

66
sys.path.append(os.path.split(os.path.realpath(__file__))[0])
77

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

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import copy
22
import json
3+
from dataclasses import dataclass
34
from pathlib import Path
45
from typing import List
56
from typing import Optional
67
from typing import Union
78

89
import lib.core as constances
910
import pandas as pd
10-
from dataclasses import dataclass
1111
from lib.app.exceptions import AppException
1212
from lib.core import ATTACHED_VIDEO_ANNOTATION_POSTFIX
1313
from lib.core import PIXEL_ANNOTATION_POSTFIX
@@ -99,6 +99,7 @@ class DataAggregator:
9999
ry=annotation["ry"],
100100
angle=annotation["angle"],
101101
),
102+
"tag": lambda annotation: None,
102103
}
103104

104105
def __init__(
@@ -171,6 +172,18 @@ def aggregate_annotations_as_df(self):
171172
elif self.project_type == constances.ProjectType.DOCUMENT.name:
172173
return self.aggregate_document_annotations_as_df(annotation_paths)
173174

175+
def __add_attributes_to_raws(self, raws, attributes, element_raw):
176+
for attribute_id, attribute in enumerate(attributes):
177+
attribute_raw = copy.copy(element_raw)
178+
attribute_raw.attributeId = attribute_id
179+
attribute_raw.attributeGroupName = attribute.get("groupName")
180+
attribute_raw.attributeName = attribute.get("name")
181+
raws.append(attribute_raw)
182+
if not attributes:
183+
raws.append(element_raw)
184+
185+
return raws
186+
174187
def aggregate_video_annotations_as_df(self, annotation_paths: List[str]):
175188
raws = []
176189
for annotation_path in annotation_paths:
@@ -225,6 +238,9 @@ def aggregate_video_annotations_as_df(self, annotation_paths: List[str]):
225238
)
226239
instance_raw.pointLabels = instance["meta"].get("pointLabels")
227240
parameters = instance.get("parameters", [])
241+
if instance_raw.type == "tag":
242+
attributes = instance["meta"].get("attributes", [])
243+
raws = self.__add_attributes_to_raws(raws, attributes, instance_raw)
228244
for parameter_id, parameter in enumerate(parameters):
229245
parameter_raw = copy.copy(instance_raw)
230246
parameter_raw.parameterId = parameter_id
@@ -236,19 +252,12 @@ def aggregate_video_annotations_as_df(self, annotation_paths: List[str]):
236252
timestamp_raw.timestampId = timestamp_id
237253
timestamp_raw.meta = self.MAPPERS[instance_type](timestamp)
238254
attributes = timestamp.get("attributes", [])
239-
for attribute_id, attribute in enumerate(attributes):
240-
attribute_raw = copy.copy(timestamp_raw)
241-
attribute_raw.attributeId = attribute_id
242-
attribute_raw.attributeGroupName = attribute.get(
243-
"groupName"
244-
)
245-
attribute_raw.attributeName = attribute.get("name")
246-
raws.append(attribute_raw)
247-
if not attributes:
248-
raws.append(timestamp_raw)
255+
raws = self.__add_attributes_to_raws(
256+
raws, attributes, timestamp_raw
257+
)
249258
if not timestamps:
250259
raws.append(parameter_raw)
251-
if not parameters:
260+
if not parameters and instance_type != "tag":
252261
raws.append(instance_raw)
253262
if not instances:
254263
raws.append(raw_data)

src/superannotate/lib/app/annotation_helpers.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def add_annotation_comment_to_json(
8686
"y": comment_coords[1],
8787
"correspondence": [{"text": comment_text, "email": comment_author}],
8888
"resolved": resolved,
89+
"creationType": "Preannotation", # noqa
8990
"createdBy": user_action,
9091
"updatedBy": user_action,
9192
}
@@ -132,7 +133,6 @@ def add_annotation_bbox_to_json(
132133
"type": "bbox",
133134
"points": {"x1": bbox[0], "y1": bbox[1], "x2": bbox[2], "y2": bbox[3]},
134135
"className": annotation_class_name,
135-
"error": error,
136136
"groupId": 0,
137137
"pointLabels": {},
138138
"locked": False,
@@ -141,7 +141,8 @@ def add_annotation_bbox_to_json(
141141
if annotation_class_attributes is None
142142
else annotation_class_attributes,
143143
}
144-
144+
if error is not None:
145+
annotation["error"] = error
145146
annotation = _add_created_updated(annotation)
146147
annotation_json["instances"].append(annotation)
147148

@@ -175,13 +176,11 @@ def add_annotation_point_to_json(
175176
raise AppException("Point should be 2 element float list.")
176177

177178
annotation_json, path = _preprocess_annotation_json(annotation_json, image_name)
178-
179179
annotation = {
180180
"type": "point",
181181
"x": point[0],
182182
"y": point[1],
183183
"className": annotation_class_name,
184-
"error": error,
185184
"groupId": 0,
186185
"pointLabels": {},
187186
"locked": False,
@@ -190,6 +189,8 @@ def add_annotation_point_to_json(
190189
if annotation_class_attributes is None
191190
else annotation_class_attributes,
192191
}
192+
if error is not None:
193+
annotation["error"] = error
193194

194195
annotation = _add_created_updated(annotation)
195196
annotation_json["instances"].append(annotation)

src/superannotate/lib/app/helpers.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import uuid
23
from pathlib import Path
34
from typing import List
@@ -128,3 +129,21 @@ def get_name_url_duplicated_from_csv(csv_path):
128129
else:
129130
duplicate_images.append(temp)
130131
return images_to_upload, duplicate_images
132+
133+
134+
def get_tabulation() -> int:
135+
try:
136+
return int(os.get_terminal_size().columns / 2)
137+
except OSError:
138+
return 48
139+
140+
141+
def wrap_error(errors_list: List[Tuple[str, str]]) -> str:
142+
tabulation = get_tabulation()
143+
msgs = []
144+
for key, value in errors_list:
145+
_tabulation = tabulation - len(key)
146+
if not key:
147+
key, value, _tabulation = value, "", 0
148+
msgs.append("{}{}{}".format(key, " " * _tabulation, value))
149+
return "\n".join(msgs)

src/superannotate/lib/app/input_converters/converters/coco_converters/coco_converter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ def make_anno_json_generator(self):
305305
jsons = list(Path(self.export_root).glob("*objects.json"))
306306

307307
self.set_num_total_images(len(jsons))
308-
print()
309308
for fpath in jsons:
310309
with open(fpath) as fp:
311310
json_data = json.load(fp)

0 commit comments

Comments
 (0)