使用自己制作的数据集和转换好的coco格式json文件训练时报错:
image_info = self.coco.loadImgs(self.image_ids[image_index])[0]
File “/home/cendelian/anaconda3/envs/tf/lib/python3.6/site-packages/pycocotools/coco.py”, line 229, in loadImgs
return [self.imgs[id] for id in ids]
File “/home/cendelian/anaconda3/envs/tf/lib/python3.6/site-packages/pycocotools/coco.py”, line 229, in
return [self.imgs[id] for id in ids]
KeyError: '2’

后面查找是因为我转换的json文件中的image_id‘str’类型而不是‘int’类型,将其修改为‘int’类型即可解决。

json文件中annotation字段必须是如下格式:

annotation{
    "id": int,    
    "image_id": int,
    "category_id": int,
    "segmentation": RLE or [polygon],
    "area": float,
    "bbox": [x,y,width,height],
    "iscrowd": 0 or 1,
}

相关问题可参考如下两个github问题链接:
https://github.com/dbolya/yolact/issues/156
https://github.com/zylo117/Yet-Another-EfficientDet-Pytorch/issues/60

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐