CoolFace
Datasetpublic

RicePasteM/ICW

Individual Cats in the Wild (ICW) ICW is an identity-disjoint benchmark for individual cat identification in unconstrained images. It contains 82,791 JPEG images of 19,877 individual cats, collected from six public adoption and rescue platforms and curated for fine-grained recognition and image retrieval research. ICW accompanies the MeowID project: MeowID: A Dual-Expert Retrieval System for Individual Cat Identification Zhangchi Hu, Yi Shang, Haocheng Yang, Qiwei Hu, and… See the full description on the dataset page: https://huggingface.co/datasets/RicePasteM/ICW.

sourceHugging Faceotherupdated 1mo agoView on Hugging Face
0likes115downloads
extract_to_imagefolder.py55 linesDownload Raw Back to root
1#!/usr/bin/env python32"""Restore ICW WebDataset shards to split/identity/image.jpg folders."""3 4from __future__ import annotations5 6import argparse7import io8import json9import tarfile10from pathlib import Path11 12 13def 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 = 024    for shard in manifest["shards"]:25        pending_key: str | None = None26        pending_image: bytes | None = None27        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).stem33                if member.name.endswith(".jpg"):34                    pending_key = key35                    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_name44                    destination.parent.mkdir(parents=True, exist_ok=True)45                    destination.write_bytes(pending_image)46                    restored += 147                    pending_key = None48                    pending_image = None49        print(f"restored {shard['path']}")50    print(f"complete: {restored} images restored to {output}")51 52 53if __name__ == "__main__":54    main()55