File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -122,13 +122,13 @@ def get_image_coco(image):
122122 if len (category_annotations ) == 0 :
123123 continue
124124
125- has_keypoints = len (category .keypoint_labels ) > 0
126-
127125 for annotation in category_annotations :
128126 annotation = fix_ids (annotation )
129127
130- if len (annotation .get ('segmentation' , [])) != 0 or \
131- len (annotation .get ('keypoints' , [])) != 0 :
128+ has_segmentation = len (annotation .get ('segmentation' , [])) > 0
129+ has_keypoints = len (annotation .get ('keypoints' , [])) > 0
130+
131+ if has_segmentation or has_keypoints :
132132 del annotation ['deleted' ]
133133
134134 if not has_keypoints :
@@ -142,12 +142,14 @@ def get_image_coco(image):
142142
143143 category = fix_ids (category )
144144 del category ['deleted' ]
145- if has_keypoints :
145+
146+ if len (category .get ('keypoint_labels' )) > 0 :
146147 category ['keypoints' ] = category .pop ('keypoint_labels' )
147148 category ['skeleton' ] = category .pop ('keypoint_edges' )
148149 else :
149150 del category ['keypoint_edges' ]
150151 del category ['keypoint_labels' ]
152+
151153 categories .append (category )
152154
153155 del image ['deleted' ]
You can’t perform that action at this time.
0 commit comments