44import pandas as pd
55import plotly .express as px
66from lib .app .exceptions import AppException
7- from lib .core import DEPRICATED_DOCUMENT_VIDEO_MESSAGE
87from 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,16 @@ 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+ group_type = attribute_group .get ("group_type" )
103+ if group_type and group_type in ["text" , "numeric" ]:
104+ freestyle_attributes .add (attribute_group ["name" ])
110105 class_group_name_to_values [name ][attribute_group ["name" ]] = []
111106 for attribute in attribute_group ["attributes" ]:
112107 class_group_name_to_values [name ][attribute_group ["name" ]].append (
@@ -175,10 +170,14 @@ def __get_user_metadata(annotation):
175170
176171 if not annotations_paths :
177172 logger .warning (f"Could not find annotations in { project_root } ." )
178- if len (list (Path (project_root ).rglob ("*___objects.json" ))) > 0 :
173+
174+ if "___objects.json" in annotations_paths [0 ].name :
179175 type_postfix = "___objects.json"
180- else :
176+ elif "___pixel.json" in annotations_paths [ 0 ]. name :
181177 type_postfix = "___pixel.json"
178+ else :
179+ type_postfix = ".json"
180+
182181 for annotation_path in annotations_paths :
183182 annotation_json = json .load (open (annotation_path ))
184183 parts = annotation_path .name .split (type_postfix )
@@ -294,6 +293,7 @@ def __get_user_metadata(annotation):
294293 not in class_group_name_to_values [annotation_class_name ][
295294 attribute_group
296295 ]
296+ and attribute_group not in freestyle_attributes
297297 ):
298298 logger .warning (
299299 "Annotation class group value %s not in classes json. Skipping." ,
@@ -383,9 +383,9 @@ def instance_consensus(inst_1, inst_2):
383383
384384 :param inst_1: First instance for consensus score.
385385 :type inst_1: shapely object
386+
386387 :param inst_2: Second instance for consensus score.
387388 :type inst_2: shapely object
388-
389389 """
390390 if inst_1 .type == inst_2 .type == "Polygon" :
391391 intersect = inst_1 .intersection (inst_2 )
@@ -404,19 +404,19 @@ def image_consensus(df, image_name, annot_type):
404404
405405 :param df: Annotation data of all images
406406 :type df: pandas.DataFrame
407+
407408 :param image_name: The image name for which the consensus score will be computed
408409 :type image_name: str
410+
409411 :param annot_type: Type of annotation instances to consider. Available candidates are: ["bbox", "polygon", "point"]
410412 :type dataset_format: str
411-
412413 """
413414
414415 try :
415416 from shapely .geometry import Point , Polygon , box
416417 except ImportError :
417418 raise ImportError (
418- "To use superannotate.benchmark or superannotate.consensus functions please install "
419- "shapely package in Anaconda enviornment with # conda install shapely"
419+ "To use superannotate.benchmark or superannotate.consensus functions please install shapely package."
420420 )
421421
422422 image_df = df [df ["imageName" ] == image_name ]
0 commit comments