MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / __init__

Method __init__

PATH/core/data/datasets/images/pos_dataset_dev.py:29–59  ·  view source on GitHub ↗

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:

(self, annotation_file=None, test_index=None, ann_data=None)

Source from the content-addressed store, hash-verified

27
28class PetrelCOCO(COCO):
29 def __init__(self, annotation_file=None, test_index=None, ann_data=None):
30 """
31 Constructor of Microsoft COCO helper class for reading and visualizing annotations.
32 :param annotation_file (str): location of annotation file
33 :param image_folder (str): location to the folder that hosts images.
34 :return:
35 """
36 self.dataset,self.anns,self.cats,self.imgs = dict(),dict(),dict(),dict()
37 self.imgToAnns, self.catToImgs = defaultdict(list), defaultdict(list)
38 self.anno_file = [annotation_file]
39 self.test_index = test_index
40 if not annotation_file == None:
41 print('loading annotations into memory...')
42 tic = time.time()
43 # https://github.com/cocodataset/cocoapi/pull/453/
44 if ann_data == None:
45 dataset = PetrelHelper.load_json(annotation_file)
46 else:
47 dataset = ann_data
48 assert type(dataset)==dict, 'annotation file format {} not supported'.format(type(dataset))
49 print('Done (t={:0.2f}s)'.format(time.time()- tic))
50 self.dataset = dataset
51 self.createIndex()
52 if 'annotations' in self.dataset:
53 for i in range(len(self.dataset['annotations'])):
54 if self.test_index is not None:
55 keypoints = np.array(self.dataset['annotations'][i]['keypoints']).reshape([-1, 3])
56 keypoints = keypoints[self.test_index, :]
57 self.dataset['annotations'][i]['keypoints'] = keypoints.reshape([-1]).tolist()
58 if 'iscrowd' not in self.dataset['annotations'][i]:
59 self.dataset['annotations'][i]['iscrowd'] = False
60
61class COCOPosDatasetDev(Dataset):
62 def __init__(self,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected