Datasets:
Publish ICW as verified WebDataset shards
Browse filesReplace the image-folder upload with 26 identity-preserving TAR shards and reproducibility metadata.
- .gitignore +0 -6
- README.md +139 -109
- check_integrity.py +0 -302
- data/test-00000.tar +3 -0
- data/train-00000.tar +3 -0
- data/train-00001.tar +3 -0
- data/train-00002.tar +3 -0
- data/train-00003.tar +3 -0
- data/train-00004.tar +3 -0
- data/train-00005.tar +3 -0
- data/train-00006.tar +3 -0
- data/train-00007.tar +3 -0
- data/train-00008.tar +3 -0
- data/train-00009.tar +3 -0
- data/train-00010.tar +3 -0
- data/train-00011.tar +3 -0
- data/train-00012.tar +3 -0
- data/train-00013.tar +3 -0
- data/train-00014.tar +3 -0
- data/train-00015.tar +3 -0
- data/train-00016.tar +3 -0
- data/train-00017.tar +3 -0
- data/train-00018.tar +3 -0
- data/train-00019.tar +3 -0
- data/train-00020.tar +3 -0
- data/train-00021.tar +3 -0
- data/train-00022.tar +3 -0
- data/train-00023.tar +3 -0
- data/validation-00000.tar +3 -0
- extract_to_imagefolder.py +54 -0
- manifest.json +285 -0
- splits.csv +0 -0
- verify_webdataset.py +109 -0
.gitignore
DELETED
|
@@ -1,6 +0,0 @@
|
|
| 1 |
-
.DS_Store
|
| 2 |
-
**/.DS_Store
|
| 3 |
-
__pycache__/
|
| 4 |
-
**/__pycache__/
|
| 5 |
-
*.py[cod]
|
| 6 |
-
.cache/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
README.md
CHANGED
|
@@ -9,6 +9,7 @@ language:
|
|
| 9 |
tags:
|
| 10 |
- image
|
| 11 |
- datasets
|
|
|
|
| 12 |
- computer-vision
|
| 13 |
- image-retrieval
|
| 14 |
- animal-re-identification
|
|
@@ -17,6 +18,15 @@ tags:
|
|
| 17 |
pretty_name: Individual Cats in the Wild
|
| 18 |
size_categories:
|
| 19 |
- 10K<n<100K
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
---
|
| 21 |
|
| 22 |
# Individual Cats in the Wild (ICW)
|
|
@@ -29,7 +39,7 @@ fine-grained recognition and image retrieval research.
|
|
| 29 |
ICW accompanies the MeowID project:
|
| 30 |
|
| 31 |
> **MeowID: A Dual-Expert Retrieval System for Individual Cat Identification**
|
| 32 |
-
>
|
| 33 |
> Zhangchi Hu, Yi Shang, Haocheng Yang, Qiwei Hu, and Yuzheng Li (2026)
|
| 34 |
|
| 35 |
- Project repository: https://github.com/RicePasteM/MeowID
|
|
@@ -37,34 +47,127 @@ ICW accompanies the MeowID project:
|
|
| 37 |
|
| 38 |
## Dataset structure
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
```text
|
| 41 |
-
|
| 42 |
-
├──
|
| 43 |
-
│
|
| 44 |
-
│
|
| 45 |
-
├──
|
| 46 |
-
│
|
| 47 |
-
│
|
| 48 |
-
├── test/
|
| 49 |
-
│ └── <cat_id>/
|
| 50 |
-
│ └── <image_id>.jpg
|
| 51 |
├── cats.csv
|
| 52 |
├── metadata.csv
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
```
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
## Construction
|
| 70 |
|
|
@@ -79,8 +182,6 @@ The release was built through the following stages:
|
|
| 79 |
5. Identities were assigned to mutually exclusive train, validation, and test
|
| 80 |
splits.
|
| 81 |
|
| 82 |
-
The identity distribution by source is:
|
| 83 |
-
|
| 84 |
| Source | Identities |
|
| 85 |
| --- | ---: |
|
| 86 |
| PetFinder 2026 | 16,785 |
|
|
@@ -93,79 +194,16 @@ The identity distribution by source is:
|
|
| 93 |
Source names describe provenance, not endorsement of this dataset or its
|
| 94 |
authors.
|
| 95 |
|
| 96 |
-
## Metadata
|
| 97 |
-
|
| 98 |
-
Both CSV files are UTF-8 encoded with a byte-order mark. Use
|
| 99 |
-
`encoding="utf-8-sig"` when reading them directly.
|
| 100 |
-
|
| 101 |
-
### `cats.csv`
|
| 102 |
-
|
| 103 |
-
One row per identity:
|
| 104 |
-
|
| 105 |
-
| Field | Description |
|
| 106 |
-
| --- | --- |
|
| 107 |
-
| `cat_folder` | Eight-digit identity directory name |
|
| 108 |
-
| `source`, `source_name` | Source platform identifiers |
|
| 109 |
-
| `animal_id` | Source-side animal/listing identifier |
|
| 110 |
-
| `name`, `breed`, `gender` | Attributes reported by the source listing |
|
| 111 |
-
| `referer_url` | Original public profile URL |
|
| 112 |
-
| `metadata_json` | Preserved source and curation metadata |
|
| 113 |
-
|
| 114 |
-
### `metadata.csv`
|
| 115 |
-
|
| 116 |
-
One row per image:
|
| 117 |
-
|
| 118 |
-
| Field | Description |
|
| 119 |
-
| --- | --- |
|
| 120 |
-
| `cat_folder`, `image_filename` | Path key for the local JPEG |
|
| 121 |
-
| `source`, `source_name`, `animal_id` | Source provenance |
|
| 122 |
-
| `name`, `breed`, `gender` | Source-reported attributes |
|
| 123 |
-
| `image_url`, `referer_url` | Original image and profile URLs |
|
| 124 |
-
| `norm_x`, `norm_y`, `norm_w`, `norm_h` | Normalized crop bounding box |
|
| 125 |
-
| `assignment_id` | Internal curation assignment identifier |
|
| 126 |
-
| `metadata_json` | Preserved source and curation metadata |
|
| 127 |
-
|
| 128 |
-
Source-reported fields may be incomplete, outdated, or inaccurate and should
|
| 129 |
-
not be treated as verified biological labels.
|
| 130 |
-
|
| 131 |
-
## Loading the images
|
| 132 |
-
|
| 133 |
-
The directory layout is compatible with common image-folder loaders. With
|
| 134 |
-
Hugging Face Datasets:
|
| 135 |
-
|
| 136 |
-
```python
|
| 137 |
-
from datasets import load_dataset
|
| 138 |
-
|
| 139 |
-
dataset = load_dataset(
|
| 140 |
-
"imagefolder",
|
| 141 |
-
data_dir="/path/to/icw_split",
|
| 142 |
-
drop_metadata=True,
|
| 143 |
-
drop_labels=False,
|
| 144 |
-
)
|
| 145 |
-
print(dataset)
|
| 146 |
-
```
|
| 147 |
-
|
| 148 |
-
The explicit `drop_metadata=True` is required because the root-level
|
| 149 |
-
`metadata.csv` is ICW's provenance table rather than an ImageFolder metadata
|
| 150 |
-
file with a `file_name` column. `drop_labels=False` keeps the identity inferred
|
| 151 |
-
from each directory name.
|
| 152 |
-
|
| 153 |
-
For identity retrieval, use directory names as identity labels and preserve the
|
| 154 |
-
provided split boundaries. Do not merge identities across splits.
|
| 155 |
-
|
| 156 |
## Intended uses
|
| 157 |
|
| 158 |
-
ICW is intended for non-commercial research and evaluation involving
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
- route-aware face and whole-animal recognition;
|
| 163 |
-
- representation learning under changes in pose, viewpoint, lighting,
|
| 164 |
-
background, camera, and occlusion.
|
| 165 |
|
| 166 |
The dataset is not intended for identifying people, inferring pet ownership,
|
| 167 |
-
contacting source organizations or individuals, making automated
|
| 168 |
-
decisions, or
|
| 169 |
|
| 170 |
## Limitations and responsible use
|
| 171 |
|
|
@@ -173,7 +211,6 @@ decisions, or any commercial deployment.
|
|
| 173 |
sample of the global cat population.
|
| 174 |
- Geographic, platform, breed, age, health, photographic, and curation biases
|
| 175 |
may affect model behavior.
|
| 176 |
-
- Some identities have substantially more observations than others.
|
| 177 |
- Listings and URLs can become outdated after collection.
|
| 178 |
- Free-text source metadata can contain contact details or other incidental
|
| 179 |
information. Do not use it to identify, profile, or contact people.
|
|
@@ -185,26 +222,21 @@ requirements in their jurisdiction and application.
|
|
| 185 |
|
| 186 |
## Data quality
|
| 187 |
|
| 188 |
-
The
|
| 189 |
-
identity disjointness, JPEG signatures, per-identity image counts, and bounding
|
| 190 |
-
box ranges.
|
| 191 |
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
- 19,877 unique identity directories;
|
| 195 |
-
- 82,791 corresponding metadata rows and JPEG files;
|
| 196 |
- no identity overlap between train, validation, and test;
|
| 197 |
-
- no
|
| 198 |
-
-
|
|
|
|
|
|
|
| 199 |
|
| 200 |
## Licensing and source rights
|
| 201 |
|
| 202 |
The dataset-specific selection, identity organization, split assignments,
|
| 203 |
curation annotations, and original documentation contributed by the MeowID
|
| 204 |
-
authors are licensed under the **Creative Commons
|
| 205 |
-
|
| 206 |
-
[`LICENSE`](LICENSE) and the
|
| 207 |
-
[Creative Commons license page](https://creativecommons.org/licenses/by-nc/4.0/).
|
| 208 |
|
| 209 |
This license applies only to material for which the MeowID authors hold the
|
| 210 |
necessary rights. **Third-party photographs, source listing text, trademarks,
|
|
@@ -219,8 +251,6 @@ only the minimum path or source identifier needed to locate the record.
|
|
| 219 |
|
| 220 |
## Citation
|
| 221 |
|
| 222 |
-
If you use ICW or MeowID in academic work, please cite:
|
| 223 |
-
|
| 224 |
```bibtex
|
| 225 |
@article{hu2026meowid,
|
| 226 |
title = {MeowID: A Dual-Expert Retrieval System for Individual Cat Identification},
|
|
|
|
| 9 |
tags:
|
| 10 |
- image
|
| 11 |
- datasets
|
| 12 |
+
- webdataset
|
| 13 |
- computer-vision
|
| 14 |
- image-retrieval
|
| 15 |
- animal-re-identification
|
|
|
|
| 18 |
pretty_name: Individual Cats in the Wild
|
| 19 |
size_categories:
|
| 20 |
- 10K<n<100K
|
| 21 |
+
configs:
|
| 22 |
+
- config_name: default
|
| 23 |
+
data_files:
|
| 24 |
+
- split: train
|
| 25 |
+
path: data/train-*.tar
|
| 26 |
+
- split: validation
|
| 27 |
+
path: data/validation-*.tar
|
| 28 |
+
- split: test
|
| 29 |
+
path: data/test-*.tar
|
| 30 |
---
|
| 31 |
|
| 32 |
# Individual Cats in the Wild (ICW)
|
|
|
|
| 39 |
ICW accompanies the MeowID project:
|
| 40 |
|
| 41 |
> **MeowID: A Dual-Expert Retrieval System for Individual Cat Identification**
|
| 42 |
+
>
|
| 43 |
> Zhangchi Hu, Yi Shang, Haocheng Yang, Qiwei Hu, and Yuzheng Li (2026)
|
| 44 |
|
| 45 |
- Project repository: https://github.com/RicePasteM/MeowID
|
|
|
|
| 47 |
|
| 48 |
## Dataset structure
|
| 49 |
|
| 50 |
+
The release uses identity-preserving [WebDataset](https://github.com/webdataset/webdataset)
|
| 51 |
+
TAR shards. Shards target approximately 1 GiB, and all images of one identity
|
| 52 |
+
remain in the same shard.
|
| 53 |
+
|
| 54 |
```text
|
| 55 |
+
ICW/
|
| 56 |
+
├── data/
|
| 57 |
+
│ ├── train-00000.tar
|
| 58 |
+
│ ├── ...
|
| 59 |
+
│ ├── train-00023.tar
|
| 60 |
+
│ ├── validation-00000.tar
|
| 61 |
+
│ └── test-00000.tar
|
|
|
|
|
|
|
|
|
|
| 62 |
├── cats.csv
|
| 63 |
├── metadata.csv
|
| 64 |
+
├── splits.csv
|
| 65 |
+
├── manifest.json
|
| 66 |
+
├── verify_webdataset.py
|
| 67 |
+
└── extract_to_imagefolder.py
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
| Split | Identities | Images | Shards | Images per identity |
|
| 71 |
+
| --- | ---: | ---: | ---: | ---: |
|
| 72 |
+
| Train | 18,877 | 77,094 | 24 | 3–19 (mean 4.08) |
|
| 73 |
+
| Validation | 500 | 2,851 | 1 | 5–14 (mean 5.70) |
|
| 74 |
+
| Test | 500 | 2,846 | 1 | 5–17 (mean 5.69) |
|
| 75 |
+
| **Total** | **19,877** | **82,791** | **26** | **3–19 (mean 4.17)** |
|
| 76 |
+
|
| 77 |
+
Identity sets are strictly disjoint across the three splits.
|
| 78 |
+
|
| 79 |
+
## Sample format
|
| 80 |
+
|
| 81 |
+
Each WebDataset example contains adjacent members with the same key:
|
| 82 |
+
|
| 83 |
+
```text
|
| 84 |
+
00001234_000001.jpg
|
| 85 |
+
00001234_000001.json
|
| 86 |
```
|
| 87 |
|
| 88 |
+
The JSON member contains the identity, split, original path, normalized crop
|
| 89 |
+
box, source provenance, and the corresponding row from `metadata.csv`.
|
| 90 |
+
`identity_id` is the benchmark label; `image_id` identifies an observation of
|
| 91 |
+
that individual.
|
| 92 |
+
|
| 93 |
+
## Loading
|
| 94 |
+
|
| 95 |
+
Install the vision dependencies:
|
| 96 |
+
|
| 97 |
+
```bash
|
| 98 |
+
pip install "datasets[vision]"
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
The dataset card defines all three splits, so it can be streamed directly:
|
| 102 |
+
|
| 103 |
+
```python
|
| 104 |
+
from datasets import load_dataset
|
| 105 |
+
|
| 106 |
+
dataset = load_dataset("RicePasteM/ICW", streaming=True)
|
| 107 |
+
sample = next(iter(dataset["train"]))
|
| 108 |
+
|
| 109 |
+
image = sample["jpg"]
|
| 110 |
+
metadata = sample["json"]
|
| 111 |
+
identity_id = metadata["identity_id"]
|
| 112 |
+
```
|
| 113 |
|
| 114 |
+
An explicit WebDataset configuration is also possible:
|
| 115 |
+
|
| 116 |
+
```python
|
| 117 |
+
from datasets import load_dataset
|
| 118 |
+
|
| 119 |
+
files = {
|
| 120 |
+
"train": "hf://datasets/RicePasteM/ICW/data/train-*.tar",
|
| 121 |
+
"validation": "hf://datasets/RicePasteM/ICW/data/validation-*.tar",
|
| 122 |
+
"test": "hf://datasets/RicePasteM/ICW/data/test-*.tar",
|
| 123 |
+
}
|
| 124 |
+
dataset = load_dataset("webdataset", data_files=files, streaming=True)
|
| 125 |
+
```
|
| 126 |
+
|
| 127 |
+
To restore the conventional image-folder layout:
|
| 128 |
+
|
| 129 |
+
```bash
|
| 130 |
+
python extract_to_imagefolder.py /path/to/ICW /path/to/icw_imagefolder
|
| 131 |
+
```
|
| 132 |
+
|
| 133 |
+
This produces `train/<identity>/<image>.jpg`,
|
| 134 |
+
`validation/<identity>/<image>.jpg`, and `test/<identity>/<image>.jpg`.
|
| 135 |
+
|
| 136 |
+
## Metadata
|
| 137 |
+
|
| 138 |
+
All tables are UTF-8 encoded. The original `cats.csv` and `metadata.csv` use a
|
| 139 |
+
UTF-8 byte-order mark, so pass `encoding="utf-8-sig"` when reading them.
|
| 140 |
+
|
| 141 |
+
### `cats.csv`
|
| 142 |
+
|
| 143 |
+
One row per identity. It includes the eight-digit `cat_folder` label, source
|
| 144 |
+
platform, source-side animal identifier, source-reported attributes, profile
|
| 145 |
+
URL, and preserved source metadata.
|
| 146 |
+
|
| 147 |
+
### `metadata.csv`
|
| 148 |
|
| 149 |
+
One row per image. It includes `cat_folder`, `image_filename`, source
|
| 150 |
+
provenance, source-reported attributes, original URLs, normalized crop box,
|
| 151 |
+
curation assignment, and preserved source metadata.
|
| 152 |
+
|
| 153 |
+
### `splits.csv`
|
| 154 |
+
|
| 155 |
+
One row per identity with its split, image count, and containing shard. This
|
| 156 |
+
table is the fastest way to map an identity to a TAR file without scanning the
|
| 157 |
+
archives.
|
| 158 |
+
|
| 159 |
+
### `manifest.json`
|
| 160 |
+
|
| 161 |
+
The release manifest records sample and identity counts, byte sizes, SHA-256
|
| 162 |
+
checksums, and key ranges for every shard. Run the included verifier after a
|
| 163 |
+
download:
|
| 164 |
+
|
| 165 |
+
```bash
|
| 166 |
+
python verify_webdataset.py /path/to/ICW
|
| 167 |
+
```
|
| 168 |
+
|
| 169 |
+
Source-reported fields may be incomplete, outdated, or inaccurate and should
|
| 170 |
+
not be treated as verified biological labels.
|
| 171 |
|
| 172 |
## Construction
|
| 173 |
|
|
|
|
| 182 |
5. Identities were assigned to mutually exclusive train, validation, and test
|
| 183 |
splits.
|
| 184 |
|
|
|
|
|
|
|
| 185 |
| Source | Identities |
|
| 186 |
| --- | ---: |
|
| 187 |
| PetFinder 2026 | 16,785 |
|
|
|
|
| 194 |
Source names describe provenance, not endorsement of this dataset or its
|
| 195 |
authors.
|
| 196 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
## Intended uses
|
| 198 |
|
| 199 |
+
ICW is intended for non-commercial research and evaluation involving
|
| 200 |
+
individual animal identification, fine-grained image retrieval, route-aware
|
| 201 |
+
face and whole-animal recognition, and representation learning under changes
|
| 202 |
+
in pose, viewpoint, lighting, background, camera, and occlusion.
|
|
|
|
|
|
|
|
|
|
| 203 |
|
| 204 |
The dataset is not intended for identifying people, inferring pet ownership,
|
| 205 |
+
contacting source organizations or individuals, making automated
|
| 206 |
+
animal-welfare decisions, or commercial deployment.
|
| 207 |
|
| 208 |
## Limitations and responsible use
|
| 209 |
|
|
|
|
| 211 |
sample of the global cat population.
|
| 212 |
- Geographic, platform, breed, age, health, photographic, and curation biases
|
| 213 |
may affect model behavior.
|
|
|
|
| 214 |
- Listings and URLs can become outdated after collection.
|
| 215 |
- Free-text source metadata can contain contact details or other incidental
|
| 216 |
information. Do not use it to identify, profile, or contact people.
|
|
|
|
| 222 |
|
| 223 |
## Data quality
|
| 224 |
|
| 225 |
+
The release was validated on 17 August 2026:
|
|
|
|
|
|
|
| 226 |
|
| 227 |
+
- 19,877 identities and 82,791 paired JPEG/JSON examples;
|
|
|
|
|
|
|
|
|
|
| 228 |
- no identity overlap between train, validation, and test;
|
| 229 |
+
- no identity split across multiple shards;
|
| 230 |
+
- deterministic member ordering and valid sidecar JSON;
|
| 231 |
+
- byte sizes and SHA-256 checksums verified for all 26 shards;
|
| 232 |
+
- all original metadata rows matched to exactly one image.
|
| 233 |
|
| 234 |
## Licensing and source rights
|
| 235 |
|
| 236 |
The dataset-specific selection, identity organization, split assignments,
|
| 237 |
curation annotations, and original documentation contributed by the MeowID
|
| 238 |
+
authors are licensed under the **Creative Commons Attribution-NonCommercial
|
| 239 |
+
4.0 International license (CC BY-NC 4.0)**. See [`LICENSE`](LICENSE).
|
|
|
|
|
|
|
| 240 |
|
| 241 |
This license applies only to material for which the MeowID authors hold the
|
| 242 |
necessary rights. **Third-party photographs, source listing text, trademarks,
|
|
|
|
| 251 |
|
| 252 |
## Citation
|
| 253 |
|
|
|
|
|
|
|
| 254 |
```bibtex
|
| 255 |
@article{hu2026meowid,
|
| 256 |
title = {MeowID: A Dual-Expert Retrieval System for Individual Cat Identification},
|
check_integrity.py
DELETED
|
@@ -1,302 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python3
|
| 2 |
-
"""Check integrity of icw_split dataset."""
|
| 3 |
-
|
| 4 |
-
import csv
|
| 5 |
-
import json
|
| 6 |
-
import os
|
| 7 |
-
from collections import defaultdict
|
| 8 |
-
from pathlib import Path
|
| 9 |
-
|
| 10 |
-
BASE = Path(__file__).resolve().parent
|
| 11 |
-
SPLITS = ["train", "val", "test"]
|
| 12 |
-
|
| 13 |
-
print("=" * 60)
|
| 14 |
-
print("DATASET INTEGRITY CHECK")
|
| 15 |
-
print("=" * 60)
|
| 16 |
-
|
| 17 |
-
# ── 1. Gather actual directories and files ───────────────────────────
|
| 18 |
-
actual_dirs_by_split = {}
|
| 19 |
-
actual_images_by_split = {}
|
| 20 |
-
all_actual_dirs = set()
|
| 21 |
-
all_actual_images = {}
|
| 22 |
-
total_images = 0
|
| 23 |
-
|
| 24 |
-
for split in SPLITS:
|
| 25 |
-
split_path = BASE / split
|
| 26 |
-
dirs = set()
|
| 27 |
-
images = {}
|
| 28 |
-
for d in sorted(split_path.iterdir()):
|
| 29 |
-
if d.is_dir():
|
| 30 |
-
dirs.add(d.name)
|
| 31 |
-
imgs = sorted(f.name for f in d.iterdir() if f.is_file() and f.suffix.lower() == ".jpg")
|
| 32 |
-
images[d.name] = imgs
|
| 33 |
-
for img in imgs:
|
| 34 |
-
all_actual_images[(d.name, img)] = split
|
| 35 |
-
total_images += len(imgs)
|
| 36 |
-
actual_dirs_by_split[split] = dirs
|
| 37 |
-
actual_images_by_split[split] = images
|
| 38 |
-
all_actual_dirs.update(dirs)
|
| 39 |
-
|
| 40 |
-
# Also check for non-.jpg files
|
| 41 |
-
non_jpg = []
|
| 42 |
-
for split in SPLITS:
|
| 43 |
-
for d in (BASE / split).iterdir():
|
| 44 |
-
if d.is_dir():
|
| 45 |
-
for f in d.iterdir():
|
| 46 |
-
if f.is_file() and f.suffix.lower() != ".jpg":
|
| 47 |
-
non_jpg.append(str(f.relative_to(BASE)))
|
| 48 |
-
|
| 49 |
-
print(f"\nActual directories: train={len(actual_dirs_by_split['train'])}, "
|
| 50 |
-
f"val={len(actual_dirs_by_split['val'])}, "
|
| 51 |
-
f"test={len(actual_dirs_by_split['test'])}")
|
| 52 |
-
print(f"Total unique dirs: {len(all_actual_dirs)}")
|
| 53 |
-
print(f"Total images: {total_images}")
|
| 54 |
-
print(f"Non-jpg files: {len(non_jpg)} {' '.join(non_jpg) if non_jpg else '(none)'}")
|
| 55 |
-
|
| 56 |
-
# ── 2. Check cross-split duplication ─────────────────────────────────
|
| 57 |
-
print("\n── Cross-split duplication ──")
|
| 58 |
-
train_set = set(actual_dirs_by_split["train"])
|
| 59 |
-
val_set = set(actual_dirs_by_split["val"])
|
| 60 |
-
test_set = set(actual_dirs_by_split["test"])
|
| 61 |
-
|
| 62 |
-
tv_overlap = train_set & val_set
|
| 63 |
-
tt_overlap = train_set & test_set
|
| 64 |
-
vt_overlap = val_set & test_set
|
| 65 |
-
|
| 66 |
-
if tv_overlap:
|
| 67 |
-
print(f"WARNING: train ∩ val = {len(tv_overlap)} cats: {sorted(tv_overlap)[:20]}...")
|
| 68 |
-
if tt_overlap:
|
| 69 |
-
print(f"WARNING: train ∩ test = {len(tt_overlap)} cats: {sorted(tt_overlap)[:20]}...")
|
| 70 |
-
if vt_overlap:
|
| 71 |
-
print(f"WARNING: val ∩ test = {len(vt_overlap)} cats: {sorted(vt_overlap)[:20]}...")
|
| 72 |
-
if not tv_overlap and not tt_overlap and not vt_overlap:
|
| 73 |
-
print("OK - no cross-split duplication")
|
| 74 |
-
|
| 75 |
-
# ── 3. Parse cats.csv ─────────────────────────────────────────────────
|
| 76 |
-
print("\n── cats.csv ──")
|
| 77 |
-
cats_csv_path = BASE / "cats.csv"
|
| 78 |
-
cats_csv_cats = set()
|
| 79 |
-
cats_csv_rows = 0
|
| 80 |
-
cats_csv_malformed = 0
|
| 81 |
-
cats_csv_extra_cols = []
|
| 82 |
-
cats_expected_cols = 9
|
| 83 |
-
|
| 84 |
-
with open(cats_csv_path, "r", encoding="utf-8-sig") as f:
|
| 85 |
-
# Try csv module first
|
| 86 |
-
reader = csv.reader(f)
|
| 87 |
-
header = next(reader)
|
| 88 |
-
expected_header = ["cat_folder","source","source_name","animal_id","name","breed","gender","referer_url","metadata_json"]
|
| 89 |
-
if header != expected_header:
|
| 90 |
-
print(f"WARNING: cats.csv header mismatch")
|
| 91 |
-
print(f" Expected: {expected_header}")
|
| 92 |
-
print(f" Got: {header}")
|
| 93 |
-
|
| 94 |
-
for i, row in enumerate(reader, start=1):
|
| 95 |
-
if len(row) != cats_expected_cols:
|
| 96 |
-
cats_csv_malformed += 1
|
| 97 |
-
cats_csv_extra_cols.append((i, len(row)))
|
| 98 |
-
continue
|
| 99 |
-
cats_csv_cats.add(row[0]) # cat_folder
|
| 100 |
-
cats_csv_rows += 1
|
| 101 |
-
|
| 102 |
-
print(f"Total rows (well-formed): {cats_csv_rows}")
|
| 103 |
-
print(f"Malformed rows (wrong col count): {cats_csv_malformed}")
|
| 104 |
-
if cats_csv_malformed:
|
| 105 |
-
print(f" First 10: {cats_csv_extra_cols[:10]}")
|
| 106 |
-
print(f"Unique cat_folders: {len(cats_csv_cats)}")
|
| 107 |
-
|
| 108 |
-
# ── 3b. Check cats.csv vs actual directories ─────────────────────────
|
| 109 |
-
print("\n── cats.csv vs actual dirs ──")
|
| 110 |
-
dirs_not_in_csv = all_actual_dirs - cats_csv_cats
|
| 111 |
-
csv_not_in_dirs = cats_csv_cats - all_actual_dirs
|
| 112 |
-
|
| 113 |
-
if dirs_not_in_csv:
|
| 114 |
-
print(f"WARNING: {len(dirs_not_in_csv)} dir(s) exist but NOT in cats.csv:")
|
| 115 |
-
for d in sorted(dirs_not_in_csv)[:30]:
|
| 116 |
-
split = [s for s in SPLITS if d in actual_dirs_by_split[s]][0]
|
| 117 |
-
print(f" {d} (in {split})")
|
| 118 |
-
else:
|
| 119 |
-
print("OK - all actual dirs found in cats.csv")
|
| 120 |
-
|
| 121 |
-
if csv_not_in_dirs:
|
| 122 |
-
print(f"WARNING: {len(csv_not_in_dirs)} cat(s) in cats.csv but no directory:")
|
| 123 |
-
for d in sorted(csv_not_in_dirs)[:30]:
|
| 124 |
-
print(f" {d}")
|
| 125 |
-
else:
|
| 126 |
-
print("OK - all cats.csv entries have corresponding dirs")
|
| 127 |
-
|
| 128 |
-
# ── 4. Parse metadata.csv ────────────────────────────────────────────
|
| 129 |
-
print("\n── metadata.csv ──")
|
| 130 |
-
meta_csv_path = BASE / "metadata.csv"
|
| 131 |
-
meta_csv_entries = set() # (cat_folder, image_filename)
|
| 132 |
-
meta_csv_rows = 0
|
| 133 |
-
meta_csv_malformed = 0
|
| 134 |
-
meta_csv_extra_cols = []
|
| 135 |
-
meta_expected_cols = 16
|
| 136 |
-
meta_cat_image_counts = defaultdict(int)
|
| 137 |
-
|
| 138 |
-
with open(meta_csv_path, "r", encoding="utf-8-sig") as f:
|
| 139 |
-
reader = csv.reader(f)
|
| 140 |
-
header = next(reader)
|
| 141 |
-
expected_meta_header = [
|
| 142 |
-
"cat_folder","image_filename","source","source_name","animal_id",
|
| 143 |
-
"name","breed","gender","image_url","referer_url",
|
| 144 |
-
"norm_x","norm_y","norm_w","norm_h","assignment_id","metadata_json"
|
| 145 |
-
]
|
| 146 |
-
if header != expected_meta_header:
|
| 147 |
-
print(f"WARNING: metadata.csv header mismatch")
|
| 148 |
-
diff = [(i, a, b) for i, (a, b) in enumerate(zip(header, expected_meta_header)) if a != b]
|
| 149 |
-
print(f" Differences: {diff}")
|
| 150 |
-
if len(header) != meta_expected_cols:
|
| 151 |
-
print(f"WARNING: header has {len(header)} cols, expected {meta_expected_cols}")
|
| 152 |
-
|
| 153 |
-
for i, row in enumerate(reader, start=1):
|
| 154 |
-
if len(row) != meta_expected_cols:
|
| 155 |
-
meta_csv_malformed += 1
|
| 156 |
-
meta_csv_extra_cols.append((i, len(row)))
|
| 157 |
-
continue
|
| 158 |
-
meta_csv_entries.add((row[0], row[1]))
|
| 159 |
-
meta_cat_image_counts[row[0]] += 1
|
| 160 |
-
meta_csv_rows += 1
|
| 161 |
-
|
| 162 |
-
print(f"Total rows (well-formed): {meta_csv_rows}")
|
| 163 |
-
print(f"Malformed rows (wrong col count): {meta_csv_malformed}")
|
| 164 |
-
if meta_csv_malformed:
|
| 165 |
-
print(f" First 10: {meta_csv_extra_cols[:10]}")
|
| 166 |
-
print(f"Unique (cat_folder, image) pairs: {len(meta_csv_entries)}")
|
| 167 |
-
print(f"Unique cat_folders in metadata: {len(meta_cat_image_counts)}")
|
| 168 |
-
|
| 169 |
-
# ── 5. Check metadata.csv vs actual images ───────────────────────────
|
| 170 |
-
print("\n── metadata.csv vs actual images ──")
|
| 171 |
-
actual_image_set = set(all_actual_images.keys()) # (cat_folder, image_filename)
|
| 172 |
-
|
| 173 |
-
images_not_in_meta = actual_image_set - meta_csv_entries
|
| 174 |
-
meta_not_actual = meta_csv_entries - actual_image_set
|
| 175 |
-
|
| 176 |
-
if images_not_in_meta:
|
| 177 |
-
print(f"WARNING: {len(images_not_in_meta)} image(s) exist on disk but NOT in metadata.csv:")
|
| 178 |
-
for cat, img in sorted(images_not_in_meta)[:30]:
|
| 179 |
-
split = all_actual_images[(cat, img)]
|
| 180 |
-
print(f" {cat}/{img} (in {split})")
|
| 181 |
-
else:
|
| 182 |
-
print("OK - all actual images found in metadata.csv")
|
| 183 |
-
|
| 184 |
-
if meta_not_actual:
|
| 185 |
-
print(f"WARNING: {len(meta_not_actual)} entry(s) in metadata.csv but no file on disk:")
|
| 186 |
-
for cat, img in sorted(meta_not_actual)[:30]:
|
| 187 |
-
print(f" {cat}/{img}")
|
| 188 |
-
else:
|
| 189 |
-
print("OK - all metadata.csv entries have corresponding files")
|
| 190 |
-
|
| 191 |
-
# ── 6. Check image counts match between actual and metadata per cat ──
|
| 192 |
-
print("\n── Image counts per cat: disk vs metadata.csv ──")
|
| 193 |
-
count_mismatches = []
|
| 194 |
-
for cat_id in all_actual_dirs:
|
| 195 |
-
actual_count = 0
|
| 196 |
-
for split in SPLITS:
|
| 197 |
-
if cat_id in actual_images_by_split[split]:
|
| 198 |
-
actual_count = len(actual_images_by_split[split][cat_id])
|
| 199 |
-
break
|
| 200 |
-
meta_count = meta_cat_image_counts.get(cat_id, 0)
|
| 201 |
-
if actual_count != meta_count:
|
| 202 |
-
count_mismatches.append((cat_id, actual_count, meta_count))
|
| 203 |
-
|
| 204 |
-
if count_mismatches:
|
| 205 |
-
print(f"WARNING: {len(count_mismatches)} cat(s) have mismatched image counts:")
|
| 206 |
-
for cat, a, m in sorted(count_mismatches)[:30]:
|
| 207 |
-
print(f" {cat}: disk={a}, metadata={m}")
|
| 208 |
-
else:
|
| 209 |
-
print("OK - all image counts match")
|
| 210 |
-
|
| 211 |
-
# ── 7. Check image file integrity (corrupt JPGs) ─────────────────────
|
| 212 |
-
print("\n── Image file integrity ──")
|
| 213 |
-
corrupt_count = 0
|
| 214 |
-
corrupt_files = []
|
| 215 |
-
empty_files = 0
|
| 216 |
-
|
| 217 |
-
for (cat, img), split in all_actual_images.items():
|
| 218 |
-
fpath = BASE / split / cat / img
|
| 219 |
-
try:
|
| 220 |
-
fsize = fpath.stat().st_size
|
| 221 |
-
if fsize == 0:
|
| 222 |
-
empty_files += 1
|
| 223 |
-
corrupt_files.append(f"{split}/{cat}/{img} (empty)")
|
| 224 |
-
continue
|
| 225 |
-
# Check JPEG magic bytes
|
| 226 |
-
with open(fpath, "rb") as ff:
|
| 227 |
-
magic = ff.read(4)
|
| 228 |
-
if magic[:2] != b'\xff\xd8':
|
| 229 |
-
corrupt_count += 1
|
| 230 |
-
corrupt_files.append(f"{split}/{cat}/{img} (bad magic: {magic.hex()})")
|
| 231 |
-
except Exception as e:
|
| 232 |
-
corrupt_count += 1
|
| 233 |
-
corrupt_files.append(f"{split}/{cat}/{img} (error: {e})")
|
| 234 |
-
|
| 235 |
-
if empty_files > 0:
|
| 236 |
-
print(f"WARNING: {empty_files} empty file(s)")
|
| 237 |
-
if corrupt_count > 0:
|
| 238 |
-
print(f"WARNING: {corrupt_count} corrupt/readable JPG(s)")
|
| 239 |
-
for f in corrupt_files[:30]:
|
| 240 |
-
print(f" {f}")
|
| 241 |
-
else:
|
| 242 |
-
print(f"OK - all {total_images} images pass JPG magic byte check")
|
| 243 |
-
|
| 244 |
-
# ── 8. Spot-check bounding box values ────────────────────────────────
|
| 245 |
-
print("\n── Bounding box sanity check ──")
|
| 246 |
-
bb_out_of_range = 0
|
| 247 |
-
bb_zero_area = 0
|
| 248 |
-
with open(meta_csv_path, "r", encoding="utf-8-sig") as f:
|
| 249 |
-
reader = csv.reader(f)
|
| 250 |
-
next(reader)
|
| 251 |
-
for i, row in enumerate(reader, start=1):
|
| 252 |
-
if len(row) != meta_expected_cols:
|
| 253 |
-
continue
|
| 254 |
-
try:
|
| 255 |
-
nx, ny, nw, nh = float(row[10]), float(row[11]), float(row[12]), float(row[13])
|
| 256 |
-
except ValueError:
|
| 257 |
-
continue
|
| 258 |
-
if not (0 <= nx <= 1 and 0 <= ny <= 1 and 0 <= nw <= 1 and 0 <= nh <= 1):
|
| 259 |
-
bb_out_of_range += 1
|
| 260 |
-
if nw <= 0 or nh <= 0:
|
| 261 |
-
bb_zero_area += 1
|
| 262 |
-
|
| 263 |
-
if bb_out_of_range:
|
| 264 |
-
print(f"WARNING: {bb_out_of_range} rows have bbox values outside [0,1]")
|
| 265 |
-
else:
|
| 266 |
-
print("OK - all bbox values in [0,1] range")
|
| 267 |
-
if bb_zero_area:
|
| 268 |
-
print(f"WARNING: {bb_zero_area} rows have zero-area bbox")
|
| 269 |
-
else:
|
| 270 |
-
print("OK - no zero-area bboxes")
|
| 271 |
-
|
| 272 |
-
# ── 9. Split ratios ─────────────────────────────────────────────────
|
| 273 |
-
print("\n── Split statistics ──")
|
| 274 |
-
for split in SPLITS:
|
| 275 |
-
n_cats = len(actual_dirs_by_split[split])
|
| 276 |
-
n_imgs = sum(len(v) for v in actual_images_by_split[split].values())
|
| 277 |
-
print(f" {split:6s}: {n_cats:>6} cats, {n_imgs:>6} images, "
|
| 278 |
-
f"avg={n_imgs/n_cats:.1f} imgs/cat")
|
| 279 |
-
|
| 280 |
-
# ── 10. Summary ──────────────────────────────────────────────────────
|
| 281 |
-
print("\n" + "=" * 60)
|
| 282 |
-
print("SUMMARY")
|
| 283 |
-
print("=" * 60)
|
| 284 |
-
issues = []
|
| 285 |
-
if cats_csv_malformed: issues.append(f"{cats_csv_malformed} malformed rows in cats.csv")
|
| 286 |
-
if meta_csv_malformed: issues.append(f"{meta_csv_malformed} malformed rows in metadata.csv")
|
| 287 |
-
if dirs_not_in_csv: issues.append(f"{len(dirs_not_in_csv)} dirs missing from cats.csv")
|
| 288 |
-
if csv_not_in_dirs: issues.append(f"{len(csv_not_in_dirs)} cats.csv entries with no dir")
|
| 289 |
-
if images_not_in_meta: issues.append(f"{len(images_not_in_meta)} images missing from metadata.csv")
|
| 290 |
-
if meta_not_actual: issues.append(f"{len(meta_not_actual)} metadata entries with no file")
|
| 291 |
-
if count_mismatches: issues.append(f"{len(count_mismatches)} cats with mismatched image counts")
|
| 292 |
-
if corrupt_count: issues.append(f"{corrupt_count} corrupt JPGs")
|
| 293 |
-
if empty_files: issues.append(f"{empty_files} empty files")
|
| 294 |
-
if non_jpg: issues.append(f"{len(non_jpg)} non-JPG files")
|
| 295 |
-
if tv_overlap or tt_overlap or vt_overlap: issues.append("cross-split duplication detected")
|
| 296 |
-
|
| 297 |
-
if issues:
|
| 298 |
-
print("ISSUES FOUND:")
|
| 299 |
-
for iss in issues:
|
| 300 |
-
print(f" - {iss}")
|
| 301 |
-
else:
|
| 302 |
-
print("Dataset is clean! No issues found.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data/test-00000.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3ec421df4bc89aa9f3e98c1b88364c64f7bf3b567c320dc9c41fd471ef454107
|
| 3 |
+
size 852213760
|
data/train-00000.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:aa7cf82ae95d605cf48c7b71bf97d0b38ee3ac3b92b26233c1c0b60afed54459
|
| 3 |
+
size 1073192960
|
data/train-00001.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1529b3115d838f7dbe31895b799a9d801bfdbe8ed835ef993b210e52d6c07896
|
| 3 |
+
size 1073397760
|
data/train-00002.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b1a624eb5c75b96235f8dc489674436cde4239cb3d16dcc9824f7b7266ee67e6
|
| 3 |
+
size 1072261120
|
data/train-00003.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:20a660f3d3043e2d52595473804064b5da22ae3ed5637c7c0a2720f0c1c2d75d
|
| 3 |
+
size 1073029120
|
data/train-00004.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c889c9ce9552242eae37b0639968746f37edb6f663eced1d8646a86ce2082291
|
| 3 |
+
size 1072988160
|
data/train-00005.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fda64747b0f9d347c6d6915fefd3aff7d925a173b214c8c9aca1aeee782ee3e2
|
| 3 |
+
size 1070929920
|
data/train-00006.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8014b52a77137cc7bff97912610e721a4088ef000dc608d63b611e39f4d9d0a9
|
| 3 |
+
size 1070141440
|
data/train-00007.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:38db5c73df4aee7de5136211a42c6c35c088e7db3b35d7cbb9f8ab60e8e0116e
|
| 3 |
+
size 1073346560
|
data/train-00008.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:40e7dea7b37a8e047265d5bf75b57b5bcec26775e0d53e488a4ace87e5fff5be
|
| 3 |
+
size 1071462400
|
data/train-00009.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1c56bcdbc9b8c6cd8933008b4d4085056cb66bbc20a7fc781c77be9aa76df7a0
|
| 3 |
+
size 1073592320
|
data/train-00010.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9a863dd6f4430f4410ae701678de4f8185c08a318ef1a49ac70081335e174774
|
| 3 |
+
size 1073387520
|
data/train-00011.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e3dbb9413276f0f9f9b8938efcaca9c2f4b5a00ae859cc7d4421f5f716bfc66e
|
| 3 |
+
size 1072721920
|
data/train-00012.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5f8b114d239d3d43f2ebdc332759aa77f1746f47e1420560b83a7d08b200b154
|
| 3 |
+
size 1070407680
|
data/train-00013.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:db3d75d97a7b791a9bc18cffb8635fcd11a7fa16cd18814191de1442599b4099
|
| 3 |
+
size 1072343040
|
data/train-00014.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a54dc7301069ab628a129cf991c2f96e3e5fd81524eab640d278bde081e4310e
|
| 3 |
+
size 1073633280
|
data/train-00015.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c33a24c55c0f4deba2c38ddc458b76ce1a4d3ee2f95eb237e4622b06ef67a0e5
|
| 3 |
+
size 1070991360
|
data/train-00016.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:562d9afbaf6774d1ba8c50bdabd0cd2c05fbfc510123f8b2c2ebb819d4cb8651
|
| 3 |
+
size 1071759360
|
data/train-00017.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f398809a6cee554f157759002779e2bf4e7bc94d4ffcc4b8d1bfbd2c1ed056b7
|
| 3 |
+
size 1071493120
|
data/train-00018.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ce6a028a69191626625f574da0b6d7561496180f4eeaf13dcf9aae6c50405828
|
| 3 |
+
size 1073223680
|
data/train-00019.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6e5abd80bfb8e91e182d15cf29d8c95bcc0af545d908311d0b8d03113d1706eb
|
| 3 |
+
size 1071411200
|
data/train-00020.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:616f7e756d0251c74cce7ee01367281d8c9c9897d721f25f7077218fba041c44
|
| 3 |
+
size 1073541120
|
data/train-00021.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bcc258cd629037b059efb08e019ac875179b10603413871d843ca8eb7cea922d
|
| 3 |
+
size 1073049600
|
data/train-00022.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5d716ea74aebfdf4bb0549eb9388d837140d23254804575be9c6fdafc95062cb
|
| 3 |
+
size 1073694720
|
data/train-00023.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8405124308caa14143b0107c718f01139c19f3ace0ea74f510b30ebfcd57b707
|
| 3 |
+
size 523161600
|
data/validation-00000.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:526d8252bf81630b886c7de3cbd28d88ed023bc63b9d3fd3ee95a7911ca67b26
|
| 3 |
+
size 820797440
|
extract_to_imagefolder.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Restore ICW WebDataset shards to split/identity/image.jpg folders."""
|
| 3 |
+
|
| 4 |
+
from __future__ import annotations
|
| 5 |
+
|
| 6 |
+
import argparse
|
| 7 |
+
import io
|
| 8 |
+
import json
|
| 9 |
+
import tarfile
|
| 10 |
+
from pathlib import Path
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def main() -> None:
|
| 14 |
+
parser = argparse.ArgumentParser()
|
| 15 |
+
parser.add_argument("release", type=Path)
|
| 16 |
+
parser.add_argument("output", type=Path)
|
| 17 |
+
args = parser.parse_args()
|
| 18 |
+
release = args.release.resolve()
|
| 19 |
+
output = args.output.resolve()
|
| 20 |
+
output.mkdir(parents=True, exist_ok=True)
|
| 21 |
+
|
| 22 |
+
manifest = json.loads((release / "manifest.json").read_text(encoding="utf-8"))
|
| 23 |
+
restored = 0
|
| 24 |
+
for shard in manifest["shards"]:
|
| 25 |
+
pending_key: str | None = None
|
| 26 |
+
pending_image: bytes | None = None
|
| 27 |
+
with tarfile.open(release / shard["path"], "r:") as archive:
|
| 28 |
+
for member in archive:
|
| 29 |
+
extracted = archive.extractfile(member)
|
| 30 |
+
if extracted is None:
|
| 31 |
+
raise RuntimeError(f"Cannot read {member.name}")
|
| 32 |
+
key = Path(member.name).stem
|
| 33 |
+
if member.name.endswith(".jpg"):
|
| 34 |
+
pending_key = key
|
| 35 |
+
pending_image = extracted.read()
|
| 36 |
+
elif member.name.endswith(".json"):
|
| 37 |
+
if pending_key != key or pending_image is None:
|
| 38 |
+
raise RuntimeError(f"Invalid member order near {member.name}")
|
| 39 |
+
metadata = json.load(extracted)
|
| 40 |
+
split = str(metadata["split"])
|
| 41 |
+
identity = str(metadata["identity_id"])
|
| 42 |
+
image_name = str(metadata["image_filename"])
|
| 43 |
+
destination = output / split / identity / image_name
|
| 44 |
+
destination.parent.mkdir(parents=True, exist_ok=True)
|
| 45 |
+
destination.write_bytes(pending_image)
|
| 46 |
+
restored += 1
|
| 47 |
+
pending_key = None
|
| 48 |
+
pending_image = None
|
| 49 |
+
print(f"restored {shard['path']}")
|
| 50 |
+
print(f"complete: {restored} images restored to {output}")
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
if __name__ == "__main__":
|
| 54 |
+
main()
|
manifest.json
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"format": "webdataset",
|
| 3 |
+
"target_shard_size_bytes": 1073741824,
|
| 4 |
+
"total_samples": 82791,
|
| 5 |
+
"total_identities": 19877,
|
| 6 |
+
"splits": {
|
| 7 |
+
"train": {
|
| 8 |
+
"samples": 77094,
|
| 9 |
+
"identities": 18877,
|
| 10 |
+
"shards": 24
|
| 11 |
+
},
|
| 12 |
+
"validation": {
|
| 13 |
+
"samples": 2851,
|
| 14 |
+
"identities": 500,
|
| 15 |
+
"shards": 1
|
| 16 |
+
},
|
| 17 |
+
"test": {
|
| 18 |
+
"samples": 2846,
|
| 19 |
+
"identities": 500,
|
| 20 |
+
"shards": 1
|
| 21 |
+
}
|
| 22 |
+
},
|
| 23 |
+
"shards": [
|
| 24 |
+
{
|
| 25 |
+
"path": "data/train-00000.tar",
|
| 26 |
+
"split": "train",
|
| 27 |
+
"samples": 2924,
|
| 28 |
+
"identities": 751,
|
| 29 |
+
"size_bytes": 1073192960,
|
| 30 |
+
"sha256": "aa7cf82ae95d605cf48c7b71bf97d0b38ee3ac3b92b26233c1c0b60afed54459",
|
| 31 |
+
"first_key": "00000000_000000",
|
| 32 |
+
"last_key": "00000777_000002"
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"path": "data/train-00001.tar",
|
| 36 |
+
"split": "train",
|
| 37 |
+
"samples": 2820,
|
| 38 |
+
"identities": 740,
|
| 39 |
+
"size_bytes": 1073397760,
|
| 40 |
+
"sha256": "1529b3115d838f7dbe31895b799a9d801bfdbe8ed835ef993b210e52d6c07896",
|
| 41 |
+
"first_key": "00000778_000000",
|
| 42 |
+
"last_key": "00001548_000003"
|
| 43 |
+
},
|
| 44 |
+
{
|
| 45 |
+
"path": "data/train-00002.tar",
|
| 46 |
+
"split": "train",
|
| 47 |
+
"samples": 2773,
|
| 48 |
+
"identities": 716,
|
| 49 |
+
"size_bytes": 1072261120,
|
| 50 |
+
"sha256": "b1a624eb5c75b96235f8dc489674436cde4239cb3d16dcc9824f7b7266ee67e6",
|
| 51 |
+
"first_key": "00001549_000000",
|
| 52 |
+
"last_key": "00002295_000004"
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"path": "data/train-00003.tar",
|
| 56 |
+
"split": "train",
|
| 57 |
+
"samples": 2534,
|
| 58 |
+
"identities": 655,
|
| 59 |
+
"size_bytes": 1073029120,
|
| 60 |
+
"sha256": "20a660f3d3043e2d52595473804064b5da22ae3ed5637c7c0a2720f0c1c2d75d",
|
| 61 |
+
"first_key": "00002296_000000",
|
| 62 |
+
"last_key": "00002972_000003"
|
| 63 |
+
},
|
| 64 |
+
{
|
| 65 |
+
"path": "data/train-00004.tar",
|
| 66 |
+
"split": "train",
|
| 67 |
+
"samples": 2857,
|
| 68 |
+
"identities": 738,
|
| 69 |
+
"size_bytes": 1072988160,
|
| 70 |
+
"sha256": "c889c9ce9552242eae37b0639968746f37edb6f663eced1d8646a86ce2082291",
|
| 71 |
+
"first_key": "00002973_000000",
|
| 72 |
+
"last_key": "00003738_000002"
|
| 73 |
+
},
|
| 74 |
+
{
|
| 75 |
+
"path": "data/train-00005.tar",
|
| 76 |
+
"split": "train",
|
| 77 |
+
"samples": 2627,
|
| 78 |
+
"identities": 684,
|
| 79 |
+
"size_bytes": 1070929920,
|
| 80 |
+
"sha256": "fda64747b0f9d347c6d6915fefd3aff7d925a173b214c8c9aca1aeee782ee3e2",
|
| 81 |
+
"first_key": "00003739_000000",
|
| 82 |
+
"last_key": "00004445_000002"
|
| 83 |
+
},
|
| 84 |
+
{
|
| 85 |
+
"path": "data/train-00006.tar",
|
| 86 |
+
"split": "train",
|
| 87 |
+
"samples": 2854,
|
| 88 |
+
"identities": 741,
|
| 89 |
+
"size_bytes": 1070141440,
|
| 90 |
+
"sha256": "8014b52a77137cc7bff97912610e721a4088ef000dc608d63b611e39f4d9d0a9",
|
| 91 |
+
"first_key": "00004446_000000",
|
| 92 |
+
"last_key": "00005206_000004"
|
| 93 |
+
},
|
| 94 |
+
{
|
| 95 |
+
"path": "data/train-00007.tar",
|
| 96 |
+
"split": "train",
|
| 97 |
+
"samples": 2723,
|
| 98 |
+
"identities": 697,
|
| 99 |
+
"size_bytes": 1073346560,
|
| 100 |
+
"sha256": "38db5c73df4aee7de5136211a42c6c35c088e7db3b35d7cbb9f8ab60e8e0116e",
|
| 101 |
+
"first_key": "00005207_000000",
|
| 102 |
+
"last_key": "00005938_000002"
|
| 103 |
+
},
|
| 104 |
+
{
|
| 105 |
+
"path": "data/train-00008.tar",
|
| 106 |
+
"split": "train",
|
| 107 |
+
"samples": 2776,
|
| 108 |
+
"identities": 707,
|
| 109 |
+
"size_bytes": 1071462400,
|
| 110 |
+
"sha256": "40e7dea7b37a8e047265d5bf75b57b5bcec26775e0d53e488a4ace87e5fff5be",
|
| 111 |
+
"first_key": "00005939_000000",
|
| 112 |
+
"last_key": "00006685_000003"
|
| 113 |
+
},
|
| 114 |
+
{
|
| 115 |
+
"path": "data/train-00009.tar",
|
| 116 |
+
"split": "train",
|
| 117 |
+
"samples": 2716,
|
| 118 |
+
"identities": 696,
|
| 119 |
+
"size_bytes": 1073592320,
|
| 120 |
+
"sha256": "1c56bcdbc9b8c6cd8933008b4d4085056cb66bbc20a7fc781c77be9aa76df7a0",
|
| 121 |
+
"first_key": "00006686_000000",
|
| 122 |
+
"last_key": "00007421_000002"
|
| 123 |
+
},
|
| 124 |
+
{
|
| 125 |
+
"path": "data/train-00010.tar",
|
| 126 |
+
"split": "train",
|
| 127 |
+
"samples": 2936,
|
| 128 |
+
"identities": 757,
|
| 129 |
+
"size_bytes": 1073387520,
|
| 130 |
+
"sha256": "9a863dd6f4430f4410ae701678de4f8185c08a318ef1a49ac70081335e174774",
|
| 131 |
+
"first_key": "00007422_000000",
|
| 132 |
+
"last_key": "00008210_000002"
|
| 133 |
+
},
|
| 134 |
+
{
|
| 135 |
+
"path": "data/train-00011.tar",
|
| 136 |
+
"split": "train",
|
| 137 |
+
"samples": 2823,
|
| 138 |
+
"identities": 715,
|
| 139 |
+
"size_bytes": 1072721920,
|
| 140 |
+
"sha256": "e3dbb9413276f0f9f9b8938efcaca9c2f4b5a00ae859cc7d4421f5f716bfc66e",
|
| 141 |
+
"first_key": "00008211_000000",
|
| 142 |
+
"last_key": "00008954_000002"
|
| 143 |
+
},
|
| 144 |
+
{
|
| 145 |
+
"path": "data/train-00012.tar",
|
| 146 |
+
"split": "train",
|
| 147 |
+
"samples": 2820,
|
| 148 |
+
"identities": 722,
|
| 149 |
+
"size_bytes": 1070407680,
|
| 150 |
+
"sha256": "5f8b114d239d3d43f2ebdc332759aa77f1746f47e1420560b83a7d08b200b154",
|
| 151 |
+
"first_key": "00008955_000000",
|
| 152 |
+
"last_key": "00009719_000003"
|
| 153 |
+
},
|
| 154 |
+
{
|
| 155 |
+
"path": "data/train-00013.tar",
|
| 156 |
+
"split": "train",
|
| 157 |
+
"samples": 2786,
|
| 158 |
+
"identities": 700,
|
| 159 |
+
"size_bytes": 1072343040,
|
| 160 |
+
"sha256": "db3d75d97a7b791a9bc18cffb8635fcd11a7fa16cd18814191de1442599b4099",
|
| 161 |
+
"first_key": "00009720_000000",
|
| 162 |
+
"last_key": "00010453_000002"
|
| 163 |
+
},
|
| 164 |
+
{
|
| 165 |
+
"path": "data/train-00014.tar",
|
| 166 |
+
"split": "train",
|
| 167 |
+
"samples": 2586,
|
| 168 |
+
"identities": 661,
|
| 169 |
+
"size_bytes": 1073633280,
|
| 170 |
+
"sha256": "a54dc7301069ab628a129cf991c2f96e3e5fd81524eab640d278bde081e4310e",
|
| 171 |
+
"first_key": "00010454_000000",
|
| 172 |
+
"last_key": "00011141_000004"
|
| 173 |
+
},
|
| 174 |
+
{
|
| 175 |
+
"path": "data/train-00015.tar",
|
| 176 |
+
"split": "train",
|
| 177 |
+
"samples": 2758,
|
| 178 |
+
"identities": 724,
|
| 179 |
+
"size_bytes": 1070991360,
|
| 180 |
+
"sha256": "c33a24c55c0f4deba2c38ddc458b76ce1a4d3ee2f95eb237e4622b06ef67a0e5",
|
| 181 |
+
"first_key": "00011142_000000",
|
| 182 |
+
"last_key": "00011897_000005"
|
| 183 |
+
},
|
| 184 |
+
{
|
| 185 |
+
"path": "data/train-00016.tar",
|
| 186 |
+
"split": "train",
|
| 187 |
+
"samples": 2561,
|
| 188 |
+
"identities": 642,
|
| 189 |
+
"size_bytes": 1071759360,
|
| 190 |
+
"sha256": "562d9afbaf6774d1ba8c50bdabd0cd2c05fbfc510123f8b2c2ebb819d4cb8651",
|
| 191 |
+
"first_key": "00011898_000000",
|
| 192 |
+
"last_key": "00012564_000002"
|
| 193 |
+
},
|
| 194 |
+
{
|
| 195 |
+
"path": "data/train-00017.tar",
|
| 196 |
+
"split": "train",
|
| 197 |
+
"samples": 2894,
|
| 198 |
+
"identities": 744,
|
| 199 |
+
"size_bytes": 1071493120,
|
| 200 |
+
"sha256": "f398809a6cee554f157759002779e2bf4e7bc94d4ffcc4b8d1bfbd2c1ed056b7",
|
| 201 |
+
"first_key": "00012565_000000",
|
| 202 |
+
"last_key": "00013342_000004"
|
| 203 |
+
},
|
| 204 |
+
{
|
| 205 |
+
"path": "data/train-00018.tar",
|
| 206 |
+
"split": "train",
|
| 207 |
+
"samples": 2573,
|
| 208 |
+
"identities": 664,
|
| 209 |
+
"size_bytes": 1073223680,
|
| 210 |
+
"sha256": "ce6a028a69191626625f574da0b6d7561496180f4eeaf13dcf9aae6c50405828",
|
| 211 |
+
"first_key": "00013343_000000",
|
| 212 |
+
"last_key": "00014037_000003"
|
| 213 |
+
},
|
| 214 |
+
{
|
| 215 |
+
"path": "data/train-00019.tar",
|
| 216 |
+
"split": "train",
|
| 217 |
+
"samples": 2746,
|
| 218 |
+
"identities": 699,
|
| 219 |
+
"size_bytes": 1071411200,
|
| 220 |
+
"sha256": "6e5abd80bfb8e91e182d15cf29d8c95bcc0af545d908311d0b8d03113d1706eb",
|
| 221 |
+
"first_key": "00014038_000000",
|
| 222 |
+
"last_key": "00014767_000003"
|
| 223 |
+
},
|
| 224 |
+
{
|
| 225 |
+
"path": "data/train-00020.tar",
|
| 226 |
+
"split": "train",
|
| 227 |
+
"samples": 2774,
|
| 228 |
+
"identities": 692,
|
| 229 |
+
"size_bytes": 1073541120,
|
| 230 |
+
"sha256": "616f7e756d0251c74cce7ee01367281d8c9c9897d721f25f7077218fba041c44",
|
| 231 |
+
"first_key": "00014768_000000",
|
| 232 |
+
"last_key": "00015505_000002"
|
| 233 |
+
},
|
| 234 |
+
{
|
| 235 |
+
"path": "data/train-00021.tar",
|
| 236 |
+
"split": "train",
|
| 237 |
+
"samples": 2719,
|
| 238 |
+
"identities": 697,
|
| 239 |
+
"size_bytes": 1073049600,
|
| 240 |
+
"sha256": "bcc258cd629037b059efb08e019ac875179b10603413871d843ca8eb7cea922d",
|
| 241 |
+
"first_key": "00015506_000000",
|
| 242 |
+
"last_key": "00016252_000002"
|
| 243 |
+
},
|
| 244 |
+
{
|
| 245 |
+
"path": "data/train-00022.tar",
|
| 246 |
+
"split": "train",
|
| 247 |
+
"samples": 7784,
|
| 248 |
+
"identities": 1533,
|
| 249 |
+
"size_bytes": 1073694720,
|
| 250 |
+
"sha256": "5d716ea74aebfdf4bb0549eb9388d837140d23254804575be9c6fdafc95062cb",
|
| 251 |
+
"first_key": "00016253_000000",
|
| 252 |
+
"last_key": "00017919_000003"
|
| 253 |
+
},
|
| 254 |
+
{
|
| 255 |
+
"path": "data/train-00023.tar",
|
| 256 |
+
"split": "train",
|
| 257 |
+
"samples": 8730,
|
| 258 |
+
"identities": 1802,
|
| 259 |
+
"size_bytes": 523161600,
|
| 260 |
+
"sha256": "8405124308caa14143b0107c718f01139c19f3ace0ea74f510b30ebfcd57b707",
|
| 261 |
+
"first_key": "00017920_000000",
|
| 262 |
+
"last_key": "00019876_000002"
|
| 263 |
+
},
|
| 264 |
+
{
|
| 265 |
+
"path": "data/validation-00000.tar",
|
| 266 |
+
"split": "validation",
|
| 267 |
+
"samples": 2851,
|
| 268 |
+
"identities": 500,
|
| 269 |
+
"size_bytes": 820797440,
|
| 270 |
+
"sha256": "526d8252bf81630b886c7de3cbd28d88ed023bc63b9d3fd3ee95a7911ca67b26",
|
| 271 |
+
"first_key": "00000028_000000",
|
| 272 |
+
"last_key": "00019862_000007"
|
| 273 |
+
},
|
| 274 |
+
{
|
| 275 |
+
"path": "data/test-00000.tar",
|
| 276 |
+
"split": "test",
|
| 277 |
+
"samples": 2846,
|
| 278 |
+
"identities": 500,
|
| 279 |
+
"size_bytes": 852213760,
|
| 280 |
+
"sha256": "3ec421df4bc89aa9f3e98c1b88364c64f7bf3b567c320dc9c41fd471ef454107",
|
| 281 |
+
"first_key": "00000012_000000",
|
| 282 |
+
"last_key": "00019855_000016"
|
| 283 |
+
}
|
| 284 |
+
]
|
| 285 |
+
}
|
splits.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
verify_webdataset.py
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Verify an ICW WebDataset release against its manifest."""
|
| 3 |
+
|
| 4 |
+
from __future__ import annotations
|
| 5 |
+
|
| 6 |
+
import argparse
|
| 7 |
+
import hashlib
|
| 8 |
+
import json
|
| 9 |
+
import tarfile
|
| 10 |
+
from collections import Counter, defaultdict
|
| 11 |
+
from pathlib import Path
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def sha256_file(path: Path) -> str:
|
| 15 |
+
digest = hashlib.sha256()
|
| 16 |
+
with path.open("rb") as handle:
|
| 17 |
+
for chunk in iter(lambda: handle.read(8 * 1024 * 1024), b""):
|
| 18 |
+
digest.update(chunk)
|
| 19 |
+
return digest.hexdigest()
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def main() -> None:
|
| 23 |
+
parser = argparse.ArgumentParser()
|
| 24 |
+
parser.add_argument("root", nargs="?", type=Path, default=Path(__file__).resolve().parent)
|
| 25 |
+
args = parser.parse_args()
|
| 26 |
+
root = args.root.resolve()
|
| 27 |
+
manifest = json.loads((root / "manifest.json").read_text(encoding="utf-8"))
|
| 28 |
+
|
| 29 |
+
split_samples: Counter[str] = Counter()
|
| 30 |
+
split_identities: dict[str, set[str]] = defaultdict(set)
|
| 31 |
+
total_samples = 0
|
| 32 |
+
|
| 33 |
+
for record in manifest["shards"]:
|
| 34 |
+
path = root / record["path"]
|
| 35 |
+
if path.stat().st_size != record["size_bytes"]:
|
| 36 |
+
raise SystemExit(f"Size mismatch: {path}")
|
| 37 |
+
if sha256_file(path) != record["sha256"]:
|
| 38 |
+
raise SystemExit(f"SHA-256 mismatch: {path}")
|
| 39 |
+
|
| 40 |
+
sample_count = 0
|
| 41 |
+
identities: set[str] = set()
|
| 42 |
+
expected_json_key: str | None = None
|
| 43 |
+
with tarfile.open(path, "r:") as archive:
|
| 44 |
+
for member in archive:
|
| 45 |
+
if not member.isfile():
|
| 46 |
+
raise SystemExit(f"Unexpected non-file member: {path}:{member.name}")
|
| 47 |
+
member_path = Path(member.name)
|
| 48 |
+
key = member_path.stem
|
| 49 |
+
if member_path.suffix == ".jpg":
|
| 50 |
+
if expected_json_key is not None:
|
| 51 |
+
raise SystemExit(f"Missing JSON after {expected_json_key} in {path}")
|
| 52 |
+
expected_json_key = key
|
| 53 |
+
elif member_path.suffix == ".json":
|
| 54 |
+
if key != expected_json_key:
|
| 55 |
+
raise SystemExit(f"JPG/JSON ordering mismatch in {path}: {key}")
|
| 56 |
+
extracted = archive.extractfile(member)
|
| 57 |
+
if extracted is None:
|
| 58 |
+
raise SystemExit(f"Cannot read {path}:{member.name}")
|
| 59 |
+
metadata = json.load(extracted)
|
| 60 |
+
if metadata["split"] != record["split"]:
|
| 61 |
+
raise SystemExit(f"Split mismatch in {path}:{member.name}")
|
| 62 |
+
if metadata["identity_id"] not in key:
|
| 63 |
+
raise SystemExit(f"Identity/key mismatch in {path}:{member.name}")
|
| 64 |
+
identities.add(metadata["identity_id"])
|
| 65 |
+
sample_count += 1
|
| 66 |
+
expected_json_key = None
|
| 67 |
+
else:
|
| 68 |
+
raise SystemExit(f"Unexpected suffix in {path}:{member.name}")
|
| 69 |
+
if expected_json_key is not None:
|
| 70 |
+
raise SystemExit(f"Missing final JSON in {path}")
|
| 71 |
+
if sample_count != record["samples"]:
|
| 72 |
+
raise SystemExit(f"Sample count mismatch in {path}")
|
| 73 |
+
if len(identities) != record["identities"]:
|
| 74 |
+
raise SystemExit(f"Identity count mismatch in {path}")
|
| 75 |
+
|
| 76 |
+
split = record["split"]
|
| 77 |
+
split_samples[split] += sample_count
|
| 78 |
+
overlap = split_identities[split].intersection(identities)
|
| 79 |
+
if overlap:
|
| 80 |
+
raise SystemExit(f"Identity split across shards: {next(iter(overlap))}")
|
| 81 |
+
split_identities[split].update(identities)
|
| 82 |
+
total_samples += sample_count
|
| 83 |
+
print(f"verified {record['path']}")
|
| 84 |
+
|
| 85 |
+
split_sets = list(split_identities.items())
|
| 86 |
+
for index, (left_name, left_ids) in enumerate(split_sets):
|
| 87 |
+
for right_name, right_ids in split_sets[index + 1 :]:
|
| 88 |
+
overlap = left_ids.intersection(right_ids)
|
| 89 |
+
if overlap:
|
| 90 |
+
raise SystemExit(
|
| 91 |
+
f"Identity overlap between {left_name} and {right_name}: {next(iter(overlap))}"
|
| 92 |
+
)
|
| 93 |
+
|
| 94 |
+
if total_samples != manifest["total_samples"]:
|
| 95 |
+
raise SystemExit("Total sample count mismatch")
|
| 96 |
+
for split, expected in manifest["splits"].items():
|
| 97 |
+
if split_samples[split] != expected["samples"]:
|
| 98 |
+
raise SystemExit(f"Manifest sample mismatch for {split}")
|
| 99 |
+
if len(split_identities[split]) != expected["identities"]:
|
| 100 |
+
raise SystemExit(f"Manifest identity mismatch for {split}")
|
| 101 |
+
print(
|
| 102 |
+
f"OK: {total_samples} samples, "
|
| 103 |
+
f"{sum(len(values) for values in split_identities.values())} identities, "
|
| 104 |
+
f"{len(manifest['shards'])} shards"
|
| 105 |
+
)
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
if __name__ == "__main__":
|
| 109 |
+
main()
|