未验证 提交 379b731a 编写于 作者: G Guanghua Yu 提交者: GitHub

fix record empty error in coco reader (#1960)

上级 6525296e
......@@ -146,6 +146,8 @@ class COCODataSet(DataSet):
'x1: {}, y1: {}, x2: {}, y2: {}.'.format(
img_id, x1, y1, x2, y2))
num_bbox = len(bboxes)
if num_bbox <= 0:
continue
gt_bbox = np.zeros((num_bbox, 4), dtype=np.float32)
gt_class = np.zeros((num_bbox, 1), dtype=np.int32)
......@@ -154,6 +156,7 @@ class COCODataSet(DataSet):
difficult = np.zeros((num_bbox, 1), dtype=np.int32)
gt_poly = [None] * num_bbox
has_segmentation = False
for i, box in enumerate(bboxes):
catid = box['category_id']
gt_class[i][0] = catid2clsid[catid]
......@@ -161,6 +164,10 @@ class COCODataSet(DataSet):
is_crowd[i][0] = box['iscrowd']
if 'segmentation' in box:
gt_poly[i] = box['segmentation']
has_segmentation = True
if has_segmentation and not any(gt_poly):
continue
coco_rec.update({
'is_crowd': is_crowd,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册