COCO数据集的测试

参考博文https://blog.csdn.net/qq_30159015/article/details/83507371
(一) COCO Python API - 使用篇

import os
import sys
import cv2
import numpy as np
 
 
# Download and install the Python COCO tools from https://github.com/waleedka/coco
# That's a fork from the original https://github.com/pdollar/coco with a bug
# fix for Python 3.
# If the PR is merged then use the original repo.
# Note: Edit PythonAPI/Makefile and replace "python" with "python3".
from pycocotools.coco import COCO
from pycocotools.cocoeval import COCOeval
from pycocotools import mask as maskUtils
 
from skimage import io
from matplotlib import pyplot as plt

# Root directory of the project
ROOT_DIR = os.path.abspath("../../")
 
# Import Mask RCNN
sys.path.append(ROOT_DIR)  # To find local version of the library
dataset_dir = "e:/coco"
subset = "train"
year = "2014"
#annFile="{}/annotations/instances_{}{}.json".format(dataset_dir, subset, year)
#annFile="e:/coco/annotations/instances_train2014.json"
#coco=COCO(annFile)
coco=COCO("e:/coco/annotations/instances_train2014.json")
#坑,COPY代码不成功,手动输入代码后成功

输出结果:
loading annotations into memory…
Done (t=19.20s)
creating index…
index created!

你可能感兴趣的:(coco)