Skip to content

Commit 9c12a71

Browse files
committed
using ids for identifying text and numeric attributes
1 parent cd2464f commit 9c12a71

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,13 +366,17 @@ def aggregate_image_annotations_as_df(self, annotations_paths: List[str]):
366366
class_name_to_color = {}
367367
class_group_name_to_values = {}
368368
rows = []
369-
369+
freestyle_attributes = set()
370370
for annotation_class in classes_json:
371371
name = annotation_class["name"]
372372
color = annotation_class["color"]
373373
class_name_to_color[name] = color
374374
class_group_name_to_values[name] = {}
375375
for attribute_group in annotation_class["attribute_groups"]:
376+
group_type = attribute_group.get("group_type")
377+
group_id = attribute_group.get("id")
378+
if group_type and group_type in ["text", "numeric"]:
379+
freestyle_attributes.add(group_id)
376380
class_group_name_to_values[name][attribute_group["name"]] = []
377381
for attribute in attribute_group["attributes"]:
378382
class_group_name_to_values[name][attribute_group["name"]].append(
@@ -443,6 +447,7 @@ def aggregate_image_annotations_as_df(self, annotations_paths: List[str]):
443447
for attribute in attributes:
444448
attribute_row = copy.copy(instance_row)
445449
attribute_group = attribute.get("groupName")
450+
group_id = attribute.get("groupId")
446451
attribute_name = attribute.get("name")
447452
if (
448453
attribute_group
@@ -452,20 +457,23 @@ def aggregate_image_annotations_as_df(self, annotations_paths: List[str]):
452457
"Annotation class group %s not in classes json. Skipping.",
453458
attribute_group,
454459
)
460+
print("asdasdasd")
455461
continue
456462
if (
457463
attribute_name
458464
not in class_group_name_to_values[annotation_class_name][
459465
attribute_group
460-
]
466+
] and group_id not in freestyle_attributes
461467
):
462468
logger.warning(
463469
f"Annotation class group value {attribute_name} not in classes json. Skipping."
464470
)
465471
continue
466472

467-
attribute_row.attributeGroupName = attribute_group,
468-
attribute_row.attributeName = attribute_name,
473+
else:
474+
attribute_row.attributeGroupName = attribute_group
475+
attribute_row.attributeName = attribute_name
476+
469477

470478
rows.append(attribute_row)
471479
num_added += 1

0 commit comments

Comments
 (0)