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

Method summarize

utils/test/pycocotools/cocoeval.py:376–426  ·  view source on GitHub ↗

Compute and display summary metrics for evaluation results. Note this functin can *only* be applied on the default parameter setting

(self)

Source from the content-addressed store, hash-verified

374 print 'DONE (t=%0.2fs).'%( toc-tic )
375
376 def summarize(self):
377 '''
378 Compute and display summary metrics for evaluation results.
379 Note this functin can *only* be applied on the default parameter setting
380 '''
381 def _summarize( ap=1, iouThr=None, areaRng='all', maxDets=100 ):
382 p = self.params
383 iStr = ' {:<18} {} @[ IoU={:<9} | area={:>6} | maxDets={:>3} ] = {}'
384 titleStr = 'Average Precision' if ap == 1 else 'Average Recall'
385 typeStr = '(AP)' if ap==1 else '(AR)'
386 iouStr = '%0.2f:%0.2f'%(p.iouThrs[0], p.iouThrs[-1]) if iouThr is None else '%0.2f'%(iouThr)
387 areaStr = areaRng
388 maxDetsStr = '%d'%(maxDets)
389
390 aind = [i for i, aRng in enumerate(['all', 'small', 'medium', 'large']) if aRng == areaRng]
391 mind = [i for i, mDet in enumerate([1, 10, 100]) if mDet == maxDets]
392 if ap == 1:
393 # dimension of precision: [TxRxKxAxM]
394 s = self.eval['precision']
395 # IoU
396 if iouThr is not None:
397 t = np.where(iouThr == p.iouThrs)[0]
398 s = s[t]
399 # areaRng
400 s = s[:,:,:,aind,mind]
401 else:
402 # dimension of recall: [TxKxAxM]
403 s = self.eval['recall']
404 s = s[:,:,aind,mind]
405 if len(s[s>-1])==0:
406 mean_s = -1
407 else:
408 mean_s = np.mean(s[s>-1])
409 print iStr.format(titleStr, typeStr, iouStr, areaStr, maxDetsStr, '%.3f'%(float(mean_s)))
410 return mean_s
411
412 if not self.eval:
413 raise Exception('Please run accumulate() first')
414 self.stats = np.zeros((12,))
415 self.stats[0] = _summarize(1)
416 self.stats[1] = _summarize(1,iouThr=.5)
417 self.stats[2] = _summarize(1,iouThr=.75)
418 self.stats[3] = _summarize(1,areaRng='small')
419 self.stats[4] = _summarize(1,areaRng='medium')
420 self.stats[5] = _summarize(1,areaRng='large')
421 self.stats[6] = _summarize(0,maxDets=1)
422 self.stats[7] = _summarize(0,maxDets=10)
423 self.stats[8] = _summarize(0,maxDets=100)
424 self.stats[9] = _summarize(0,areaRng='small')
425 self.stats[10] = _summarize(0,areaRng='medium')
426 self.stats[11] = _summarize(0,areaRng='large')
427
428 def __str__(self):
429 self.summarize()

Callers 2

__str__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected