| --- |
| language: |
| - en |
| pretty_name: SnapBench |
| task_categories: |
| - visual-document-retrieval |
| tags: |
| - multimodal |
| - image-text-retrieval |
| - retrieval |
| - robustness |
| - benchmark |
| configs: |
| - config_name: queries |
| data_dir: queries |
| default: true |
| - config_name: gallery |
| data_dir: gallery |
| --- |
| |
| Source repository: <https://github.com/zrchen03/SnapBench> |
|
|
| Paper: [SnapBench: Benchmarking Snap-and-Ask Multimodal Retrieval for Mobile Interactions](https://arxiv.org/abs/2608.29607) |
|
|
| # SnapBench: Benchmarking Snap-and-Ask Multimodal Retrieval for Mobile Interactions |
|
|
| SnapBench is a benchmark for **snap-and-ask** mobile interactions: a user captures a photo and asks a short English question. Each query pairs an image with text; the gallery contains image–caption pairs to retrieve from. The benchmark includes a clean split plus text and image perturbations to simulate real-world query degradation. |
|
|
| | | | |
| |---|---| |
| | Queries | 1,145 (image + text) | |
| | Gallery | 9,085 items (image + caption) | |
| | Conditions | 54 (1 clean + 8 text + 45 image perturbations) | |
|
|
| This repository ships the clean benchmark in the standard Hugging Face `ImageFolder` format. It includes the clean query and gallery images, retrieval annotations, and perturbation metadata. It does not include evaluation code. |
|
|
| --- |
|
|
| ## What Is Included |
|
|
| | Component | Location | Status | |
| |---|---|---| |
| | Query metadata | `queries/test/metadata.jsonl` | included | |
| | Query images | `queries/test/images/` (1,145) | included | |
| | Gallery metadata | `gallery/test/metadata.jsonl` (9,085 items) | included | |
| | Gallery images | `gallery/test/images/` (9,059 unique images) | included | |
| | Text perturbations | `queries/test/metadata.jsonl` → `text_perturbations` | included | |
| | Image perturbation specifications | `queries/test/metadata.jsonl` → `image_perturbations` | included | |
| | Image perturbation files | 15 types × 3 severity levels × 1,145 queries | **generate locally from the source repository** | |
|
|
| --- |
|
|
| ## Setup |
|
|
| Install Hugging Face Datasets: |
|
|
| ```bash |
| pip install datasets |
| ``` |
|
|
| Load the two dataset configurations from the Hub: |
|
|
| ```python |
| from datasets import load_dataset |
| |
| queries = load_dataset("yefd/SnapBench", "queries", split="test") |
| gallery = load_dataset("yefd/SnapBench", "gallery", split="test") |
| ``` |
|
|
| To load a local copy of this repository: |
|
|
| ```python |
| from datasets import load_dataset |
| |
| queries = load_dataset(".", "queries", split="test") |
| gallery = load_dataset(".", "gallery", split="test") |
| ``` |
|
|
| The `file_name` field in each `metadata.jsonl` file is automatically exposed as an `image` column by the Hugging Face `ImageFolder` builder. |
|
|
| --- |
|
|
| ## Build the Full Benchmark |
|
|
| This Hugging Face version already includes the clean benchmark (queries, gallery, and text perturbations). The image perturbation specifications are stored in the `image_perturbations` field of every query. Use the scripts in the source repository to generate all image-perturbed query images locally. |
|
|
| ### Step 1. Generate image perturbations |
|
|
| Clone and set up the source repository: |
|
|
| ```bash |
| git lfs install |
| git clone https://github.com/zrchen03/SnapBench.git SnapBench_raw |
| cd SnapBench_raw |
| git lfs pull |
| pip install -r requirements.txt |
| export BENCH_IMAGES_DIR=$(pwd)/bench_images |
| ``` |
|
|
| Generate 15 perturbation types × 3 severity levels (sev1 / sev2 / sev3) × 1,145 queries = **51,675 images**: |
|
|
| ```bash |
| python benchmark/gen_image_perturbations.py |
| ``` |
|
|
| Output: |
|
|
| ``` |
| bench_images/perturbed/{type}/sev{1,2,3}/{query_id}.jpg |
| ``` |
|
|
| Preview the workload without writing files: |
|
|
| ```bash |
| python benchmark/gen_image_perturbations.py --dry-run |
| ``` |
|
|
| To export the generated images as an additional Hugging Face configuration: |
|
|
| ```bash |
| python benchmark/export_hf_dataset.py --include-perturbed --overwrite |
| ``` |
|
|
| ### Step 2. (Optional) Regenerate text perturbations |
|
|
| Text perturbations are already stored in `queries/test/metadata.jsonl`. Only rerun this in the source repository if you need to rebuild them: |
|
|
| ```bash |
| python benchmark/gen_text_perturbations.py \ |
| --gpu 0 --chunk-in chunk_0.json --chunk-out result_0.json |
| ``` |
|
|
| --- |
|
|
| ## Data Layout |
|
|
| ``` |
| SnapBench/ |
| ├── README.md |
| ├── queries/ |
| │ └── test/ |
| │ ├── metadata.jsonl |
| │ └── images/ # 1,145 query images |
| └── gallery/ |
| └── test/ |
| ├── metadata.jsonl |
| └── images/ # 9,059 unique gallery images |
| ``` |
|
|
| The dataset exposes two configurations, both with a `test` split: |
|
|
| - `queries`: clean query images and text, positive and hard-negative gallery IDs, and all text/image perturbation metadata. |
| - `gallery`: image–caption retrieval candidates. It has 9,085 items backed by 9,059 unique image files because some images have more than one caption. |
|
|
| Important fields: |
|
|
| - Query image: `queries/test/metadata.jsonl` → `file_name` (loaded as `image`) |
| - Query text: `text` |
| - Positive gallery items: `positive_gallery_ids` |
| - Hard negatives: `hard_negative_gallery_ids` |
| - Gallery image: `gallery/test/metadata.jsonl` → `file_name` (loaded as `image`) |
| - Gallery caption: `caption` |
|
|