perform evaluation for single category and image :return: dict (single image results)
(self, imgId, aRng, maxDet)
| 229 | return ious |
| 230 | |
| 231 | def evaluateImg(self, imgId, aRng, maxDet): |
| 232 | ''' |
| 233 | perform evaluation for single category and image |
| 234 | :return: dict (single image results) |
| 235 | ''' |
| 236 | p = self.params |
| 237 | if p.useCats: |
| 238 | gt = self._gts[imgId] |
| 239 | dt = self._dts[imgId] |
| 240 | else: |
| 241 | gt = [_ for _ in self._gts[imgId]] |
| 242 | dt = [_ for _ in self._dts[imgId]] |
| 243 | if len(gt) == 0 and len(dt) ==0: |
| 244 | return None |
| 245 | # print(dt, "GTTTT") |
| 246 | for g in gt: |
| 247 | if g['ignore'] or (g['area']<aRng[0] or g['area']>aRng[1]): |
| 248 | g['_ignore'] = 1 |
| 249 | else: |
| 250 | g['_ignore'] = 0 |
| 251 | |
| 252 | # sort dt highest score first, sort gt ignore last |
| 253 | gtind = np.argsort([g['_ignore'] for g in gt], kind='mergesort') |
| 254 | gt = [gt[i] for i in gtind] |
| 255 | dtind = np.argsort([-d['score'] for d in dt], kind='mergesort') |
| 256 | dt = [dt[i] for i in dtind[0:maxDet]] |
| 257 | iscrowd = [int(o['iscrowd']) for o in gt] |
| 258 | # load computed ious |
| 259 | ious = self.ious[imgId][:, gtind] if len(self.ious[imgId]) > 0 else self.ious[imgId] |
| 260 | |
| 261 | T = len(p.iouThrs) |
| 262 | G = len(gt) |
| 263 | D = len(dt) |
| 264 | gtm = np.zeros((T,G)) |
| 265 | dtm = np.zeros((T,D)) |
| 266 | gtIg = np.array([g['_ignore'] for g in gt]) |
| 267 | dtIg = np.zeros((T,D)) |
| 268 | if not len(ious)==0: |
| 269 | for tind, t in enumerate(p.iouThrs): |
| 270 | for dind, d in enumerate(dt): |
| 271 | # information about best match so far (m=-1 -> unmatched) |
| 272 | iou = min([t,1-1e-10]) |
| 273 | m = -1 |
| 274 | for gind, g in enumerate(gt): |
| 275 | # if this gt already matched, and not a crowd, continue |
| 276 | if gtm[tind,gind]>0 and not iscrowd[gind]: |
| 277 | continue |
| 278 | # if dt matched to reg gt, and on ignore gt, stop |
| 279 | if m>-1 and gtIg[m]==0 and gtIg[gind]==1: |
| 280 | break |
| 281 | # continue to next gt unless better match made |
| 282 | if ious[dind,gind] < iou: |
| 283 | continue |
| 284 | # if match successful and best so far, store appropriately |
| 285 | iou=ious[dind,gind] |
| 286 | m=gind |
| 287 | # if match made store id of match for both dt and gt |
| 288 | if m ==-1: |
nothing calls this directly
no outgoing calls
no test coverage detected