Datasets:
Tasks:
Image Classification
Formats:
parquet
Size:
1K - 10K
Tags:
fish-recognition
fine-grained-recognition
biodiversity-informatics
benchmark
temporal-evaluation
License:
| #!/usr/bin/env python3 | |
| """Verify the encoded image bytes stored in the QT26-QC Parquet shards.""" | |
| from __future__ import annotations | |
| import argparse | |
| import hashlib | |
| from pathlib import Path | |
| from datasets import Image, load_dataset | |
| def main() -> int: | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument( | |
| "--data", | |
| default=str(Path(__file__).resolve().parents[1] / "data" / "test-*.parquet"), | |
| help="Parquet glob or one Parquet file", | |
| ) | |
| args = parser.parse_args() | |
| dataset = load_dataset("parquet", data_files=args.data, split="train") | |
| raw = dataset.cast_column("image", Image(decode=False)) | |
| checked = 0 | |
| for row in raw: | |
| payload = row["image"]["bytes"] | |
| if payload is None: | |
| raise ValueError(f"missing embedded bytes: {row['public_id']}") | |
| actual = hashlib.sha256(payload).hexdigest() | |
| if actual != row["image_sha256"]: | |
| raise ValueError( | |
| f"SHA-256 mismatch for {row['public_id']}: {actual} != {row['image_sha256']}" | |
| ) | |
| if len(payload) != row["image_bytes"]: | |
| raise ValueError(f"byte-length mismatch for {row['public_id']}") | |
| checked += 1 | |
| print(f"PASS: verified encoded bytes for {checked:,} QT26-QC rows") | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |