Exemplo n.º 1
0
def run_eval(exp_name: str) -> Mapping[str, Any]:
    """ """
    pred_log_dir = f"{_ROOT}/test_data/eval_tracking_dummy_logs_pred"
    gt_log_dir = f"{_ROOT}/test_data/eval_tracking_dummy_logs_gt"

    out_fpath = f"{_ROOT}/test_data/{exp_name}.txt"
    out_file = open(out_fpath, "w")
    eval_tracks(
        path_tracker_output_root=pred_log_dir,
        path_dataset_root=gt_log_dir,
        d_min=0,
        d_max=100,
        out_file=out_file,
        centroid_method="average",
        diffatt=None,
        category="VEHICLE",
    )
    out_file.close()

    with open(out_fpath, "r") as f:
        result_lines = f.readlines()
        result_vals = result_lines[0].strip().split(" ")

        fn, num_frames, mota, motp_c, motp_o, motp_i, idf1 = result_vals[:7]
        most_track, most_lost, num_fp, num_miss, num_sw, num_frag = result_vals[
            7:]

        result_dict = {
            "filename": fn,
            "num_frames": int(num_frames),
            "mota": float(mota),
            "motp_c": float(motp_c),
            "motp_o": float(motp_o),
            "motp_i": float(motp_i),
            "idf1": float(idf1),
            "most_track": float(most_track),
            "most_lost": float(most_lost),
            "num_fp": int(num_fp),
            "num_miss": int(num_miss),
            "num_sw": int(num_sw),
            "num_frag": int(num_frag),
        }
    shutil.rmtree(pred_log_dir)
    shutil.rmtree(gt_log_dir)
    return result_dict
Exemplo n.º 2
0
def test_evaluation_track():
    """
        test eval_tracks function
        """

    # for testing, consider all point
    eval_tracking.min_point_num = 0
    centroid_methods = ["label_center", "average"]
    temp_output = TEST_DATA_LOC / "tmp"
    out_file = open(temp_output, "w+")

    log = "1"
    log_location = TEST_DATA_LOC / log

    # sanity check, gt and results exactly the same
    track_results_location = log_location / "per_sweep_annotations_amodal"
    cm = centroid_methods[1]
    eval_tracking.eval_tracks(track_results_location, os.fspath(log_location), D_MIN, D_MAX, out_file, cm)
    # _,n_frame,mota,motp, idf1, mostly_tracked,mostly_lost,num_false_positives, num_misses,num_switches,num_fragmentations = out_file.read().strip().split(' ')
    out_file.close()
Exemplo n.º 3
0
def test_evaluation_track():
    """
        test eval_tracks function
        """

    # for testing, consider all point
    eval_tracking.min_point_num = 0
    centroid_methods = ["label_center", "average"]
    temp_output = TEST_DATA_LOC / "tmp"
    out_file = open(temp_output, "w+")

    log = "1"
    log_location = TEST_DATA_LOC / log

    # sanity check, gt and results exactly the same
    track_results_location = log_location / "per_sweep_annotations_amodal"
    cm = centroid_methods[1]
    eval_tracking.eval_tracks([track_results_location],
                              [os.fspath(log_location)], D_MIN, D_MAX,
                              out_file, cm)
    out_file.close()
                            thr_estimate=thr_estimate,
                            thr_prune=thr_prune,
                            ps=ps)

                print(f"Elapsed tracking vehicle {time.time() - time_start}")

                time_start = time.time()

                with open(filename_v, "a+") as out_file:
                    out_file.write(
                        f"{p_vel_mult} min_conf {min_conf} match_thr {match_threshold} {thr_prune} {thr_estimate} {ps} "
                    )
                    eval_tracks(path_results,
                                path_data,
                                0,
                                100,
                                out_file,
                                'average',
                                diffatt=None,
                                category='VEHICLE')

                print(f"Elapsed evaluating vehicle {time.time() - time_start}")

                if os.path.exists(path_results):
                    shutil.rmtree(path_results)

                match_threshold = 0.001
                min_conf = 0.26

                time_start = time.time()

                # Pedestrian
def dump_scenario_json(centers, yaw_angles, log_id, is_gt, run_eval=True):
    """
	Egovehicle stationary (represented by `o`).
	Seqeuence of 4-nanosecond timestamps.
	"""
    t_objs = TrackedObjects(log_id=log_id, is_gt=is_gt)

    l = 2
    w = 2
    h = 1
    track_id = 'obj_a'
    label_class = 'VEHICLE'

    cx, cy, cz = centers[0]
    qx, qy, qz, qw = yaw_to_quaternion3d(yaw=yaw_angles[0])
    tor = TrackedObjRec(l, w, h, qx, qy, qz, qw, cx, cy, cz, track_id,
                        label_class)
    t_objs.add_obj(tor, ts_ns=0)

    cx, cy, cz = centers[1]
    qx, qy, qz, qw = yaw_to_quaternion3d(yaw=yaw_angles[1])
    tor = TrackedObjRec(l, w, h, qx, qy, qz, qw, cx, cy, cz, track_id,
                        label_class)
    t_objs.add_obj(tor, ts_ns=1)

    cx, cy, cz = centers[2]
    qx, qy, qz, qw = yaw_to_quaternion3d(yaw=yaw_angles[2])
    tor = TrackedObjRec(l, w, h, qx, qy, qz, qw, cx, cy, cz, track_id,
                        label_class)
    t_objs.add_obj(tor, ts_ns=2)

    cx, cy, cz = centers[3]
    qx, qy, qz, qw = yaw_to_quaternion3d(yaw=yaw_angles[3])
    tor = TrackedObjRec(l, w, h, qx, qy, qz, qw, cx, cy, cz, track_id,
                        label_class)
    t_objs.add_obj(tor, ts_ns=3)

    t_objs.save_to_disk()

    if not run_eval:
        return None

    pred_log_dir = f'{_ROOT}/test_data/eval_tracking_dummy_logs_pred'
    gt_log_dir = f'{_ROOT}/test_data/eval_tracking_dummy_logs_gt'

    out_fpath = f'{_ROOT}/test_data/{log_id}.txt'
    out_file = open(out_fpath, 'w')
    eval_tracks(path_tracker_output_root=pred_log_dir,
                path_dataset_root=gt_log_dir,
                d_min=0,
                d_max=100,
                out_file=out_file,
                centroid_method="average",
                diffatt=None,
                category='VEHICLE')
    out_file.close()

    with open(out_fpath, 'r') as f:
        result_lines = f.readlines()
        result_vals = result_lines[0].strip().split(' ')

        fn, num_frames, mota, motp_c, motp_o, motp_i, idf1 = result_vals[:7]
        most_track, most_lost, num_fp, num_miss, num_sw, num_frag = result_vals[
            7:]

        # Todo: change `num_flag` to `num_frag`
        result_dict = {
            'filename': fn,
            'num_frames': int(num_frames),
            'mota': float(mota),
            'motp_c': float(motp_c),
            'motp_o': float(motp_o),
            'motp_i': float(motp_i),
            'idf1': float(idf1),
            'most_track': float(most_track),
            'most_lost': float(most_lost),
            'num_fp': int(num_fp),
            'num_miss': int(num_miss),
            'num_sw': int(num_sw),
            'num_frag': int(num_frag),
        }
    shutil.rmtree(pred_log_dir)
    shutil.rmtree(gt_log_dir)
    return result_dict