Download src/data_audit.py from huohuo0345/0716: direct link, hf CLI and curl.
- Browser
- Download file 1.71 kB
-
https://huggingface.co/datasets/huohuo0345/0716/resolve/main/src/data_audit.py
- Command line
-
hf download hf://datasets/huohuo0345/0716/src/data_audit.py
-
curl -L -o data_audit.py https://huggingface.co/datasets/huohuo0345/0716/resolve/main/src/data_audit.py
1.71 kB
| from __future__ import annotations | |
| import argparse | |
| import collections | |
| import os | |
| from .common import CAMERA_ORDER, load_rows, normalized_row | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description="Audit flattened DriveLM data") | |
| parser.add_argument("--data-dir", required=True) | |
| parser.add_argument("--splits", nargs="+", default=["train", "val"]) | |
| parser.add_argument("--num-views", type=int, default=6) | |
| parser.add_argument("--allow-missing-images", action="store_true") | |
| args = parser.parse_args() | |
| failed = False | |
| cameras = CAMERA_ORDER[: args.num_views] | |
| for split in args.splits: | |
| rows = [normalized_row(row) for row in load_rows(args.data_dir, split)] | |
| tasks = collections.Counter(row["task_type"] for row in rows) | |
| missing_text = sum(not row["question"] or not row["answer"] for row in rows) | |
| missing_images = collections.Counter() | |
| for row in rows: | |
| for camera in cameras: | |
| path = row["image_paths"].get(camera, "") | |
| if not path or not os.path.isfile(path): | |
| missing_images[camera] += 1 | |
| print(f"[{split}] rows={len(rows)} task_types={dict(tasks)}") | |
| print(f"[{split}] empty_question_or_answer={missing_text}") | |
| print(f"[{split}] missing_images={dict(missing_images)}") | |
| if rows: | |
| print(f"[{split}] first_question={rows[0]['question'][:160]!r}") | |
| failed |= missing_text > 0 | |
| failed |= bool(missing_images) and not args.allow_missing_images | |
| if failed: | |
| raise SystemExit("Data audit failed; fix the reported issues before training") | |
| print("DATA_AUDIT_OK") | |
| if __name__ == "__main__": | |
| main() | |