瀏覽代碼

Fix segmentation generation for rectangles

Shannon 5 年之前
父節點
當前提交
ecf6362a37
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5 0
      examples/instance_segmentation/labelme2coco.py

+ 5 - 0
examples/instance_segmentation/labelme2coco.py

@@ -126,6 +126,11 @@ def main():
                 masks[instance] = mask
 
             points = np.asarray(points).flatten().tolist()
+            
+            if shape['shape_type'] == 'rectangle':
+                x_1, y_1, x_2, y_2 = points
+                points = [x_1, y_1, x_2, y_1, x_2, y_2, x_1, y_2]
+            
             segmentations[instance].append(points)
         segmentations = dict(segmentations)