(self, annotation_file=None)
Constructor of Microsoft COCO helper class for reading and visualizing annotations.
        :param annotation_file (str): location of annotation file
        :param image_folder (str): location to the folder that hosts images.
        :return:
Constructor of Microsoft COCO helper class for reading and visualizing annotations.
        :param annotation_file (str): location of annotation file
        :param image_folder (str): location to the folder that hosts images.
        :return:
Constructor of Microsoft COCO helper class for reading and visualizing annotations . : param annotation_file ( str ) : location of annotation file : param image_folder ( str ) : location to the folder that hosts images . : return :
def __init__(self, annotation_file=None):
        """
        Constructor of Microsoft COCO helper class for reading and visualizing annotations.
        :param annotation_file (str): location of annotation file
        :param image_folder (str): location to the folder that hosts images.
        :return:
        """
        # load dataset
        self.dataset,self.anns,self.cats,self.imgs = dict(),dict(),dict(),dict()
        self.imgToAnns, self.catToImgs = defaultdict(list), defaultdict(list)
        if not annotation_file == None:
            # print('loading annotations into memory...')
            tic = time.time()
            dataset = json.load(open(annotation_file, 'r'))
            assert type(dataset)==dict, 'annotation file format {} not supported'.format(type(dataset))
            # print('Done (t={:0.2f}s)'.format(time.time()- tic))
            self.dataset = dataset
            self.createIndex()
def __init__ ( self , annotation_file = None ) : # load dataset self . dataset , self . anns , self . cats , self . imgs = dict ( ) , dict ( ) , dict ( ) , dict ( ) self . imgToAnns , self . catToImgs = defaultdict ( list ) , defaultdict ( list ) if not annotation_file == None : # print('loading annotations into memory...') tic = time . time ( ) dataset = json . load ( open ( annotation_file , 'r' ) ) assert type ( dataset ) == dict , 'annotation file format {} not supported' . format ( type ( dataset ) ) # print('Done (t={:0.2f}s)'.format(time.time()- tic)) self . dataset = dataset self . createIndex ( )