Skip to content

Commit 6f8df8c

Browse files
committed
optimize
1 parent 0d357c2 commit 6f8df8c

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

superannotate/db/annotation_classes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,9 @@ def fill_class_and_attribute_names(annotations_json, annotation_classes_dict):
330330
def fill_class_and_attribute_ids(annotation_json, annotation_classes_dict):
331331
if "instances" not in annotation_json:
332332
return
333+
333334
unknown_classes = {}
334-
for ann in annotation_json["instances"]:
335+
for ann in [i for i in annotation_json["instances"] if "className" in i]:
335336
if "className" not in ann:
336337
continue
337338
annotation_class_name = ann["className"]
@@ -342,8 +343,7 @@ def fill_class_and_attribute_ids(annotation_json, annotation_classes_dict):
342343
'id': class_num,
343344
'attribute_groups': {}
344345
}
345-
for k in unknown_classes:
346-
annotation_classes_dict[k] = unknown_classes[k]
346+
annotation_classes_dict = {**annotation_classes_dict, **unknown_classes}
347347

348348
for ann in annotation_json["instances"]:
349349
if "className" not in ann:

tests/converter_test/test_conversion.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ def test_instance_segmentation_sa2coco_vector_empty_array(tmpdir):
105105
truth_path = input_dir / "truth.json"
106106
with open(truth_path, 'r') as f:
107107
truth = json.loads(f.read())
108-
assert truth['annotations'][0]['bbox'] == data['annotations'][0]['bbox']
108+
data['info']['date_created'] = 0
109+
truth['info']['date_created'] = 0
110+
assert truth == data
109111

110112

111113
def test_instance_segmentation_sa2coco_vector_empty_name(tmpdir):

0 commit comments

Comments
 (0)