Datasets:

Modalities:
Image
Text
Formats:
parquet
Languages:
Chinese
Size:
< 1K
ArXiv:
Libraries:
Datasets
pandas
License:
File size: 11,571 Bytes
77c6776
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9ac96a6
77c6776
 
9ac96a6
77c6776
 
 
 
 
9ac96a6
 
 
 
 
 
 
 
 
 
 
77c6776
9ac96a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c50be42
9ac96a6
c50be42
0fef325
 
 
c50be42
 
 
 
 
 
 
 
 
 
 
 
dc442d2
9ac96a6
c50be42
dc442d2
c50be42
 
 
 
 
 
 
 
 
 
 
 
 
dc442d2
9ac96a6
c50be42
 
dc442d2
c50be42
dc442d2
c50be42
dc442d2
 
 
c50be42
dc442d2
 
c50be42
 
dc442d2
c50be42
 
 
 
 
 
 
 
 
 
 
9ac96a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
---
dataset_info:
  features:
  - name: question_id
    dtype: int64
  - name: image
    dtype: image
  - name: caption
    dtype: string
  - name: stacked_image
    dtype: image
  - name: only_it_image
    dtype: image
  - name: only_it_image_small
    dtype: image
  - name: crossed_text
    sequence: string
  splits:
  - name: test
    num_bytes: 100452047
    num_examples: 500
  download_size: 100332998
  dataset_size: 100452047
configs:
- config_name: default
  data_files:
  - split: test
    path: data/test-*
license: cc-by-sa-4.0
source_datasets:
- wikimedia/wit_base
task_categories:
- visual-question-answering
language:
- zh
pretty_name: VCR
arxiv: 2406.06462
size_categories:
- n<1K
---
# The VCR-Wiki Dataset for Visual Caption Restoration (VCR)

🏠 [Paper](https://arxiv.org/abs/2406.06462) | 👩🏻‍💻 [GitHub](https://github.com/tianyu-z/vcr) | 🤗 [Huggingface Datasets](https://huggingface.co/vcr-org) | 📏 [Evaluation with lmms-eval](https://github.com/EvolvingLMMs-Lab/lmms-eval)

This is the official Hugging Face dataset for VCR-Wiki, a dataset for the [Visual Caption Restoration (VCR)](https://arxiv.org/abs/2406.06462) task.

VCR is designed to measure vision-language models' capability to accurately restore partially obscured texts using pixel-level hints within images. text-based processing becomes ineffective in VCR as accurate text restoration depends on the combined information from provided images, context, and subtle cues from the tiny exposed areas of masked texts.

![image/jpg](https://raw.githubusercontent.com/tianyu-z/VCR/main/assets/main_pic_en_easy.jpg)

We found that OCR and text-based processing become ineffective in VCR as accurate text restoration depends on the combined information from provided images, context, and subtle cues from the tiny exposed areas of masked texts. We develop a pipeline to generate synthetic images for the VCR task using image-caption pairs, with adjustable caption visibility to control the task difficulty. However, this task is generally easy for native speakers of the corresponding language. Initial results indicate that current vision-language models fall short compared to human performance on this task.

## Dataset Description

- **GitHub:** [VCR GitHub](https://github.com/tianyu-z/vcr)
- **Paper:** [VCR: Visual Caption Restoration](https://arxiv.org/abs/2406.06462)
- **Point of Contact:** [Tianyu Zhang](mailto:tianyu.zhang@mila.quebec)

# Model Evaluation

## Method 1 (recommended): use the evaluation script
```bash
git clone https://github.com/tianyu-z/VCR.git
```
### Open-source evaluation
We support open-source model_id: 
```python
["openbmb/MiniCPM-Llama3-V-2_5",
"OpenGVLab/InternVL-Chat-V1-5",
"internlm/internlm-xcomposer2-vl-7b",
"HuggingFaceM4/idefics2-8b",
"Qwen/Qwen-VL-Chat",
"THUDM/cogvlm2-llama3-chinese-chat-19B",
"THUDM/cogvlm2-llama3-chat-19B",
"echo840/Monkey-Chat",]
```
For the models not on list, they are not intergated with huggingface, please refer to their github repo to create the evaluation pipeline. Examples of the inference logic are in `src/evaluation/inference.py`

```bash
pip install -r requirements.txt
# We use HuggingFaceM4/idefics2-8b and vcr_wiki_en_easy as an example
# Inference from the VLMs and save the results to {model_id}_{difficulty}_{language}.json
cd src/evaluation
python3 inference.py --dataset_handler "vcr-org/VCR-wiki-en-easy-test" --model_id "HuggingFaceM4/idefics2-8b" --device "cuda" --dtype "bf16" --save_interval 50 --resume True

# Evaluate the results and save the evaluation metrics to {model_id}_{difficulty}_{language}_evaluation_result.json
python3 evaluation_metrics.py --model_id HuggingFaceM4/idefics2-8b --output_path . --json_filename "HuggingFaceM4_idefics2-8b_en_easy.json" --dataset_handler "vcr-org/VCR-wiki-en-easy-test"

# To get the mean score of all the `{model_id}_{difficulty}_{language}_evaluation_result.json` in `jsons_path` (and the std, confidence interval if `--bootstrap`) of the evaluation metrics
python3 gather_results.py --jsons_path .
```

### Close-source evaluation
We provide the evaluation script for the close-source models in `src/evaluation/closed_source_eval.py`.

You need an API Key, a pre-saved testing dataset and specify the path of the data saving the paper
```bash
pip install -r requirements.txt
cd src/evaluation
# [download images to inference locally option 1] save the testing dataset to the path using script from huggingface
python3 save_image_from_dataset.py --output_path .
# [download images to inference locally option 2] save the testing dataset to the path using github repo
# use en-easy-test-500 as an example
git clone https://github.com/tianyu-z/VCR-wiki-en-easy-test-500.git

# specify your image path if you would like to inference using the image stored locally by --image_path "path_to_image", otherwise, the script will streaming the images from github repo
python3 closed_source_eval.py --model_id gpt4o --dataset_handler "VCR-wiki-en-easy-test-500" --api_key "Your_API_Key"

# Evaluate the results and save the evaluation metrics to {model_id}_{difficulty}_{language}_evaluation_result.json
python3 evaluation_metrics.py --model_id gpt4o --output_path . --json_filename "gpt4o_en_easy.json" --dataset_handler "vcr-org/VCR-wiki-en-easy-test-500"

# To get the mean score of all the `{model_id}_{difficulty}_{language}_evaluation_result.json` in `jsons_path` (and the std, confidence interval if `--bootstrap`) of the evaluation metrics
python3 gather_results.py --jsons_path .
```

## Method 2: use lmms-eval framework
You may need to incorporate the inference method of your model if the lmms-eval framework does not support it. For details, please refer to [here](https://github.com/EvolvingLMMs-Lab/lmms-eval/blob/main/docs/model_guide.md)
```bash
pip install git+https://github.com/EvolvingLMMs-Lab/lmms-eval.git
# We use HuggingFaceM4/idefics2-8b and vcr_wiki_en_easy as an example
python3 -m accelerate.commands.launch --num_processes=8 -m lmms_eval --model idefics2 --model_args pretrained="HuggingFaceM4/idefics2-8b" --tasks vcr_wiki_en_easy --batch_size 1 --log_samples --log_samples_suffix HuggingFaceM4_idefics2-8b_vcr_wiki_en_easy --output_path ./logs/
```
`lmms-eval` supports the following VCR `--tasks` settings:

* English
  * Easy
    * `vcr_wiki_en_easy` (full test set, 5000 instances)
    * `vcr_wiki_en_easy_500` (first 500 instances in the vcr_wiki_en_easy setting)
    * `vcr_wiki_en_easy_100` (first 100 instances in the vcr_wiki_en_easy setting)
  * Hard
    * `vcr_wiki_en_hard` (full test set, 5000 instances)
    * `vcr_wiki_en_hard_500` (first 500 instances in the vcr_wiki_en_hard setting)
    * `vcr_wiki_en_hard_100` (first 100 instances in the vcr_wiki_en_hard setting)
* Chinese
  * Easy
    * `vcr_wiki_zh_easy` (full test set, 5000 instances)
    * `vcr_wiki_zh_easy_500` (first 500 instances in the vcr_wiki_zh_easy setting)
    * `vcr_wiki_zh_easy_100` (first 100 instances in the vcr_wiki_zh_easy setting)
  * Hard
    * `vcr_wiki_zh_hard` (full test set, 5000 instances)
    * `vcr_wiki_zh_hard_500` (first 500 instances in the vcr_wiki_zh_hard setting)
    * `vcr_wiki_zh_hard_100` (first 100 instances in the vcr_wiki_zh_hard setting)

## Dataset Statistics

We show the statistics of the original VCR-Wiki dataset below:

![image/png](https://cdn-uploads.huggingface.co/production/uploads/62bb1e0f3ff437e49a3088e5/CBS35FnFi9p0hFY9iJ0ba.png)

## Dataset Construction

![image/png](https://raw.githubusercontent.com/tianyu-z/VCR/main/assets/vcr_pipeline.png)

* **Data Collection and Initial Filtering**: The original data is collected from [wikimedia/wit_base](https://huggingface.co/datasets/wikimedia/wit_base). Before constructing the dataset, we first filter out the instances with sensitive content, including NSFW and crime-related terms, to mitigate AI risk and biases.

* **N-gram selection**: We first truncate the description of each entry to be less than 5 lines with our predefined font and size settings. We then tokenize the description for each entry with spaCy and randomly mask out 5-grams, where the masked 5-grams do not contain numbers, person names, religious or political groups, facilities, organizations, locations, dates and time labeled by spaCy, and the total masked token does not exceed 50\% of the tokens in the caption.

* **Create text embedded in images**: We create text embedded in images (TEI) for the description, resize its width to 300 pixels, and mask out the selected 5-grams with white rectangles. The size of the rectangle reflects the difficulty of the task: (1) in easy versions, the task is easy for native speakers but open-source OCR models almost always fail, and (2) in hard versions, the revealed part consists of only one to two pixels for the majority of letters or characters, yet the restoration task remains feasible for native speakers of the language.

* **Concatenate Images**: We concatenate TEI with the main visual image (VI) to get the stacked image.

* **Second-round Filtering**: We filter out all entries with no masked n-grams or have a height exceeding 900 pixels.

## Data Fields

* `question_id`: `int64`, the instance id in the current split.
* `image`: `PIL.Image.Image`, the original visual image (VI).
* `stacked_image`: `PIL.Image.Image`, the stacked VI+TEI image containing both the original visual image and the masked text embedded in image.
* `only_id_image`: `PIL.Image.Image`, the masked TEI image.
* `caption`: `str`, the unmasked original text presented in the TEI image.
* `crossed_text`: `List[str]`, the masked n-grams in the current instance.

## Disclaimer for the VCR-Wiki dataset and Its Subsets

The VCR-Wiki dataset and/or its subsets are provided under the Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license. This dataset is intended solely for research and educational purposes in the field of visual caption restoration and related vision-language tasks.

Important Considerations:

1. **Accuracy and Reliability**: While the VCR-Wiki dataset has undergone filtering to exclude sensitive content, it may still contain inaccuracies or unintended biases. Users are encouraged to critically evaluate the dataset's content and applicability to their specific research objectives.

2. **Ethical Use**: Users must ensure that their use of the VCR-Wiki dataset aligns with ethical guidelines and standards, particularly in avoiding harm, perpetuating biases, or misusing the data in ways that could negatively impact individuals or groups.

3. **Modifications and Derivatives**: Any modifications or derivative works based on the VCR-Wiki dataset must be shared under the same license (CC BY-SA 4.0).

4. **Commercial Use**: Commercial use of the VCR-Wiki dataset is permitted under the CC BY-SA 4.0 license, provided that proper attribution is given and any derivative works are shared under the same license.

By using the VCR-Wiki dataset and/or its subsets, you agree to the terms and conditions outlined in this disclaimer and the associated license. The creators of the dataset are not liable for any direct or indirect damages resulting from its use.

## Citation

If you find VCR useful for your research and applications, please cite using this BibTeX:

```bibtex
@article{zhang2024vcr,
  title   = {VCR: Visual Caption Restoration},
  author  = {Tianyu Zhang and Suyuchen Wang and Lu Li and Ge Zhang and Perouz Taslakian and Sai Rajeswar and Jie Fu and Bang Liu and Yoshua Bengio},
  year    = {2024},
  journal = {arXiv preprint arXiv: 2406.06462}
}
```