Download scripts/analysis/compare_tracker_finetune.py from ZenoNing/ConsDrive: direct link, hf CLI and curl.
- Browser
- Download file 3.6 kB
-
https://huggingface.co/ZenoNing/ConsDrive/resolve/main/scripts/analysis/compare_tracker_finetune.py
- Command line
-
hf download hf://ZenoNing/ConsDrive/scripts/analysis/compare_tracker_finetune.py
-
curl -L -o compare_tracker_finetune.py https://huggingface.co/ZenoNing/ConsDrive/resolve/main/scripts/analysis/compare_tracker_finetune.py
3.6 kB
| import json, statistics, math | |
| from scipy import stats | |
| def load(p): return {r["route_id"]: r for r in json.load(open(p))["_checkpoint"]["records"]} | |
| runs = { | |
| "stage1": "/tmp/s1_view/merged.json", | |
| "oracle_full": "fastvlm_stage3_oracle_2026-11-01_07-40-56/merged.json", | |
| "oracle_repeat": "stage3_oracle_repeat_clean/merged.json", | |
| "speeddrop_mask15 (oracle)": "speeddrop_mask15/merged.json", | |
| "det_zeroshot_20hz (oracle ckpt)": "detector_zeroshot_v1/merged.json", | |
| "speeddrop_zeroshot_det4hz": "speeddrop_det4hz_mask15_zeroshot/merged.json", | |
| "ft_coast2": "tracker_ft_det4hz_mask15/merged.json", | |
| "ft_coast2_repeat": "tracker_ft_det4hz_mask15_repeat/merged.json", | |
| "ft_coast1": "tracker_ft_coast1_det4hz_mask15/merged.json", | |
| "ft_coast1_repeat": "tracker_ft_coast1_det4hz_mask15_repeat/merged.json", | |
| "ft_coast4": "tracker_ft_coast4_det4hz_mask15/merged.json", | |
| "ft_coast4_repeat": "tracker_ft_coast4_det4hz_mask15_repeat/merged.json", | |
| } | |
| R = {k: load(v) for k, v in runs.items()} | |
| a, b = R["oracle_full"], R["oracle_repeat"] | |
| ref = {k: (a[k]["scores"]["score_composed"] + b[k]["scores"]["score_composed"]) / 2 for k in a} | |
| keys = ["collisions_vehicle", "collisions_pedestrian", "collisions_layout", "red_light", "stop_infraction", "route_dev", "route_timeout", "scenario_timeouts", "vehicle_blocked"] | |
| print(f"{'run':34s} {'DS':>6s} {'SR':>6s} {'vs oracle':>18s} {'p':>6s} " + " ".join(f"{k.replace('collisions_','col_').replace('_infractions','')[:9]:>9s}" for k in keys) + " game_s") | |
| for n, recs in R.items(): | |
| ds = [recs[k]["scores"]["score_composed"] for k in ref] | |
| d = [recs[k]["scores"]["score_composed"] - ref[k] for k in ref] | |
| m, se = statistics.mean(d), statistics.stdev(d) / math.sqrt(len(d)) | |
| p = stats.wilcoxon(ds, [ref[k] for k in ref], zero_method="zsplit").pvalue | |
| sr = sum(r["status"] in ("Completed", "Perfect") and all(len(v) == 0 for k2, v in r["infractions"].items() if k2 != "min_speed_infractions") for r in recs.values()) / 220 * 100 | |
| tot = {k: sum(len(r["infractions"].get(k, [])) for r in recs.values()) for k in keys} | |
| gt = statistics.mean(r["meta"]["duration_game"] for r in recs.values()) | |
| print(f"{n:34s} {statistics.mean(ds):6.2f} {sr:6.2f} {m:+6.2f} [{m-1.96*se:+5.2f},{m+1.96*se:+5.2f}] {p:6.3f} " + " ".join(f"{tot[k]:9d}" for k in keys) + f" {gt:6.1f}") | |
| print() | |
| pooled = {} | |
| for name, pair in (("coast1", ("ft_coast1", "ft_coast1_repeat")), ("coast2", ("ft_coast2", "ft_coast2_repeat")), ("coast4", ("ft_coast4", "ft_coast4_repeat"))): | |
| x = {k: (R[pair[0]][k]["scores"]["score_composed"] + R[pair[1]][k]["scores"]["score_composed"]) / 2 for k in ref} | |
| pooled[name] = x | |
| d = [x[k] - ref[k] for k in ref] | |
| m, se = statistics.mean(d), statistics.stdev(d) / math.sqrt(len(d)) | |
| p = stats.wilcoxon([x[k] for k in ref], [ref[k] for k in ref], zero_method="zsplit").pvalue | |
| col = sum(len(R[q][k]["infractions"]["collisions_vehicle"]) for q in pair for k in ref) / 2 | |
| print(f"{name} x2 mean DS {statistics.mean(x.values()):6.2f} vs oracle mean {m:+.2f} [{m-1.96*se:+.2f},{m+1.96*se:+.2f}] p={p:.3f} vehicle collisions/run {col:.1f}") | |
| for nm, x, y in (("coast1 - coast2", pooled["coast1"], pooled["coast2"]), ("coast4 - coast2", pooled["coast4"], pooled["coast2"]), ("coast2 - stage1", pooled["coast2"], {k: R["stage1"][k]["scores"]["score_composed"] for k in ref})): | |
| d = [x[k] - y[k] for k in ref]; m, se = statistics.mean(d), statistics.stdev(d) / math.sqrt(len(d)) | |
| print(f"{nm}: {m:+.2f} [{m-1.96*se:+.2f},{m+1.96*se:+.2f}] p={stats.wilcoxon([x[k] for k in ref], [y[k] for k in ref], zero_method='zsplit').pvalue:.3f}") | |