Download run_classification_pilot.py from JackieMM/progress_probe_repro: direct link, hf CLI and curl.
- Browser
- Download file 8.19 kB
-
https://huggingface.co/JackieMM/progress_probe_repro/resolve/main/run_classification_pilot.py
- Command line
-
hf download hf://JackieMM/progress_probe_repro/run_classification_pilot.py
-
curl -L -o run_classification_pilot.py https://huggingface.co/JackieMM/progress_probe_repro/resolve/main/run_classification_pilot.py
8.19 kB
| #!/usr/bin/env python3 | |
| """Batch runner for classification probe milestones.""" | |
| from __future__ import annotations | |
| import argparse | |
| import subprocess | |
| import sys | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parent | |
| PY = sys.executable | |
| # Prefer ACP /data/share, else Himacon /share (override with LABEL_ROOT / VIDEO_ROOT) | |
| sys.path.insert(0, str(ROOT)) | |
| from path_detect import detect_share_roots # noqa: E402 | |
| _label, _video = detect_share_roots() | |
| LABEL_ROOT = str(_label) | |
| VIDEO_ROOT = str(_video) | |
| OUT = ROOT / "outputs" / "classification_probe" | |
| TASK = "blocks_ranking_rgb" | |
| DEMOS = ["demo_clean_100_arx", "demo_clean_100_franka", "demo_clean_100_ur5"] | |
| def run(cmd: list[str]) -> None: | |
| print("+", " ".join(cmd), flush=True) | |
| subprocess.run(cmd, check=True, cwd=str(ROOT)) | |
| def smoke(n_episodes: int = 5, n_splits: int = 2) -> None: | |
| demo = "demo_clean_100_franka" | |
| run([ | |
| PY, "classification_probe.py", "propose-primitive-labels", | |
| "--task", TASK, "--demo", demo, | |
| "--label-root", LABEL_ROOT, "--video-root", VIDEO_ROOT, | |
| "--annotation-root", str(OUT), "--max-episodes", str(n_episodes), | |
| ]) | |
| for label_kind in ("full_label", "womae_label"): | |
| out = OUT / "within_robot" / TASK / demo / f"{label_kind}_val0_960" | |
| run([ | |
| PY, "classification_probe.py", "fit-cv", | |
| "--task", TASK, "--demo", demo, "--label-kind", label_kind, | |
| "--label-root", LABEL_ROOT, "--video-root", VIDEO_ROOT, | |
| "--annotation-root", str(OUT), "--output-dir", str(out), | |
| "--n-splits", str(n_splits), "--seed", "42", | |
| ]) | |
| run([ | |
| PY, "classification_probe.py", "viz-temporal", | |
| "--task", TASK, "--label-kind", "full_label", | |
| "--label-root", LABEL_ROOT, "--video-root", VIDEO_ROOT, | |
| "--annotation-root", str(OUT), | |
| "--output-dir", str(OUT / "visualization" / "smoke"), | |
| "--train-demo", demo, "--eval-demo", demo, | |
| "--source-episode", "0", "--target-episode", "0", | |
| "--model-path", str(OUT / "within_robot" / TASK / demo / "full_label_val0_960" / "checkpoints" / "model_all_episodes.joblib"), | |
| ]) | |
| def train(n_episodes: int = 100, n_splits: int = 10) -> None: | |
| """Train/eval on existing annotations (no proposal step).""" | |
| run([ | |
| PY, "classification_probe.py", "check-distribution", | |
| "--task", TASK, "--annotation-root", str(OUT), | |
| "--output-dir", str(OUT / "summary"), | |
| ]) | |
| for demo in DEMOS: | |
| for label_kind in ("full_label", "womae_label"): | |
| out = OUT / "within_robot" / TASK / demo / f"{label_kind}_val0_960" | |
| run([ | |
| PY, "classification_probe.py", "fit-cv", | |
| "--task", TASK, "--demo", demo, "--label-kind", label_kind, | |
| "--label-root", LABEL_ROOT, "--video-root", VIDEO_ROOT, | |
| "--annotation-root", str(OUT), "--output-dir", str(out), | |
| "--n-splits", str(n_splits), "--seed", "42", "--max-episodes", str(n_episodes), | |
| ]) | |
| run([ | |
| PY, "classification_probe.py", "fit-time-baseline", | |
| "--task", TASK, "--demo", demo, "--label-kind", label_kind, | |
| "--label-root", LABEL_ROOT, "--video-root", VIDEO_ROOT, | |
| "--annotation-root", str(OUT), | |
| "--n-splits", str(n_splits), "--seed", "42", "--max-episodes", str(n_episodes), | |
| ]) | |
| run([ | |
| PY, "classification_probe.py", "fit-majority-baseline", | |
| "--task", TASK, "--demo", demo, "--label-kind", label_kind, | |
| "--label-root", LABEL_ROOT, "--video-root", VIDEO_ROOT, | |
| "--annotation-root", str(OUT), | |
| "--n-splits", str(n_splits), "--seed", "42", "--max-episodes", str(n_episodes), | |
| ]) | |
| cross_out = OUT / "cross_robot" / TASK | |
| run([ | |
| PY, "classification_probe.py", "fit-cross-robot", | |
| "--task", TASK, "--label-root", LABEL_ROOT, "--video-root", VIDEO_ROOT, | |
| "--annotation-root", str(OUT), "--output-dir", str(cross_out), | |
| "--max-episodes", str(n_episodes), | |
| ]) | |
| run([ | |
| PY, "classification_probe.py", "summarize", | |
| "--task", TASK, "--label-root", LABEL_ROOT, "--video-root", VIDEO_ROOT, | |
| "--annotation-root", str(OUT), "--max-episodes", str(n_episodes), | |
| ]) | |
| def pilot(n_episodes: int = 20, n_splits: int = 5) -> None: | |
| run([ | |
| PY, "classification_probe.py", "propose-primitive-labels", | |
| "--task", TASK, "--demos", *DEMOS, | |
| "--label-root", LABEL_ROOT, "--video-root", VIDEO_ROOT, | |
| "--annotation-root", str(OUT), "--max-episodes", str(n_episodes), | |
| ]) | |
| run([ | |
| PY, "classification_probe.py", "check-distribution", | |
| "--task", TASK, "--annotation-root", str(OUT), | |
| "--output-dir", str(OUT / "summary"), | |
| ]) | |
| for demo in DEMOS: | |
| for label_kind in ("full_label", "womae_label"): | |
| out = OUT / "within_robot" / TASK / demo / f"{label_kind}_val0_960" | |
| run([ | |
| PY, "classification_probe.py", "fit-cv", | |
| "--task", TASK, "--demo", demo, "--label-kind", label_kind, | |
| "--label-root", LABEL_ROOT, "--video-root", VIDEO_ROOT, | |
| "--annotation-root", str(OUT), "--output-dir", str(out), | |
| "--n-splits", str(n_splits), "--seed", "42", "--max-episodes", str(n_episodes), | |
| ]) | |
| run([ | |
| PY, "classification_probe.py", "fit-time-baseline", | |
| "--task", TASK, "--demo", demo, "--label-kind", label_kind, | |
| "--label-root", LABEL_ROOT, "--video-root", VIDEO_ROOT, | |
| "--annotation-root", str(OUT), | |
| "--n-splits", str(n_splits), "--seed", "42", "--max-episodes", str(n_episodes), | |
| ]) | |
| run([ | |
| PY, "classification_probe.py", "fit-majority-baseline", | |
| "--task", TASK, "--demo", demo, "--label-kind", label_kind, | |
| "--label-root", LABEL_ROOT, "--video-root", VIDEO_ROOT, | |
| "--annotation-root", str(OUT), | |
| "--n-splits", str(n_splits), "--seed", "42", "--max-episodes", str(n_episodes), | |
| ]) | |
| cross_out = OUT / "cross_robot" / TASK | |
| run([ | |
| PY, "classification_probe.py", "fit-cross-robot", | |
| "--task", TASK, "--label-root", LABEL_ROOT, "--video-root", VIDEO_ROOT, | |
| "--annotation-root", str(OUT), "--output-dir", str(cross_out), | |
| "--max-episodes", str(n_episodes), | |
| ]) | |
| run([ | |
| PY, "classification_probe.py", "viz-tsne", | |
| "--task", TASK, "--label-kind", "full_label", | |
| "--label-root", LABEL_ROOT, "--video-root", VIDEO_ROOT, | |
| "--annotation-root", str(OUT), | |
| "--output-dir", str(OUT / "visualization"), | |
| "--demos", *DEMOS, "--max-episodes", str(n_episodes), | |
| ]) | |
| run([ | |
| PY, "classification_probe.py", "summarize", | |
| "--task", TASK, "--label-root", LABEL_ROOT, "--video-root", VIDEO_ROOT, | |
| "--annotation-root", str(OUT), "--max-episodes", str(n_episodes), | |
| ]) | |
| def final(n_episodes: int = 100, n_splits: int = 10) -> None: | |
| run([ | |
| PY, "classification_probe.py", "propose-primitive-labels", | |
| "--task", TASK, "--demos", *DEMOS, | |
| "--label-root", LABEL_ROOT, "--video-root", VIDEO_ROOT, | |
| "--annotation-root", str(OUT), "--max-episodes", str(n_episodes), | |
| ]) | |
| pilot(n_episodes=n_episodes, n_splits=n_splits) | |
| def main() -> None: | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("stage", choices=["smoke", "pilot", "final", "train"]) | |
| parser.add_argument("--n-episodes", type=int, default=None) | |
| parser.add_argument("--n-splits", type=int, default=None) | |
| args = parser.parse_args() | |
| OUT.mkdir(parents=True, exist_ok=True) | |
| if args.stage == "smoke": | |
| smoke(args.n_episodes or 5, args.n_splits or 2) | |
| elif args.stage == "pilot": | |
| pilot(args.n_episodes or 20, args.n_splits or 5) | |
| elif args.stage == "train": | |
| train(args.n_episodes or 100, args.n_splits or 10) | |
| else: | |
| final(args.n_episodes or 100, args.n_splits or 10) | |
| if __name__ == "__main__": | |
| main() | |