未验证 提交 e5605dd8 编写于 作者: W wangxinxin08 提交者: GitHub

fix the problem of converting labelme to coco (#1296)

上级 d98fb5d4
...@@ -154,17 +154,19 @@ def deal_json(ds_type, img_path, json_path): ...@@ -154,17 +154,19 @@ def deal_json(ds_type, img_path, json_path):
categories_list.append(categories(label, labels_list)) categories_list.append(categories(label, labels_list))
labels_list.append(label) labels_list.append(label)
label_to_num[label] = len(labels_list) label_to_num[label] = len(labels_list)
points = shapes['points']
p_type = shapes['shape_type'] p_type = shapes['shape_type']
if p_type == 'polygon': if p_type == 'polygon':
points = shapes['points']
annotations_list.append( annotations_list.append(
annotations_polygon(data['imageHeight'], data[ annotations_polygon(data['imageHeight'], data[
'imageWidth'], points, label, image_num, 'imageWidth'], points, label, image_num,
object_num, label_to_num)) object_num, label_to_num))
if p_type == 'rectangle': if p_type == 'rectangle':
points.append([points[0][0], points[1][1]]) (x1, y1), (x2, y2) = shapes['points']
points.append([points[1][0], points[0][1]]) x1, x2 = sorted([x1, x2])
y1, y2 = sorted([y1, y2])
points = [[x1, y1], [x2, y2], [x1, y2], [x2, y1]]
annotations_list.append( annotations_list.append(
annotations_rectangle(points, label, image_num, annotations_rectangle(points, label, image_num,
object_num, label_to_num)) object_num, label_to_num))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册