Release KITTI-C2L v1.0.0: documented self-contained benchmark, loader and baselines
db613b6 verified Download code/scripts/check_hub_payloads.py from mcocheteux/KITTI-C2L-Dataset: direct link, hf CLI and curl.
- Browser
- Download file 3.66 kB
-
https://huggingface.co/datasets/mcocheteux/KITTI-C2L-Dataset/resolve/main/code/scripts/check_hub_payloads.py
- Command line
-
hf download hf://datasets/mcocheteux/KITTI-C2L-Dataset/code/scripts/check_hub_payloads.py
-
curl -L -o check_hub_payloads.py https://huggingface.co/datasets/mcocheteux/KITTI-C2L-Dataset/resolve/main/code/scripts/check_hub_payloads.py
3.66 kB
| """Verify the smallest uploaded train/test shards against local KITTI Raw bytes.""" | |
| from __future__ import annotations | |
| import argparse | |
| import io | |
| import json | |
| from pathlib import Path | |
| import numpy as np | |
| import pyarrow.parquet as pq | |
| from huggingface_hub import hf_hub_download | |
| from PIL import Image | |
| from kitti_c2l.release import require, sha256, validate_hub_manifest | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("--root", type=Path, default=Path(__file__).resolve().parents[1]) | |
| parser.add_argument("--raw-root", type=Path, required=True) | |
| parser.add_argument("--output", type=Path, required=True) | |
| args = parser.parse_args() | |
| if args.output.exists(): | |
| raise FileExistsError(args.output) | |
| manifest = validate_hub_manifest(args.root) | |
| selected = [ | |
| min( | |
| ( | |
| item | |
| for item in manifest["shards"] | |
| if item["path"].startswith(f"data/frames_{split}-") | |
| ), | |
| key=lambda item: item["bytes"], | |
| ) | |
| for split in ("train", "test") | |
| ] | |
| results = [] | |
| for item in selected: | |
| path = Path( | |
| hf_hub_download( | |
| manifest["repo_id"], | |
| item["path"], | |
| repo_type="dataset", | |
| revision=manifest["revision"], | |
| ) | |
| ) | |
| require(sha256(path) == item["sha256"], f"shard checksum mismatch: {item['path']}") | |
| count = 0 | |
| for batch in pq.ParquetFile(path).iter_batches(batch_size=16): | |
| for row in batch.to_pylist(): | |
| drive = ( | |
| args.raw_root | |
| / row["raw_date"] | |
| / f"{row['raw_date']}_drive_{row['raw_drive']}_sync" | |
| ) | |
| frame = f"{row['raw_frame_index']:010d}" | |
| require( | |
| row["image_png"] == (drive / "image_02/data" / f"{frame}.png").read_bytes(), | |
| "image source bytes mismatch", | |
| ) | |
| require( | |
| row["points_bin"] | |
| == (drive / "velodyne_points/data" / f"{frame}.bin").read_bytes(), | |
| "scan source bytes mismatch", | |
| ) | |
| with Image.open(io.BytesIO(row["image_png"])) as image: | |
| require( | |
| image.size == (row["image_width"], row["image_height"]), | |
| "image dimensions mismatch", | |
| ) | |
| image.verify() | |
| points = np.frombuffer(row["points_bin"], dtype=np.float32).reshape(-1, 4) | |
| require(len(points) > 0 and np.isfinite(points).all(), "invalid scan values") | |
| count += 1 | |
| results.append( | |
| { | |
| "path": item["path"], | |
| "sha256": item["sha256"], | |
| "bytes": item["bytes"], | |
| "verified_frame_payloads": count, | |
| "raw_source_bytes_and_decoding": "pass", | |
| } | |
| ) | |
| print(f"{item['path']}: {count} image/scan pairs match local KITTI Raw", flush=True) | |
| report = { | |
| "repo_id": manifest["repo_id"], | |
| "revision": manifest["revision"], | |
| "status": "pass", | |
| "scope": "Smallest train and test shards downloaded in full, SHA256 verified, every sensor payload compared byte-for-byte to local KITTI Raw and decoded. Not every shard payload was downloaded.", | |
| "shards": results, | |
| } | |
| args.output.parent.mkdir(parents=True, exist_ok=True) | |
| args.output.write_text(json.dumps(report, indent=2) + "\n") | |
| if __name__ == "__main__": | |
| main() | |