MCPcopy Create free account
hub / github.com/Tencent/ObjectDetection-OneStageDet / createIndex

Method createIndex

utils/test/pycocotools/coco.py:84–120  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

82 self.createIndex()
83
84 def createIndex(self):
85 # create index
86 print 'creating index...'
87 anns = {}
88 imgToAnns = {}
89 catToImgs = {}
90 cats = {}
91 imgs = {}
92 if 'annotations' in self.dataset:
93 imgToAnns = {ann['image_id']: [] for ann in self.dataset['annotations']}
94 anns = {ann['id']: [] for ann in self.dataset['annotations']}
95 for ann in self.dataset['annotations']:
96 imgToAnns[ann['image_id']] += [ann]
97 anns[ann['id']] = ann
98
99 if 'images' in self.dataset:
100 imgs = {im['id']: {} for im in self.dataset['images']}
101 for img in self.dataset['images']:
102 imgs[img['id']] = img
103
104 if 'categories' in self.dataset:
105 cats = {cat['id']: [] for cat in self.dataset['categories']}
106 for cat in self.dataset['categories']:
107 cats[cat['id']] = cat
108 catToImgs = {cat['id']: [] for cat in self.dataset['categories']}
109 if 'annotations' in self.dataset:
110 for ann in self.dataset['annotations']:
111 catToImgs[ann['category_id']] += [ann['image_id']]
112
113 print 'index created!'
114
115 # create class members
116 self.anns = anns
117 self.imgToAnns = imgToAnns
118 self.catToImgs = catToImgs
119 self.imgs = imgs
120 self.cats = cats
121
122 def info(self):
123 """

Callers 2

__init__Method · 0.95
loadResMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected