Skip to content

Commit cca132b

Browse files
committed
Fix template names - coco convert
1 parent 599d5d6 commit cca132b

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

superannotate/input_converters/converters/coco_converters/coco_to_sa_vector.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ def coco_keypoint_detection_to_sa_vector(coco_path, output_dir):
171171
cat_id_to_cat[cat["id"]] = {
172172
"name": cat["name"],
173173
"keypoints": cat["keypoints"],
174-
"skeleton": cat["skeleton"]
174+
"skeleton": cat["skeleton"],
175+
"supercategory": cat["supercategory"]
175176
}
176177

177178
image_id_to_annotations = {}
@@ -239,8 +240,12 @@ def coco_keypoint_detection_to_sa_vector(coco_path, output_dir):
239240
pointLabels[id_mapping[kp_index + 1] - 1] = kp_name
240241

241242
sa_obj = _create_vector_instance(
242-
'template', points, pointLabels, [],
243-
cat_id_to_cat[annot["category_id"]]["name"], connections
243+
'template',
244+
points,
245+
pointLabels, [],
246+
cat_id_to_cat[annot["category_id"]]["supercategory"],
247+
connections,
248+
template_name=cat_id_to_cat[annot["category_id"]]["name"]
244249
)
245250
if str(annot['image_id']) not in image_id_to_annotations:
246251
image_id_to_annotations[str(annot['image_id'])] = [sa_obj]

superannotate/input_converters/converters/sa_json_helper.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ def _create_vector_instance(
88
pointLabels,
99
attributes,
1010
class_name='',
11-
connections=[]
11+
connections=[],
12+
template_name=''
1213
):
1314
sa_instance = {
1415
'type': instance_type,
@@ -20,6 +21,8 @@ def _create_vector_instance(
2021
if instance_type == 'template':
2122
sa_instance['points'] = points
2223
sa_instance['connections'] = connections
24+
sa_instance['className'] = class_name
25+
sa_instance['templateName'] = template_name
2326
elif instance_type == 'point':
2427
sa_instance['x'] = points[0]
2528
sa_instance['y'] = points[1]

0 commit comments

Comments
 (0)