Skip to content

Commit 3765700

Browse files
Vaghinak BasentsyanVaghinak Basentsyan
authored andcommitted
Added video convertor
1 parent ed1af5d commit 3765700

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/superannotate/lib/core/helpers.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def fill_annotation_ids(
118118
][attribute["groupName"]]["attributes"][attribute["name"]]
119119

120120

121-
def convert_to_video_editor_json(data: dict, class_name_mapper: dict):
121+
def convert_to_video_editor_json(data: dict, class_name_mapper: dict, reporter: Reporter):
122122
def safe_time(timestamp):
123123
return "0" if str(timestamp) == "0.0" else timestamp
124124

@@ -170,12 +170,18 @@ def convert_timestamp(timestamp):
170170
]
171171

172172
if not class_name_mapper.get(meta["className"], None):
173+
reporter.store_message("missing_classes", meta["className"])
173174
continue
174175

175176
existing_attributes_in_current_instance = set()
176177
for attribute in timestamp_data["attributes"]:
177-
key = attribute["groupName"], attribute["name"]
178-
existing_attributes_in_current_instance.add(key)
178+
group_name, attr_name = attribute.get("groupName"), attribute.get("name")
179+
if not class_name_mapper[class_name].get("attribute_groups", {}).get(group_name):
180+
reporter.store_message("missing_attribute_groups", f"{class_name}.{group_name}")
181+
elif not class_name_mapper[class_name]["attribute_groups"][group_name].get("attributes", {}).get(attr_name):
182+
reporter.store_message("missing_attributes", f"{class_name}.{group_name}.{attr_name}")
183+
else:
184+
existing_attributes_in_current_instance.add((group_name, attr_name))
179185
attributes_to_add = (
180186
existing_attributes_in_current_instance - active_attributes
181187
)
@@ -212,7 +218,6 @@ def convert_timestamp(timestamp):
212218
editor_instance["timeline"][timestamp]["attributes"]["-"].append(
213219
attr
214220
)
215-
216221
editor_data["instances"].append(editor_instance)
217222
return editor_data
218223

src/superannotate/lib/core/usecases/annotations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def _log_report(self):
198198
elif key == "missing_attributes":
199199
template = "Could not find attributes matching existing attributes on the platform: [{}]"
200200
logger.warning(
201-
template.format(", ".join(values))
201+
template.format("', '".join(values))
202202
)
203203

204204
def execute(self):
@@ -373,7 +373,7 @@ def prepare_annotations(
373373
)
374374
elif project_type == constances.ProjectType.VIDEO.value:
375375
annotations = convert_to_video_editor_json(
376-
annotations, map_annotation_classes_name(annotation_classes, reporter)
376+
annotations, map_annotation_classes_name(annotation_classes, reporter), reporter
377377
)
378378
return annotations
379379

tests/integration/test_interface.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,6 @@ def test_create_folder_with_special_character(self):
251251
'Folder __abc (1) created in project Interface Pixel test',
252252
logs.output[4]
253253
)
254+
255+
def test_(self):
256+
sa.upload_annotations_from_folder_to_project("PROJECT_2", "/Users/vaghinak.basentsyan/www/for_fun/data")

0 commit comments

Comments
 (0)