philipp-fischer's picture lvoegtle's picture
Initial public release
b82fcf1
|
Raw History Blame Contribute Delete
1.87 kB

deepvision_reasoning

Download visual_logic-26k.parquet from skylenage-ai/DeepVision-103K, revision d90619a39b1d2db7815ec958f2d728c78daa80cb. Images are embedded in the images column.

Match the filename stem in each JSONL image field to the SHA-256 digest of the original embedded bytes in the source Parquet images column. For a list of images, hash and extract each image separately. Write those bytes into deepvision_reasoning/images/ using the digest plus .png. Use the image bytes as the key, rather than the Parquet row number or either dataset's record ID.

Extract the original embedded bytes to deepvision_reasoning/images/<SHA-256-of-original-image-bytes>.png. The following example runs from the release root with pyarrow installed and downloaded files in /downloads/source/:

from pathlib import Path
import hashlib
import pyarrow.parquet as pq
out = Path("deepvision_reasoning/images")
out.mkdir(parents=True, exist_ok=True)
for path in sorted(Path("/downloads/source").rglob("*.parquet")):
    pf = pq.ParquetFile(path)
    for batch in pf.iter_batches(batch_size=128, columns=["images"]):
        for row in batch.to_pylist():
            value = row["images"]
            for image in value if isinstance(value, list) else [value]:
                data = image.get("bytes") if isinstance(image, dict) else None
                if data:
                    (out / (hashlib.sha256(data).hexdigest() + ".png")).write_bytes(data)

Check that all referenced paths exist after extraction. Retain the original bytes without re-encoding, since re-encoding changes the filename key.