def evaluate(label_path, result_path, save_path, current_class=['Car', 'Pedestrian', 'Cyclist'], coco=False, score_thresh=-1): class_to_name = {0: 'Car', 1: 'Pedestrian', 2: 'Cyclist', 3: 'DontCare'} gt_annos = kitti.get_label_annos(label_path) dt_annos = kitti.get_label_annos(result_path) # visualize(gt_annos, dt_annos) print(len(dt_annos)) if score_thresh > 0: dt_annos = kitti.filter_annos_low_score(dt_annos, score_thresh) if coco: print(get_coco_eval_result(dt_annos, dt_annos, current_class)) else: result_str, _ = get_official_eval_result(gt_annos, dt_annos, current_class, class_to_name) print(result_str) with open(save_path, 'w+') as f: f.write("\n") f.write(result_str)
def evaluate(label_path, result_path, current_class=0, coco=False, score_thresh=-1, eval_dist=None): dt_annos, image_ids = kitti.get_label_annos(result_path, return_image_ids=True, eval_dist=eval_dist) print('Eval {} images'.format(len(dt_annos))) if score_thresh > 0: dt_annos = kitti.filter_annos_low_score(dt_annos, score_thresh) #val_image_ids = _read_imageset_file(label_split_file) gt_annos = kitti.get_label_annos(label_path, image_ids, eval_dist=eval_dist) # Playground # print(gt_annos[48].keys()) #print(gt_annos[48]["name"]) #print(gt_annos[48]["dimensions"]) #print(gt_annos[48]["location"]) ## Playground end if coco: print(get_coco_eval_result(gt_annos, dt_annos, current_class)) else: print(get_official_eval_result(gt_annos, dt_annos, current_class))
def show_result(gt_annos, pd_annos, obj_type=[0]): # obj_type [0] == Car result_kitti = get_official_eval_result(gt_annos, pd_annos, obj_type) print(result_kitti) result_coco = get_coco_eval_result(gt_annos, pd_annos, obj_type) print(result_coco)
def evaluate(label_path, result_path, current_class=0, coco=False, score_thresh=-1, eval_dist=None): dt_annos, image_ids = kitti.get_label_annos(result_path, return_image_ids=True, eval_dist=eval_dist) print('Eval {} images'.format(len(dt_annos))) if score_thresh > 0: dt_annos = kitti.filter_annos_low_score(dt_annos, score_thresh) #val_image_ids = _read_imageset_file(label_split_file) gt_annos = kitti.get_label_annos(label_path, image_ids, eval_dist=eval_dist) if coco: print(get_coco_eval_result(gt_annos, dt_annos, current_class)) else: print(get_official_eval_result(gt_annos, dt_annos, current_class))
def evaluate(label_path, result_path, label_split_file, current_class=0, coco=False, score_thresh=-1): dt_annos = kitti.get_label_annos(result_path) if score_thresh > 0: dt_annos = kitti.filter_annos_low_score(dt_annos, score_thresh) val_image_ids = _read_imageset_file(label_split_file) val_image_ids = exists(val_image_ids, result_path) gt_annos = kitti.get_label_annos(label_path, val_image_ids) dt_annos = kitti.get_label_annos(result_path, val_image_ids) if coco: print(get_coco_eval_result(gt_annos, dt_annos, current_class)) else: print(get_official_eval_result(gt_annos, dt_annos, current_class))
import kitti_common as kitti import json from eval import get_official_eval_result, get_coco_eval_result def _read_imageset_file(path): with open(path, 'r') as f: lines = f.readlines() return [line[:-1] for line in lines] gt_split_file = "/mnt/nfs/scratch1/pmallya/nusc_kitti/val/nusc_val.txt" val_image_ids = _read_imageset_file(gt_split_file) # print("Val Image IDs: ", val_image_ids) det_path = "/mnt/nfs/scratch1/pmallya/nusc_kitti/val/infer_2/" dt_annos = kitti.get_label_annos(det_path, val_image_ids) gt_path = "/mnt/nfs/scratch1/pmallya/nusc_kitti/val/label_2/" gt_annos = kitti.get_label_annos(gt_path, val_image_ids) # print(dt_annos) # print(gt_annos) with open("./outputs/eval_result.json", "w", encoding="utf-8") as f: json.dump(get_official_eval_result(gt_annos, dt_annos, 0), f, ensure_ascii=False, indent=4) # f.write("\nCOCO Eval Result:\n") # print(get_coco_eval_result(gt_annos, dt_annos, 0))