99
1010def df_to_annotations (df , output_dir ):
1111 """Converts and saves pandas DataFrame annotation info (see aggregate_annotations_as_df) in output_dir
12- The DataFrame should have columns: "imageName", "classNmae ", "attributeGroupName", "attributeName", "type", "error", "locked", "visible", trackingId", "probability", "pointLabels", "meta", "commentResolved", "classColor", "groupId"
12+ The DataFrame should have columns: "imageName", "className ", "attributeGroupName", "attributeName", "type", "error", "locked", "visible", trackingId", "probability", "pointLabels", "meta", "commentResolved", "classColor", "groupId"
1313
1414 Currently only works for Vector projects.
1515
@@ -120,6 +120,7 @@ def aggregate_annotations_as_df(
120120 project_root ,
121121 include_classes_wo_annotations = False ,
122122 include_comments = False ,
123+ include_tags = False ,
123124 verbose = True
124125):
125126 """Aggregate annotations as pandas dataframe from project root.
@@ -154,7 +155,6 @@ def aggregate_annotations_as_df(
154155 "error" : [],
155156 "locked" : [],
156157 "visible" : [],
157- "tag" : [],
158158 "trackingId" : [],
159159 "probability" : [],
160160 "pointLabels" : [],
@@ -172,6 +172,8 @@ def aggregate_annotations_as_df(
172172
173173 if include_comments :
174174 annotation_data ["commentResolved" ] = []
175+ if include_tags :
176+ annotation_data ["tag" ] = []
175177
176178 classes_path = Path (project_root ) / "classes" / "classes.json"
177179 if not classes_path .is_file ():
@@ -245,13 +247,14 @@ def __get_image_metadata(image_name, annotations):
245247 __append_annotation (annotation_dict )
246248 continue
247249 if annotation_type == "tag" :
248- annotation_tag = annotation ["name" ]
249- annotation_dict = {
250- "type" : annotation_type ,
251- "tag" : annotation_tag
252- }
253- annotation_dict .update (image_metadata )
254- __append_annotation (annotation_dict )
250+ if include_tags :
251+ annotation_tag = annotation ["name" ]
252+ annotation_dict = {
253+ "type" : annotation_type ,
254+ "tag" : annotation_tag
255+ }
256+ annotation_dict .update (image_metadata )
257+ __append_annotation (annotation_dict )
255258 continue
256259 annotation_instance_id += 1
257260 annotation_class_name = annotation .get ("className" )
0 commit comments