Last active
October 8, 2021 16:34
-
-
Save eminorhan/123e920cee96a0f384146024446a4c1f to your computer and use it in GitHub Desktop.
COCO-API cheat sheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pycocotools.coco import COCO | |
import numpy as np | |
dataDir = '/home/emin/coco' | |
dataType = 'val2017' | |
annFile = '{}/annotations/instances_{}.json'.format(dataDir, dataType) | |
coco = COCO(annFile) # build COCO object | |
catIds = coco.getCatIds() # category ids (80) | |
imgIds = coco.getImgIds() # image ids (5000 for val2017) | |
annIds = coco.getAnnIds() # annotation ids (36781 for val2017) | |
sorted_imgIds = np.sort(imgIds) # sort image ids so they match the order in binary target matrix |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment