COCO dataset: get different image id with 2 approaches

Viewed 665
from pycocotools.coco import COCO

dataType='train2017'
annFile='./data/coco/annotations/instances_{}.json'.format(dataType)
coco=COCO(annFile)

img_ids_0 = coco.getImgIds(catIds=[])
img_ids_1 = coco.imgToAnns.keys()

print("img_ids_0: {}".format(len(img_ids_0)))
print("img_ids_1: {}".format(len(img_ids_1)))

Running the code above, I got

img_ids_0: 118287
img_ids_1: 117266

Why are they different? Which is correct?

0 Answers
Related