Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
task_categories:
|
| 4 |
+
- image-to-text
|
| 5 |
+
- other
|
| 6 |
+
tags:
|
| 7 |
+
- image-text
|
| 8 |
+
- deduplication
|
| 9 |
+
- perceptual-hash
|
| 10 |
+
- clip
|
| 11 |
+
- webdataset
|
| 12 |
+
- synthetic
|
| 13 |
+
size_categories:
|
| 14 |
+
- n<1K
|
| 15 |
+
pretty_name: Parallel Image-Text Dataset Builder (sample shard)
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# parallel-image-text-dataset-builder (sample)
|
| 19 |
+
|
| 20 |
+
A small representative sample from the
|
| 21 |
+
[parallel-image-text-dataset-builder](https://github.com/narinzar/parallel-image-text-dataset-builder)
|
| 22 |
+
pipeline: it ingests image-text pairs, removes near-duplicates with
|
| 23 |
+
perceptual-hash (dhash) LSH-style bucketing, filters weak pairs by CLIP
|
| 24 |
+
image-text similarity, and writes fixed-size WebDataset-style tar shards.
|
| 25 |
+
|
| 26 |
+
## Contents
|
| 27 |
+
|
| 28 |
+
- `shard-00002.tar` - one WebDataset-style shard (536 samples). Each sample is
|
| 29 |
+
two members sharing a key: `{key}.jpg` (image) and `{key}.txt` (caption).
|
| 30 |
+
- `stats.json` - machine-readable statistics from the full run that produced this
|
| 31 |
+
sample.
|
| 32 |
+
|
| 33 |
+
## Generation method
|
| 34 |
+
|
| 35 |
+
Fully synthetic. Base images are procedural RGB patterns built from a sum of
|
| 36 |
+
random low-frequency plane waves plus a bright blob and a per-image color tint,
|
| 37 |
+
so each base image has a distinctive perceptual hash while a planted
|
| 38 |
+
resize + JPEG-recompress copy hashes close to it. Captions are templated
|
| 39 |
+
(`a {color} {shape} over a {scene}`) and only loosely tied to the abstract
|
| 40 |
+
images, so absolute CLIP scores are low by construction.
|
| 41 |
+
|
| 42 |
+
The published shard is the output of the full pipeline:
|
| 43 |
+
|
| 44 |
+
1. Perceptual hashing (dhash, 9x8 grid, 64-bit) over all inputs.
|
| 45 |
+
2. Near-duplicate removal via banded LSH bucketing + union-find (5-bit hamming
|
| 46 |
+
threshold, 8 bands).
|
| 47 |
+
3. CLIP image-text similarity filtering (open_clip `ViT-B-32`
|
| 48 |
+
`laion2b_s34b_b79k`) at score threshold 0.10.
|
| 49 |
+
4. Fixed-size tar sharding (1000 samples/shard).
|
| 50 |
+
|
| 51 |
+
## Run this sample came from
|
| 52 |
+
|
| 53 |
+
Measured on a single NVIDIA RTX 5090 (24 GB). Input: 3840 synthetic pairs
|
| 54 |
+
(3000 unique base images + 840 planted near-duplicates).
|
| 55 |
+
|
| 56 |
+
| stage | value |
|
| 57 |
+
| ----- | ----- |
|
| 58 |
+
| input pairs | 3840 |
|
| 59 |
+
| after dedup | 3000 (removed 840: 637 exact, 203 near) |
|
| 60 |
+
| dedup rate | 0.2188 (equals the planted duplicate fraction) |
|
| 61 |
+
| after CLIP filter (threshold 0.10) | 2536 |
|
| 62 |
+
| shards written | 3 (this repo ships shard 2, 536 samples) |
|
| 63 |
+
| band pairs checked | 556,812 vs 7,370,880 all-pairs |
|
| 64 |
+
|
| 65 |
+
This is a small-scale run that exercises the full path end to end; the numbers
|
| 66 |
+
are real measurements, not a large-corpus benchmark.
|
| 67 |
+
|
| 68 |
+
## Reading a shard
|
| 69 |
+
|
| 70 |
+
```python
|
| 71 |
+
import tarfile
|
| 72 |
+
|
| 73 |
+
with tarfile.open("shard-00002.tar") as tar:
|
| 74 |
+
jpgs = [n for n in tar.getnames() if n.endswith(".jpg")]
|
| 75 |
+
print(len(jpgs), "images")
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
## License
|
| 79 |
+
|
| 80 |
+
MIT.
|