Skip to content

Commit 305f87d

Browse files
authored
Merge pull request #534 from superannotateai/1510_objects_json
fixing __objects.json and freestyle attributes
2 parents 897865f + 7f7826a commit 305f87d

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import pandas as pd
55
import plotly.express as px
66
from lib.app.exceptions import AppException
7-
from lib.core import DEPRICATED_DOCUMENT_VIDEO_MESSAGE
87
from superannotate.logger import get_default_logger
98

109

@@ -44,14 +43,6 @@ def aggregate_image_annotations_as_df(
4443
:rtype: pandas DataFrame
4544
"""
4645

47-
json_paths = list(Path(str(project_root)).glob("*.json"))
48-
if (
49-
json_paths
50-
and "___pixel.json" not in json_paths[0].name
51-
and "___objects.json" not in json_paths[0].name
52-
):
53-
raise AppException(DEPRICATED_DOCUMENT_VIDEO_MESSAGE)
54-
5546
logger.info("Aggregating annotations from %s as pandas DataFrame", project_root)
5647

5748
annotation_data = {
@@ -101,12 +92,15 @@ def aggregate_image_annotations_as_df(
10192
classes_json = json.load(open(classes_path))
10293
class_name_to_color = {}
10394
class_group_name_to_values = {}
95+
freestyle_attributes = set()
10496
for annotation_class in classes_json:
10597
name = annotation_class["name"]
10698
color = annotation_class["color"]
10799
class_name_to_color[name] = color
108100
class_group_name_to_values[name] = {}
109101
for attribute_group in annotation_class["attribute_groups"]:
102+
if attribute_group["group_type"] in ["text", "numeric"]:
103+
freestyle_attributes.add(attribute_group["name"])
110104
class_group_name_to_values[name][attribute_group["name"]] = []
111105
for attribute in attribute_group["attributes"]:
112106
class_group_name_to_values[name][attribute_group["name"]].append(
@@ -175,10 +169,14 @@ def __get_user_metadata(annotation):
175169

176170
if not annotations_paths:
177171
logger.warning(f"Could not find annotations in {project_root}.")
178-
if len(list(Path(project_root).rglob("*___objects.json"))) > 0:
172+
173+
if "___objects.json" in annotations_paths[0].name:
179174
type_postfix = "___objects.json"
180-
else:
175+
elif "___pixel.json" in annotations_paths[0].name:
181176
type_postfix = "___pixel.json"
177+
else:
178+
type_postfix = ".json"
179+
182180
for annotation_path in annotations_paths:
183181
annotation_json = json.load(open(annotation_path))
184182
parts = annotation_path.name.split(type_postfix)
@@ -294,6 +292,7 @@ def __get_user_metadata(annotation):
294292
not in class_group_name_to_values[annotation_class_name][
295293
attribute_group
296294
]
295+
and attribute_group not in freestyle_attributes
297296
):
298297
logger.warning(
299298
"Annotation class group value %s not in classes json. Skipping.",

0 commit comments

Comments
 (0)