in challenge/2019_COCO_DensePose/densepose_cocoeval.py [0:0]
def evaluate(self, calc_mode='GPSm', tracking=True, UB_geo_iuvgt=False,
UB_geo_igt_uv0=False, UB_geo_igt=False, UB_geo_uv0=False, check_scores=False):
'''
Run per image evaluation on given images and store results (a list of dict) in self.evalImgs
:return: None
'''
self.UB_geo_iuvgt = UB_geo_iuvgt
self.UB_geo_igt_uv0 = UB_geo_igt_uv0
self.UB_geo_igt = UB_geo_igt
self.UB_geo_uv0 = UB_geo_uv0
# Options for calc_mode: GPS, GPSm, IOU
self.calc_mode = calc_mode
self.tracking = tracking
tic = time.time()
if check_scores:
print('Running per image *optimal score* evaluation for error analysis...')
else:
print('Running per image evaluation...')
self.do_gpsM = True #False
p = self.params
# add backward compatibility if useSegm is specified in params
if not p.useSegm is None:
p.iouType = 'segm' if p.useSegm == 1 else 'bbox'
print('useSegm (deprecated) is not None. Running {} evaluation'.format(p.iouType))
# raise exception if checking scores and not using keypoints
if check_scores and p.iouType != 'uv':
raise Exception('This function works only for *uv* eval.')
p.imgIds = list(np.unique(p.imgIds))
if p.useCats:
p.catIds = list(np.unique(p.catIds))
p.maxDets = sorted(p.maxDets)
self.params=p
self._prepare()
# loop through images, area range, max detection number
catIds = p.catIds if p.useCats else [-1]
if p.iouType in ['segm', 'bbox']:
computeIoU = self.computeIoU
elif p.iouType == 'keypoints':
computeIoU = self.computeOks
elif p.iouType == 'uv':
computeIoU = self.computeOgps
if self.do_gpsM:
self.real_ious = {(imgId, catId): self.computeDPIoU(imgId, catId) \
for imgId in p.imgIds
for catId in catIds}
self.ious = {(imgId, catId): computeIoU(imgId, catId) \
for imgId in p.imgIds
for catId in catIds}
evaluateImg = self.evaluateImg
maxDet = p.maxDets[-1]
self.evalImgs = [evaluateImg(imgId, catId, areaRng, maxDet, check_scores)
for catId in catIds
for areaRng in p.areaRng
for imgId in p.imgIds
]
self._paramsEval = copy.deepcopy(self.params)
toc = time.time()
print('DONE (t={:0.2f}s).'.format(toc-tic))