OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.5 KiB
47 lines
1.5 KiB
# Copyright (c) OpenMMLab. All rights reserved. |
|
# This file add snake case alias for coco api |
|
|
|
import warnings |
|
|
|
import pycocotools |
|
from pycocotools.coco import COCO as _COCO |
|
from pycocotools.cocoeval import COCOeval as _COCOeval |
|
|
|
|
|
class COCO(_COCO): |
|
"""This class is almost the same as official pycocotools package. |
|
|
|
It implements some snake case function aliases. So that the COCO class has |
|
the same interface as LVIS class. |
|
""" |
|
|
|
def __init__(self, annotation_file=None): |
|
if getattr(pycocotools, '__version__', '0') >= '12.0.2': |
|
warnings.warn( |
|
'mmpycocotools is deprecated. Please install official pycocotools by "pip install pycocotools"', # noqa: E501 |
|
UserWarning) |
|
super().__init__(annotation_file=annotation_file) |
|
self.img_ann_map = self.imgToAnns |
|
self.cat_img_map = self.catToImgs |
|
|
|
def get_ann_ids(self, img_ids=[], cat_ids=[], area_rng=[], iscrowd=None): |
|
return self.getAnnIds(img_ids, cat_ids, area_rng, iscrowd) |
|
|
|
def get_cat_ids(self, cat_names=[], sup_names=[], cat_ids=[]): |
|
return self.getCatIds(cat_names, sup_names, cat_ids) |
|
|
|
def get_img_ids(self, img_ids=[], cat_ids=[]): |
|
return self.getImgIds(img_ids, cat_ids) |
|
|
|
def load_anns(self, ids): |
|
return self.loadAnns(ids) |
|
|
|
def load_cats(self, ids): |
|
return self.loadCats(ids) |
|
|
|
def load_imgs(self, ids): |
|
return self.loadImgs(ids) |
|
|
|
|
|
# just for the ease of import |
|
COCOeval = _COCOeval
|
|
|