File size: 10,036 Bytes
0e023c7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
## Data preparation

### data for training
- The images pretraining dataset is from [LLaVA](https://github.com/haotian-liu/LLaVA).
- The images tuning dataset is from [LLaVA](https://github.com/haotian-liu/LLaVA).
- The videos pretraining dataset is from [Valley](https://github.com/RupertLuo/Valley).
- The videos tuning dataset is from [Video-ChatGPT](https://github.com/mbzuai-oryx/Video-ChatGPT).
- Download the training annotations. You can download from [Baidu Disk](https://pan.baidu.com/s/1BipI3_f--GRWqaWTGYp-Jg?pwd=wkl0), [Google Disk](https://drive.google.com/file/d/11-1NBXNeiNQE2wPbue1dFph_Na_EHRYG/view?usp=drive_link) or [Peking University Disk](https://disk.pku.edu.cn:443/link/84783AB54553DFA150C1C5E82C16EB29)


We also provide the processed data as follows.
<div align="center">
<table border="1" width="100%">
    <tr align="center">
        <th>Datasets</th><th>Baidu Disk</th>
    </tr>
    <tr align="center">
        <td>Image pretraining</td><td><a href="">Link</a></td>
    </tr>
    </tr>
    <tr align="center">
        <td>Image tuning</td><td><a href="">Link</a></td>
    </tr>
    </tr>
    <tr align="center">
        <td>Video pretraining</td><td><a href="">Link</a></td>
    </tr>
    </tr>
    <tr align="center">
        <td>Video tuning</td><td><a href="">Link</a></td>
    </tr>
</table>
</div>

After downloading all of them, organize the data as follows in ```DATA_ROOT```. 

```Shell
DATA_ROOT
β”œβ”€β”€ llava_image
β”œβ”€β”€ llava_image_tune
β”œβ”€β”€ valley
└── videochatgpt_tune
```

### data for validating
- For image, follow LLaVA's instructions. ***You MUST first download [eval.zip](https://drive.google.com/file/d/1atZSBBrAX54yYpxtVVW33zFvcnaHeFPy/view?usp=sharing)**. It contains custom annotations, scripts, and the prediction files with LLaVA v1.5. Extract to `eval`. This also provides a general structure for all datasets.*
- For video, videos and annotations can be downloaded from Video-ChatGPT. We also provide the processed data as follows.
<div align="center">
<table border="1" width="100%">
    <tr align="center">
        <th>Datasets</th><th>Baidu Disk</th><th>Google Disk</th><th>Peking University Disk</th>
    </tr>
    <tr align="center">
        <td>Activitynet_Zero_Shot_QA</td><td><a href="https://pan.baidu.com/s/1d_AVx9Mz_57nA3exhQZGyA?pwd=9amr ">Link</a></td><td>-</td><td>-</td>
    </tr>
    </tr>
    <tr align="center">
        <td>MSRVTT_Zero_Shot_QA</td><td><a href="https://pan.baidu.com/s/1QHUtwHXm4Vc-Wc12XFCFsA?pwd=1rj8">Link</a></td><td><a href="https://drive.google.com/file/d/1yXh9lz7flQ5Ui2IRSd6Qi6RqSEeUJwl3/view?usp=drive_link">Link</a></td><td>-</td>
    </tr>
    </tr>
    <tr align="center">
        <td>MSVD_Zero_Shot_QA</td><td><a href="https://pan.baidu.com/s/1PJSHkjHG2BPl_ddUnBj9AA?pwd=jj34">Link</a></td><td><a href="https://drive.google.com/file/d/1_q4eiSdb7i8P3Hmh4lCfgY1uBGyzU_7X/view?usp=drive_link">Link</a></td><td><a href="https://disk.pku.edu.cn:443/link/8B0D01747D8AA65534820B7E60CBFEFC">Link</a></td>
    </tr>
    </tr>
    <tr align="center">
        <td>TGIF_Zero_Shot_QA</td><td><a href="https://pan.baidu.com/s/11ubtWbTtubyBmN9UPvAyow?pwd=98yr">Link</a></td><td><a href="https://drive.google.com/file/d/1so6L9rg_gdC8Segur7rKML-ffd4Ix_I6/view?usp=drive_link">Link</a></td><td><a href="https://disk.pku.edu.cn:443/link/B9AB387EFE8817158F181FF3D7A97163">Link</a></td>
    </tr>
</table>
</div>

After downloading all of them, organize the data as follows in `eval`.

```Shell
eval
β”œβ”€β”€ GPT_Zero_Shot_QA
β”‚Β Β  β”œβ”€β”€ Activitynet_Zero_Shot_QA
β”‚Β Β  β”œβ”€β”€ MSRVTT_Zero_Shot_QA
β”‚Β Β  β”œβ”€β”€ MSVD_Zero_Shot_QA
β”‚Β Β  └── TGIF_Zero_Shot_QA
β”œβ”€β”€ gqa
β”‚Β Β  β”œβ”€β”€ answers
β”‚Β Β  β”œβ”€β”€ data
β”‚Β Β  └── llava_gqa_testdev_balanced.jsonl
β”œβ”€β”€ llava-bench-in-the-wild
β”‚Β Β  β”œβ”€β”€ answers
β”‚Β Β  β”œβ”€β”€ answers_gpt4.jsonl
β”‚Β Β  β”œβ”€β”€ bard_0718.jsonl
β”‚Β Β  β”œβ”€β”€ bing_chat_0629.jsonl
β”‚Β Β  β”œβ”€β”€ context.jsonl
β”‚Β Β  β”œβ”€β”€ images
β”‚Β Β  β”œβ”€β”€ questions.jsonl
β”‚Β Β  β”œβ”€β”€ README.md
β”‚Β Β  └── reviews
β”œβ”€β”€ mmbench
β”‚Β Β  β”œβ”€β”€ answers
β”‚Β Β  β”œβ”€β”€ answers_upload
β”‚Β Β  β”œβ”€β”€ mmbench_dev_20230712.tsv
β”‚Β Β  └── mmbench_dev_en_20231003.tsv
β”œβ”€β”€ MME
β”‚Β Β  β”œβ”€β”€ answers
β”‚Β Β  β”œβ”€β”€ convert_answer_to_mme.py
β”‚Β Β  └── llava_mme.jsonl
β”œβ”€β”€ mm-vet
β”‚Β Β  β”œβ”€β”€ answers
β”‚Β Β  β”œβ”€β”€ bard_set.json
β”‚Β Β  β”œβ”€β”€ convert_answers.py
β”‚Β Β  β”œβ”€β”€ images
β”‚Β Β  β”œβ”€β”€ llava-mm-vet.jsonl
β”‚Β Β  β”œβ”€β”€ mm-vet.json
β”‚Β Β  └── results
β”œβ”€β”€ pope
β”‚Β Β  β”œβ”€β”€ answers
β”‚Β Β  β”œβ”€β”€ coco
β”‚Β Β  β”œβ”€β”€ llava_pope_test.jsonl
β”‚Β Β  └── val2014
β”œβ”€β”€ scienceqa
β”‚Β Β  β”œβ”€β”€ answers
β”‚Β Β  β”œβ”€β”€ images
β”‚Β Β  β”œβ”€β”€ llava_test_CQM-A.json
β”‚Β Β  β”œβ”€β”€ pid_splits.json
β”‚Β Β  └── problems.json
β”œβ”€β”€ seed_bench
β”‚Β Β  β”œβ”€β”€ answers
β”‚Β Β  β”œβ”€β”€ answers_upload
β”‚Β Β  β”œβ”€β”€ extract_video_frames.py
β”‚Β Β  └── llava-seed-bench.jsonl
β”œβ”€β”€ textvqa
β”‚Β Β  β”œβ”€β”€ answers
β”‚Β Β  β”œβ”€β”€ llava_textvqa_val_v051_ocr.jsonl
β”‚Β Β  β”œβ”€β”€ TextVQA_0.5.1_val.json
β”‚Β Β  └── train_images
β”œβ”€β”€ vizwiz
β”‚Β Β  β”œβ”€β”€ answers
β”‚Β Β  β”œβ”€β”€ answers_upload
β”‚Β Β  β”œβ”€β”€ llava_test.jsonl
β”‚Β Β  β”œβ”€β”€ test
β”‚Β Β  β”œβ”€β”€ test.json
β”‚Β Β  β”œβ”€β”€ train.json
β”‚Β Β  └── val.json
└── vqav2
    β”œβ”€β”€ answers
    β”œβ”€β”€ answers_upload
    β”œβ”€β”€ llava_vqav2_mscoco_test2015.jsonl
    β”œβ”€β”€ llava_vqav2_mscoco_test-dev2015.jsonl
    └── test2015
```

## Training
Specify your `DATA_ROOT` according to the data preparation.
- Stage 1 pretraining script: [pretrain.sh](scripts/v1_5/pretrain.sh). 
- Stage 2 tuning script: [finetune.sh](scripts/v1_5/finetune.sh).

## Validating
Our image validation code comes from LLaVA and our video validation code comes from Video-ChatGPT, thanks for their contribution! 

You can refer to the official repository for validation, but we also provide [off-the-shelf](scripts/v1_5/eval) scripts.


### MSRVTT-QA
1. Inference to get the result.
```Shell
CUDA_VISIBLE_DEVICES=0 bash scripts/v1_5/eval/run_qa_msrvtt.sh
```

2. GPT-Assistant evaluation.
```Shell
bash scripts/v1_5/eval/eval_qa_msrvtt.sh
```

### MSVD-QA
1. Inference to get the result.
```Shell
CUDA_VISIBLE_DEVICES=0 bash scripts/v1_5/eval/run_qa_msvd.sh
```

2. GPT-Assistant evaluation.
```Shell
bash scripts/v1_5/eval/eval_qa_msvd.sh
```

### TGIF-QA
1. Inference to get the result.
```Shell
CUDA_VISIBLE_DEVICES=0 bash scripts/v1_5/eval/run_qa_tgif.sh
```

2. GPT-Assistant evaluation.
```Shell
bash scripts/v1_5/eval/eval_qa_tgif.sh
```

### ActivityNet-QA
1. Inference to get the result.
```Shell
CUDA_VISIBLE_DEVICES=0 bash scripts/v1_5/eval/run_qa_activitynet.sh
```

2. GPT-Assistant evaluation.
```Shell
bash scripts/v1_5/eval/eval_qa_activitynet.sh
```


### VQAv2

1. Download [`test2015`](http://images.cocodataset.org/zips/test2015.zip) and put it under `eval/vqav2`.
2. Multi-GPU inference.
```Shell
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 bash scripts/v1_5/eval/eval_image_vqav2.sh
```
3. Submit the results to the [evaluation server](https://eval.ai/web/challenges/challenge-page/830/my-submission): `eval/vqav2/answers_upload`.

### GQA

1. Download the data following the official instructions [here](https://cs.stanford.edu/people/dorarad/gqa/download.html) and put under `eval/gqa/data`.
2. Multi-GPU inference.
```Shell
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 bash scripts/v1_5/eval/eval_image_gqa.sh
```

### VisWiz

1. Download [`test.json`](https://vizwiz.cs.colorado.edu/VizWiz_final/vqa_data/Annotations.zip) and extract [`test.zip`](https://vizwiz.cs.colorado.edu/VizWiz_final/images/test.zip) to `test`. Put them under `eval/vizwiz`.
2. Single-GPU inference.
```Shell
CUDA_VISIBLE_DEVICES=0 bash scripts/v1_5/eval/eval_image_vizwiz.sh
```
3. Submit the results to the [evaluation server](https://eval.ai/web/challenges/challenge-page/1911/my-submission): `eval/vizwiz/answers_upload`.

### ScienceQA

1. Under `eval/scienceqa`, download `images`, `pid_splits.json`, `problems.json` from the `data/scienceqa` folder of the ScienceQA [repo](https://github.com/lupantech/ScienceQA).
2. Single-GPU inference and evaluate.
```Shell
CUDA_VISIBLE_DEVICES=0 bash scripts/v1_5/eval/eval_image_sqa.sh
```

### TextVQA

1. Download [`TextVQA_0.5.1_val.json`](https://dl.fbaipublicfiles.com/textvqa/data/TextVQA_0.5.1_val.json) and [images](https://dl.fbaipublicfiles.com/textvqa/images/train_val_images.zip) and extract to `eval/textvqa`.
2. Single-GPU inference and evaluate.
```Shell
CUDA_VISIBLE_DEVICES=0 bash scripts/v1_5/eval/eval_image_textvqa.sh
```

### POPE

1. Download `coco` from [POPE](https://github.com/AoiDragon/POPE/tree/e3e39262c85a6a83f26cf5094022a782cb0df58d/output/coco) and put under `eval/pope`.
2. Single-GPU inference and evaluate.
```Shell
CUDA_VISIBLE_DEVICES=0 bash scripts/v1_5/eval/eval_image_pope.sh
```

### MMBench

1. Download [`mmbench_dev_20230712.tsv`](https://download.openmmlab.com/mmclassification/datasets/mmbench/mmbench_dev_20230712.tsv) and put under `eval/mmbench`.
2. Single-GPU inference.
```Shell
CUDA_VISIBLE_DEVICES=0 bash scripts/v1_5/eval/eval_image_mmbench.sh
```
3. Submit the results to the [evaluation server](https://opencompass.org.cn/leaderboard-multimodal): `eval/mmbench/answers_upload/mmbench_dev_20230712`.

### LLaVA-Bench-in-the-Wild

1. Extract contents of [`llava-bench-in-the-wild`](https://huggingface.co/datasets/liuhaotian/llava-bench-in-the-wild) to `eval/llava-bench-in-the-wild`.
2. Single-GPU inference and evaluate.
```Shell
CUDA_VISIBLE_DEVICES=0 bash scripts/v1_5/eval/eval_image_llavabench.sh
```

### MM-Vet

1. Extract [`mm-vet.zip`](https://github.com/yuweihao/MM-Vet/releases/download/v1/mm-vet.zip) to `eval/mmvet`.
2. Single-GPU inference.
```Shell
CUDA_VISIBLE_DEVICES=0 bash scripts/v1_5/eval/eval_image_mmvet.sh
```