|
4 | 4 | import pandas as pd |
5 | 5 | import plotly.express as px |
6 | 6 | from lib.app.exceptions import AppException |
7 | | -from lib.core import DEPRICATED_DOCUMENT_VIDEO_MESSAGE |
8 | 7 | from superannotate.logger import get_default_logger |
9 | 8 |
|
10 | 9 |
|
@@ -44,14 +43,6 @@ def aggregate_image_annotations_as_df( |
44 | 43 | :rtype: pandas DataFrame |
45 | 44 | """ |
46 | 45 |
|
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 | | - |
55 | 46 | logger.info("Aggregating annotations from %s as pandas DataFrame", project_root) |
56 | 47 |
|
57 | 48 | annotation_data = { |
@@ -101,12 +92,15 @@ def aggregate_image_annotations_as_df( |
101 | 92 | classes_json = json.load(open(classes_path)) |
102 | 93 | class_name_to_color = {} |
103 | 94 | class_group_name_to_values = {} |
| 95 | + freestyle_attributes = set() |
104 | 96 | for annotation_class in classes_json: |
105 | 97 | name = annotation_class["name"] |
106 | 98 | color = annotation_class["color"] |
107 | 99 | class_name_to_color[name] = color |
108 | 100 | class_group_name_to_values[name] = {} |
109 | 101 | for attribute_group in annotation_class["attribute_groups"]: |
| 102 | + if attribute_group["group_type"] in ["text", "numeric"]: |
| 103 | + freestyle_attributes.add(attribute_group["name"]) |
110 | 104 | class_group_name_to_values[name][attribute_group["name"]] = [] |
111 | 105 | for attribute in attribute_group["attributes"]: |
112 | 106 | class_group_name_to_values[name][attribute_group["name"]].append( |
@@ -175,10 +169,14 @@ def __get_user_metadata(annotation): |
175 | 169 |
|
176 | 170 | if not annotations_paths: |
177 | 171 | 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: |
179 | 174 | type_postfix = "___objects.json" |
180 | | - else: |
| 175 | + elif "___pixel.json" in annotations_paths[0].name: |
181 | 176 | type_postfix = "___pixel.json" |
| 177 | + else: |
| 178 | + type_postfix = ".json" |
| 179 | + |
182 | 180 | for annotation_path in annotations_paths: |
183 | 181 | annotation_json = json.load(open(annotation_path)) |
184 | 182 | parts = annotation_path.name.split(type_postfix) |
@@ -294,6 +292,7 @@ def __get_user_metadata(annotation): |
294 | 292 | not in class_group_name_to_values[annotation_class_name][ |
295 | 293 | attribute_group |
296 | 294 | ] |
| 295 | + and attribute_group not in freestyle_attributes |
297 | 296 | ): |
298 | 297 | logger.warning( |
299 | 298 | "Annotation class group value %s not in classes json. Skipping.", |
|
0 commit comments