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

Method getAnnIds

tools/refer.py:173–195  ·  view source on GitHub ↗
(self, image_ids=[], cat_ids=[], ref_ids=[])

Source from the content-addressed store, hash-verified

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]
175 cat_ids = cat_ids if type(cat_ids) == list else [cat_ids]
176 ref_ids = ref_ids if type(ref_ids) == list else [ref_ids]
177
178 if len(image_ids) == len(cat_ids) == len(ref_ids) == 0:
179 ann_ids = [ann['id'] for ann in self.data['annotations']]
180 else:
181 if not len(image_ids) == 0:
182 lists = [
183 self.imgToAnns[image_id] for image_id in image_ids
184 if image_id in self.imgToAnns
185 ] # list of [anns]
186 anns = list(itertools.chain.from_iterable(lists))
187 else:
188 anns = self.data['annotations']
189 if not len(cat_ids) == 0:
190 anns = [ann for ann in anns if ann['category_id'] in cat_ids]
191 ann_ids = [ann['id'] for ann in anns]
192 if not len(ref_ids) == 0:
193 ids = set(ann_ids).intersection(
194 set([self.Refs[ref_id]['ann_id'] for ref_id in ref_ids]))
195 return ann_ids
196
197 def getImgIds(self, ref_ids=[]):
198 ref_ids = ref_ids if type(ref_ids) == list else [ref_ids]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected