Ejemplo n.º 1
0
def validate(annFile, dt_path):
    mean_MR = []
    for id_setup in range(0, 4):
        cocoGt = COCO(annFile)
        cocoDt = cocoGt.loadRes(dt_path)
        imgIds = sorted(cocoGt.getImgIds())
        cocoEval = COCOeval(cocoGt, cocoDt, 'bbox')
        cocoEval.params.imgIds = imgIds
        cocoEval.evaluate(id_setup)
        cocoEval.accumulate()
        mean_MR.append(cocoEval.summarize_nofile(id_setup))
    return mean_MR
Ejemplo n.º 2
0
def eval_json_reasonable(annFile, resFile, annType='bbox'):
    dt_path = os.path.split(resFile)[0]
    respath = os.path.join(dt_path, 'results.txt')
    res_file = open(respath, "w")
    mr_reasonable = None
    for id_setup in range(6):
        cocoGt = COCO(annFile)
        cocoDt = cocoGt.loadRes(resFile)
        imgIds = sorted(cocoGt.getImgIds())
        cocoEval = COCOeval(cocoGt, cocoDt, annType)
        cocoEval.params.imgIds = imgIds
        cocoEval.evaluate(id_setup)
        cocoEval.accumulate()
        mean_mr = cocoEval.summarize(id_setup, res_file)
        if id_setup == 0:
            mr_reasonable = mean_mr
    print('')
    res_file.close()
    return mr_reasonable
Ejemplo n.º 3
0
    if C.offset:
        boxes = bbox_process.parse_det_offset(Y, C, score=0.1, down=4)
    else:
        boxes = bbox_process.parse_det(Y, C, score=0.1, down=4, scale=C.scale)
    if len(boxes) > 0:
        f_res = np.repeat(f + 1, len(boxes), axis=0).reshape((-1, 1))
        boxes[:, [2, 3]] -= boxes[:, [0, 1]]
        res_all += np.concatenate((f_res, boxes), axis=-1).tolist()
np.savetxt(res_file_txt, np.array(res_all), fmt='%6f')
print(time.time() - start_time)

dt_path = res_path
json_path = convert_file(res_file_txt)

annFile_test = '/home/vobecant/PhD/CSP/eval_city/val_gt.json'
resFile = os.path.join(dt_path, 'val_dt.json')
respath = os.path.join(dt_path, 'results_testSet.txt')
res_file = open(respath, "w")
print('\nResults on the TEST set:')
for id_setup in range(6):
    print('setup {}'.format(id_setup))
    cocoGt = COCO(annFile_test)
    cocoDt = cocoGt.loadRes(resFile)
    imgIds = sorted(cocoGt.getImgIds())
    cocoEval = COCOeval(cocoGt, cocoDt, 'bbox')
    cocoEval.params.imgIds = imgIds
    cocoEval.evaluate(id_setup)
    cocoEval.accumulate()
    cocoEval.summarize(id_setup, res_file)