|
@@ -135,13 +135,7 @@ def main():
|
|
mask = np.asfortranarray(mask.astype(np.uint8))
|
|
mask = np.asfortranarray(mask.astype(np.uint8))
|
|
mask = pycocotools.mask.encode(mask)
|
|
mask = pycocotools.mask.encode(mask)
|
|
area = float(pycocotools.mask.area(mask))
|
|
area = float(pycocotools.mask.area(mask))
|
|
-
|
|
|
|
- bbox = []
|
|
|
|
- for points in segmentations[label]:
|
|
|
|
- bbox.extend(points)
|
|
|
|
- bbox = np.asarray(bbox).reshape((-1, 2))
|
|
|
|
- xmin, ymin = np.amin(bbox, axis=0).tolist();
|
|
|
|
- xmax, ymax = np.amax(bbox, axis=0).tolist();
|
|
|
|
|
|
+ bbox = pycocotools.mask.toBbox(mask).flatten().tolist()
|
|
|
|
|
|
data['annotations'].append(dict(
|
|
data['annotations'].append(dict(
|
|
id=len(data['annotations']),
|
|
id=len(data['annotations']),
|
|
@@ -149,8 +143,8 @@ def main():
|
|
category_id=cls_id,
|
|
category_id=cls_id,
|
|
segmentation=segmentations[label],
|
|
segmentation=segmentations[label],
|
|
area=area,
|
|
area=area,
|
|
- bbox=[xmin, ymin, xmax - xmin, ymax - ymin],
|
|
|
|
- iscrowd=None,
|
|
|
|
|
|
+ bbox=bbox,
|
|
|
|
+ iscrowd=0,
|
|
))
|
|
))
|
|
|
|
|
|
with open(out_ann_file, 'w') as f:
|
|
with open(out_ann_file, 'w') as f:
|