Download examples/quickstart_loader.py from Lo6yu/egocentric_dataset: direct link, hf CLI and curl.
- Browser
- Download file 2.54 kB
-
https://huggingface.co/datasets/Lo6yu/egocentric_dataset/resolve/main/examples/quickstart_loader.py
- Command line
-
hf download hf://datasets/Lo6yu/egocentric_dataset/examples/quickstart_loader.py
-
curl -L -o quickstart_loader.py https://huggingface.co/datasets/Lo6yu/egocentric_dataset/resolve/main/examples/quickstart_loader.py
2.54 kB
| #!/usr/bin/env python3 | |
| """Quickstart loader for the egocentric RGB-D + EMG/IMU dataset. | |
| This script uses only the Python standard library. It reads viewer/train.csv, | |
| lists the packages, and checks whether each package contains the expected | |
| public directories. | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import csv | |
| from pathlib import Path | |
| EXPECTED_DIRS = [ | |
| "source_stage_a", | |
| "clean", | |
| "gold", | |
| "analysis", | |
| "events", | |
| "training_ready", | |
| ] | |
| def read_viewer_index(dataset_root: Path) -> list[dict[str, str]]: | |
| index_path = dataset_root / "viewer" / "train.csv" | |
| if not index_path.exists(): | |
| raise FileNotFoundError(f"Missing viewer index: {index_path}") | |
| with index_path.open("r", encoding="utf-8-sig", newline="") as f: | |
| return list(csv.DictReader(f)) | |
| def package_status(dataset_root: Path, row: dict[str, str]) -> dict[str, object]: | |
| package_id = row["package_id"] | |
| package_dir = dataset_root / row.get("package_path", f"packages/{package_id}") | |
| missing = [name for name in EXPECTED_DIRS if not (package_dir / name).exists()] | |
| return { | |
| "package_id": package_id, | |
| "task_name": row.get("task_name", ""), | |
| "size_gb": row.get("package_size_gb", ""), | |
| "package_dir": package_dir, | |
| "missing": missing, | |
| "ok": package_dir.exists() and not missing, | |
| } | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description="Inspect dataset packages.") | |
| parser.add_argument("--dataset-root", default=".", help="Dataset repository root") | |
| args = parser.parse_args() | |
| dataset_root = Path(args.dataset_root).expanduser().resolve() | |
| rows = read_viewer_index(dataset_root) | |
| print(f"Dataset root: {dataset_root}") | |
| print(f"Packages: {len(rows)}") | |
| print() | |
| print(f"{'package_id':28} {'size_gb':>8} {'status':>8} task_name") | |
| print("-" * 78) | |
| failures = 0 | |
| for row in rows: | |
| status = package_status(dataset_root, row) | |
| ok_text = "ok" if status["ok"] else "missing" | |
| if not status["ok"]: | |
| failures += 1 | |
| print( | |
| f"{status['package_id']:28} {str(status['size_gb']):>8} " | |
| f"{ok_text:>8} {status['task_name']}" | |
| ) | |
| if status["missing"]: | |
| print(f" missing: {', '.join(status['missing'])}") | |
| print() | |
| if failures: | |
| raise SystemExit(f"Found {failures} package(s) with missing public directories.") | |
| print("All packages contain the expected public directories.") | |
| if __name__ == "__main__": | |
| main() | |