Datasets:
File size: 5,069 Bytes
33785bd 6902ed0 33785bd c5e780a 33785bd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | ---
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`
|