Skip to content

Commit 910d511

Browse files
committed
Updated image coco export
1 parent 5f12784 commit 910d511

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

app/util/coco_util.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff 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']

0 commit comments

Comments
 (0)