def test_temp_2(run): import json from test_stars_data_proc import get_config, check_file_and_size, get_config_file import sys sys.path.append("../") # Running Detection Tracking on video from StarsDataProcessing.detection_tracking.detection_tracking_copy import ( detection_tracking, ) cfg = get_config(run) detection_tracking(cfg)
def test_fvd_demo1(run): # Carla test_obj = TestSTARSDataProc() cfg = get_config(run) if cfg["eval"]: # Get p,r for one side # test_1(run) # Get trajectory for one side # Get mota,motp for side 0 using GT test_2(run) # Get trajectory for other side from StarsDataProcessing.detection_tracking.detection_tracking import ( detection_tracking, ) sys.path.append("../StarsDataProcessing/detection_tracking") cfg["intersection_config"] = cfg["intersection_config_2"] cfg["video"] = cfg["video_2"] cfg["trajectory_pred"] = cfg["trajectory_pred_2"] detection_tracking(cfg) assert check_file_and_size(cfg["trajectory_pred"]) # combine both cfg2 = get_config(run) traj_combined = combine(cfg2["trajectory_pred"], cfg2["trajectory_pred_2"]) traj_combined.to_csv(cfg2["trajectory_pred_combined"], index=False) assert check_file_and_size(cfg2["trajectory_pred_combined"]) else: # get trajectories test_obj.test_get_trajectory(run) # Get TL status for both test_obj.test_get_TL_status(run) # compute TLV, LVD using both sides test_obj.test_get_TLV(run) test_obj.test_get_LVD(run) if cfg["eval"]: # Compare params with GT test_obj.test_validate_params_wrt_gt(run) assert True
def test_get_trajectory(self, run): from StarsDataProcessing.detection_tracking.detection_tracking import ( detection_tracking, ) sys.path.append("../StarsDataProcessing/detection_tracking") cfg = get_config(run) detection_tracking(cfg) assert check_file_and_size(cfg["trajectory_pred"]) cfg["intersection_config"] = cfg["intersection_config_2"] cfg["video"] = cfg["video_2"] cfg["trajectory_pred"] = cfg["trajectory_pred_2"] detection_tracking(cfg) assert check_file_and_size(cfg["trajectory_pred"]) # combine both cfg2 = get_config(run) traj_combined = combine(cfg2["trajectory_pred"], cfg2["trajectory_pred_2"]) traj_combined.to_csv(cfg2["trajectory_pred_combined"], index=False) assert check_file_and_size(cfg2["trajectory_pred_combined"])
def test_2(run): import json from test_stars_data_proc import get_config, check_file_and_size, get_config_file import sys sys.path.append("../") # Running Detection Tracking on video from StarsDataProcessing.detection_tracking.detection_tracking import ( detection_tracking, ) cfg = get_config(run) mota, motp = detection_tracking(cfg) intersection_cfg_path = cfg["intersection_config"] intersection_cfg = get_config_file(intersection_cfg_path) intersection_type = intersection_cfg["type"] if intersection_type == "carla": assert mota >= 0.4 assert motp >= 0.4 assert True
def test_3(run): import json from test_stars_data_proc import get_config, check_file_and_size, get_config_file import sys sys.path.append("../") # Running Detection Tracking on video from StarsDataProcessing.detection_tracking.detection_tracking import ( detection_tracking, ) cfg = get_config(run) detection_tracking(cfg) # Extracting params from trajectory files from StarsDataProcessing.tl_violation.traffic_violation import tlv from StarsDataProcessing import extract_params tlv = tlv(cfg) lvd_stats = extract_params.get_global_stats() if check_file_and_size(cfg["params_pred"]): with open(cfg["params_pred"]) as f: params = json.load(f) else: params = {} params["LVD"] = lvd_stats params["TLV"] = tlv os.remove(cfg["params_pred"]) with open(cfg["params_pred"], "w") as f: json.dump(params, f, indent=4) intersection_cfg_path = cfg["intersection_config"] intersection_cfg = get_config_file(intersection_cfg_path) intersection_type = intersection_cfg["type"] if intersection_type == "carla": params_pred = get_config_file(cfg["params_pred"]) params_gt = get_config_file(cfg["params_gt"]) dist_param = "min_lvd_global" if params_gt["TLV"] != 0: eps = 0 else: eps = 0.001 diff_tlv = (params_pred["TLV"] - params_gt["TLV"] - eps) / ( params_gt["TLV"] + eps ) if params_gt["LVD"] != 0: eps = 0 else: eps = 0.001 diff_lvd = (params_pred["LVD"][dist_param] / 9.46 - params_gt["LVD"] - eps) / ( params_gt["LVD"] + eps ) print("TLV : ", diff_tlv, "LVD : ", diff_lvd) assert abs(diff_tlv) <= 0.2 assert abs(diff_lvd) <= 0.2