MCPcopy Create free account
hub / github.com/SooLab/CGFormer / getRefIds

Method getRefIds

tools/refer.py:140–171  ·  view source on GitHub ↗
(self, image_ids=[], cat_ids=[], ref_ids=[], split='')

Source from the content-addressed store, hash-verified

138 print('index created.')
139
140 def getRefIds(self, image_ids=[], cat_ids=[], ref_ids=[], split=''):
141 image_ids = image_ids if type(image_ids) == list else [image_ids]
142 cat_ids = cat_ids if type(cat_ids) == list else [cat_ids]
143 ref_ids = ref_ids if type(ref_ids) == list else [ref_ids]
144
145 if len(image_ids) == len(cat_ids) == len(ref_ids) == len(split) == 0:
146 refs = self.data['refs']
147 else:
148 if not len(image_ids) == 0:
149 refs = [self.imgToRefs[image_id] for image_id in image_ids]
150 else:
151 refs = self.data['refs']
152 if not len(cat_ids) == 0:
153 refs = [ref for ref in refs if ref['category_id'] in cat_ids]
154 if not len(ref_ids) == 0:
155 refs = [ref for ref in refs if ref['ref_id'] in ref_ids]
156 if not len(split) == 0:
157 if split in ['testA', 'testB', 'testC']:
158 refs = [ref for ref in refs if split[-1] in ref['split']
159 ] # we also consider testAB, testBC, ...
160 elif split in ['testAB', 'testBC', 'testAC']:
161 refs = [ref for ref in refs
162 if ref['split'] == split] # rarely used I guess...
163 elif split == 'test':
164 refs = [ref for ref in refs if 'test' in ref['split']]
165 elif split == 'train' or split == 'val':
166 refs = [ref for ref in refs if ref['split'] == split]
167 else:
168 print('No such split [%s]' % split)
169 sys.exit()
170 ref_ids = [ref['ref_id'] for ref in refs]
171 return ref_ids
172
173 def getAnnIds(self, image_ids=[], cat_ids=[], ref_ids=[]):
174 image_ids = image_ids if type(image_ids) == list else [image_ids]

Callers 3

data_process.pyFile · 0.80
prepare_datasetFunction · 0.80
refer.pyFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected