Datasets:
Tasks:
Image Classification
Formats:
parquet
Size:
1K - 10K
Tags:
fish-recognition
fine-grained-recognition
biodiversity-informatics
benchmark
temporal-evaluation
License:
File size: 1,345 Bytes
fb37bc0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #!/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())
|