Download scripts/validate_public_arx.py from JackieMM/robotwin-pi05-arx: direct link, hf CLI and curl.
- Browser
- Download file 3.62 kB
-
https://huggingface.co/JackieMM/robotwin-pi05-arx/resolve/main/scripts/validate_public_arx.py
- Command line
-
hf download hf://JackieMM/robotwin-pi05-arx/scripts/validate_public_arx.py
-
curl -L -o validate_public_arx.py https://huggingface.co/JackieMM/robotwin-pi05-arx/resolve/main/scripts/validate_public_arx.py
3.62 kB
| #!/usr/bin/env python3 | |
| """Validate a public ARX X5 LeRobot export without ROS or model dependencies.""" | |
| from __future__ import annotations | |
| import argparse | |
| import json | |
| import subprocess | |
| from pathlib import Path | |
| import numpy as np | |
| import pyarrow.parquet as pq | |
| def video_info(path: Path) -> dict: | |
| import cv2 | |
| cap = cv2.VideoCapture(str(path)) | |
| if not cap.isOpened(): | |
| raise RuntimeError(f"cannot open video: {path}") | |
| frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT)) | |
| fps = float(cap.get(cv2.CAP_PROP_FPS)) | |
| width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) | |
| height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) | |
| ok, frame = cap.read() | |
| cap.release() | |
| if not ok or frame is None: | |
| raise RuntimeError(f"cannot decode first frame: {path}") | |
| return {"frames": frames, "fps": fps, "width": width, "height": height} | |
| def main() -> int: | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("dataset", type=Path) | |
| parser.add_argument("--output", type=Path) | |
| args = parser.parse_args() | |
| info_path = args.dataset / "meta/info.json" | |
| parquet = args.dataset / "data/chunk-000/episode_000000.parquet" | |
| info = json.loads(info_path.read_text(encoding="utf-8")) | |
| table = pq.read_table(parquet) | |
| report: dict = { | |
| "source": "https://huggingface.co/datasets/heyuan1993/record-test-arxx5_bimanual", | |
| "robot_type": info.get("robot_type"), | |
| "fps": info.get("fps"), | |
| "declared_episodes": info.get("total_episodes"), | |
| "declared_frames": info.get("total_frames"), | |
| "columns": table.column_names, | |
| "videos": {}, | |
| "checks": {}, | |
| } | |
| for key in ("observation.state", "action"): | |
| if key not in table.column_names: | |
| raise RuntimeError(f"missing column: {key}") | |
| values = np.asarray(table[key].to_pylist(), dtype=np.float32) | |
| if values.ndim != 2 or values.shape[1] != 14: | |
| raise RuntimeError(f"{key} has shape {values.shape}, expected (N, 14)") | |
| if not np.isfinite(values).all(): | |
| raise RuntimeError(f"{key} contains non-finite values") | |
| report["checks"][key] = { | |
| "shape": list(values.shape), | |
| "finite": True, | |
| "min": np.round(values.min(axis=0), 6).tolist(), | |
| "max": np.round(values.max(axis=0), 6).tolist(), | |
| } | |
| state = np.asarray(table["observation.state"].to_pylist(), dtype=np.float32) | |
| action = np.asarray(table["action"].to_pylist(), dtype=np.float32) | |
| report["checks"]["action_delta"] = { | |
| "max_abs": float(np.abs(action - state).max()), | |
| "mean_abs": float(np.abs(action - state).mean()), | |
| "identical_fraction": float(np.all(action == state, axis=1).mean()), | |
| } | |
| video_root = args.dataset / "videos/chunk-000" | |
| for path in sorted(video_root.glob("observation.images.*/episode_000000.mp4")): | |
| report["videos"][path.parent.name] = video_info(path) | |
| if len(report["videos"]) < 3: | |
| raise RuntimeError("expected at least three decoded camera videos") | |
| report["checks"]["video_alignment"] = { | |
| "all_same_frame_count": len({v["frames"] for v in report["videos"].values()}) == 1, | |
| "all_640x480": all(v["width"] == 640 and v["height"] == 480 for v in report["videos"].values()), | |
| } | |
| report["result"] = "pass" | |
| text = json.dumps(report, indent=2, ensure_ascii=True) + "\n" | |
| print(text, end="") | |
| if args.output: | |
| args.output.parent.mkdir(parents=True, exist_ok=True) | |
| args.output.write_text(text, encoding="utf-8") | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |