File size: 24,933 Bytes
32b542e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
# Prepare Data

* By default,   all training data used for this repository will be searched  in the directory `DATA_PATH`. Please specify or change your data location before code running as following:

    ```
    export DATA_PATH='/mnt/lustre/share_data/zhujinguo/open_source_dataset'
    ```


* To make it very easy for you to run the training code, we provide [a toy dataset](https://drive.google.com/file/d/14GZPYqVLiXVYjxRGvC9WO4WK3WiwBPRY/view?usp=sharing), which is a small subset of our pretraing data.
You should download this and unzip this file to `DATA_PATH`.

    With the data of this subset, you can train Uni-Perceiver with  config file [configs/BERT_L12_H192_experiments/4tasks_training_small_datasets.yaml](../configs/BERT_L12_H192_experiments/4tasks_training_small_datasets.yaml).
    Please refer to [pretraining.md](./pretraining.md) for training usage.

* For tasks with a fixed candidate target sets, such as image / video classification (where the target sets are the category labels) and masked language modeling (where the target set is the vocabulary), you also need to perpare the target set file. Please refer to the jupyter notebook [tools/generate_target_sets.ipynb](../tools/generate_target_sets.ipynb) for details.

* For the complete datasets for training our models, please download datasets according to the instructions below:

## Different datasets

### Todo List:
- [x] Imagenet-21k and Imagenet-1k
- [x] books&wiki
- [x] MSCOCO Caption
- [x] YFCC 
- [x] CC12M 
- [x] CC3M 
- [x] Visual Genome
- [x] SBU 
- [x] Kinetics-400 & Kinetics-700
- [x] Moments in Time 
- [x] Flickr30k
- [x] MSVD 
- [x] MSR-VTT
- [x] GLUE 
- [x] VQA 

### Imagenet-1k

1. Please download the images of imagenet dataset from the official website [Imagenet](https://image-net.org/).

2. We provide the annotation files (including train.txt, val.txt and test.txt) on [meta](https://drive.google.com/file/d/1piqII0qGHmK1pop0RjdoFx927hcm1Mny/view).

3. a) Tokenizing imagenet class names to generate "imagenet_class_name_CLIP_with_endoftext.pkl" using [generate_target_sets.ipynb](../tools/generate_target_sets.ipynb)

   b) Or using generated file we provide from [here](https://drive.google.com/file/d/1bgFohNsppe7kksxTbWgSFMoEZuX0szc_/view?usp=sharing) 
4. Organize them as follows:
    ```
    DATA_PATH/
    └── imagenet/
        β”œβ”€β”€ imagenet_class_name_CLIP_with_endoftext.pkl
        β”œβ”€β”€ meta
        β”‚Β Β  β”œβ”€β”€ test.txt
        β”‚Β Β  β”œβ”€β”€ train.txt
        β”‚Β Β  └── val.txt
        β”œβ”€β”€ test
        β”‚Β Β  β”œβ”€β”€ ILSVRC2012_test_00000001.JPEG
        β”‚Β Β  β”œβ”€β”€ ILSVRC2012_test_00000002.JPEG
        β”‚Β Β  β”œβ”€β”€ ILSVRC2012_test_00000003.JPEG
        β”‚Β Β  β”œβ”€β”€ ILSVRC2012_test_00000004.JPEG
        β”‚Β Β  └── ...
        β”œβ”€β”€ train
        β”‚Β Β  β”œβ”€β”€ n01440764
        β”‚   β”‚Β Β  β”œβ”€β”€ n01440764_10026.JPEG
        |   β”‚Β Β  β”œβ”€β”€ n01440764_10027.JPEG
        |   β”‚Β Β  β”œβ”€β”€ n01440764_10029.JPEG
        |   β”‚Β Β  └── ...
        β”‚Β Β  β”œβ”€β”€ n01443537
        |   β”‚Β Β  └── ...   
        β”‚Β Β  β”œβ”€β”€ n01484850
        |   β”‚Β Β  └── ...
        |   └── ...
        └─── val
        Β Β  β”œβ”€β”€ ILSVRC2012_val_00000001.JPEG
        Β Β  β”œβ”€β”€ ILSVRC2012_val_00000002.JPEG
        Β Β  β”œβ”€β”€ ILSVRC2012_val_00000003.JPEG
        Β Β  └── ...

    ```






### Imagenet-22k
1. Please refer to Imagenet-1K dataset. 

2. Meta file is provided from [here](https://drive.google.com/file/d/1TDF0i8tXTB-K-zYOVhsmmocAtgrKpOG8/view?usp=sharing)

3. Imagenet class name file in [generate_target_sets.ipynb](../tools/generate_target_sets.ipynb) for tokenizing is provided from [here](https://drive.google.com/file/d/1cJHD5Ysxfr4tRMqAAwjOah2glfFktiT1/view?usp=sharing). Or you can directly use the CLIP-tokenized imagenet-22K class name files is provided from [here](https://drive.google.com/file/d/1juSGVP8IjERXoM-AwxKRDtLk65p9FTds/view?usp=sharing)

### Books&wiki
1. please download files [wiki.doc](https://drive.google.com/file/d/1rZJ-Nj_SSqwu85tME3wbN8tfGhljfAsf/view) abd [bc1g.doc](https://drive.google.com/file/d/16T5EYqIjO-tAj1OFxz6bnnzEABCusCcv/view).
And  put them together into a file:
    ```
    cat wiki.doc bc1g.doc > bookswiki.doc
    ```
2. <a id="vocab"></a>  a) Tokenizing vocabularies to generate "vocabulary_CLIP_with_endoftext.pkl" using [generate_target_sets.ipynb](../tools/generate_target_sets.ipynb)

   b) Or using generated file we provide from [here](https://drive.google.com/file/d/1omEahjKjeWe0a4PSXEHaGE_WVdiZLf4W/view?usp=sharing) 

3. Then put this files in `DATA_PATH`
    ```
    DATA_PATH/
    β”œβ”€β”€ vocabulary_CLIP_with_endoftext.pkl
    └── bert_pretrain_data/
        └─ bookswiki/
        └── bookswiki.doc
            
    ```
4. you can also download the plain text dataset from [huggingface.co/datasets/wikipedia](https://huggingface.co/datasets/wikipedia) and [huggingface.co/datasets/bookcorpus](https://huggingface.co/datasets/bookcorpus).

### MSCOCO

1. Please download the images of COCO 2014 from [MSCOCO](https://cocodataset.org/#download).
2. Download preprocessed coco captions from Karpathy's homepage: [link](http://cs.stanford.edu/people/karpathy/deepimagesent/caption_datasets.zip) and extract "dataset_coco.json" from zip file.

3. a) You can run the [coco_preprocess.py](./preprocess/coco_preprocess.py) file to split the dataset_coco.json file into train, val and test part:
    
    1. walk into the /data/preprocess folder and open the [coco_preprocess.py](./preprocess/coco_preprocess.py) file;
    2. fill the 'original_json' variable with the path you download the dataset_coco.json file.
    3. fill the 'savepath' with the path you want to save the splited json file.
    4. run the [coco_preprocess.py](./preprocess/coco_preprocess.py) file.
    
    b) Or you can directly use the generated json file we provide from [here](https://drive.google.com/file/d/12XUh4-Lb82RXg7Sa-Vgtut2dhIqrp7Sy/view) 

4. Generating tokenized vocabularies as mentioned in [bookswiki part](#vocab)
5. Organize the files into following structure:
    ```
    DATA_PATH/
    β”œβ”€β”€ vocabulary_CLIP_with_endoftext.pkl
    └── mscoco_dataset/
        β”œβ”€β”€ new_annotations
        β”‚  Β β”œβ”€β”€ captions_test5k.json
        β”‚Β Β  β”œβ”€β”€ captions_train113k.json
        β”‚Β Β  β”œβ”€β”€ captions_val5k.json
        |   └── dataset_coco.json
        └── coco_origin 
        Β Β   β”œβ”€β”€ train2014
            β”‚  Β β”œβ”€β”€ COCO_train2014_000000000009.jpg
            |   β”œβ”€β”€ COCO_train2014_000000000025.jpg
            |   β”œβ”€β”€ COCO_train2014_000000000030.jpg
            β”‚Β Β  └── ...
        Β Β   └── val2014
                β”œβ”€β”€ COCO_val2014_000000000042.jpg
                β”œβ”€β”€ COCO_val2014_000000000073.jpg
                β”œβ”€β”€ COCO_val2014_000000000074.jpg
            Β Β   └── ...


    ```

### Visual Genome
1. Please download the images and region decriptions of visual genome from [VG](https://visualgenome.org/api/v0/api_home.html).

2. a) You can run the [region_descriptions.ipynb](./preprocess/region_descriptions.ipynb) to preprocess the downloaded "region_descriptions.json" file:
    
    1. walk into the /data/preprocess folder and open the [region_descriptions.ipynb](./preprocess/region_descriptions.ipynb);
    2. fill the path of downloaded 'region_descriptions.json' and the path you want to save the processed file.
    3. run the [region_descriptions.ipynb](./preprocess/region_descriptions.ipynb).
    
    b) Or you can directly use the generated json file we provide from [here](https://drive.google.com/file/d/1pnl30qAPr03RpKbdbH13YZI9GtWseEHf/view) 
3. Generating tokenized vocabularies as mentioned in [bookswiki part](#vocab)
4. Organize the files into following structure:

    ```
        DATA_PATH/
        β”œβ”€β”€ vocabulary_CLIP_with_endoftext.pkl
        └── visual_genome/
            β”œβ”€β”€ annotations
            β”‚  Β β”œβ”€β”€ region_descriptions.json
            β”‚Β Β  β”œβ”€β”€ vg_captions_128filter.json
            └── images 
            Β Β   β”œβ”€β”€ VG_100K
                β”‚  Β β”œβ”€β”€ 2.jpg
                |   β”œβ”€β”€ 3.jpg
                |   β”œβ”€β”€ 4.jpg
                β”‚Β Β  └── ...
            Β Β   └── VG_100K_2
                    β”œβ”€β”€ 1.jpg
                    β”œβ”€β”€ 51.jpg
                    β”œβ”€β”€ 52.jpg
                Β Β   └── ...


    ```

### Flickr30k
1. Please download the images of filckr30k according to the instruction of [Flickr30k](http://shannon.cs.illinois.edu/DenotationGraph/).
2. Download [flickr_jsons](https://drive.google.com/file/d/1_dJsD8_YXWtR0124X_RiEgcx1c6B_BUM/view) which provides the annotations of flickr30k images.
3. a) You can run the [process_flickr_caption_json.py](./preprocess/process_flickr_caption_json.py) to preprocess the json file:
    
    1. walk into the /data/preprocess folder and open the [process_flickr_caption_json.py](./preprocess/process_flickr_caption_json.py);
    2. fill the path of downloaded json files and fill the path you want to save the processed json files.
    3. run the [process_flickr_caption_json.py](./preprocess/process_flickr_caption_json.py).
    
    b) Or you can directly use the generated json files (including captions_test.json, captions_train.json and captions_val.json) we provide from [here](https://drive.google.com/file/d/1WIWUKbXfBJd1S0izTe_OuP7bjCFDk2wk/view) 

4. Generating tokenized vocabularies as mentioned in [bookswiki part](#vocab)
5. Organize the files into following structure:

    ```
        DATA_PATH/
         β”œβ”€β”€ vocabulary_CLIP_with_endoftext.pkl
         β”œβ”€β”€ flickr30k/
         β”‚   β”œβ”€β”€ captions_test.json
         β”‚   β”œβ”€β”€ captions_train.json
         β”‚   └── captions_val.json
         └── flickr30k_images
                └──  flickr30k_images
                    └──  flickr30k_images
                        β”œβ”€β”€ 36979.jpg
                        β”œβ”€β”€ 65567.jpg
                 Β Β      └── ...

        ```

### SBU
1. Please download the SBU [url](https://drive.google.com/file/d/1Hfbw8DVSnE3ZAaWZ7C6d6hlUde7Pr_YN/view) and [caption](https://drive.google.com/file/d/1GY_kFyiFqOHAYvjfRdM98LMlAsnFmxic/view?usp=sharing) files.
2. Filling the path of above files in [sbu_download_list.py](./preprocess/sbu/sbu_download_list.py) and run it for generating the download_list.
3. Running the script [sbu_download.sh](./preprocess/sbu/sbu_download.sh) to download the sbu images.
4. a) You can run the [make_sbu_json.py](./preprocess/sbu/make_sbu_json.py) to get the annotation file:
    
    b) Or you can directly download the generated json file [sbucaption.json](https://drive.google.com/file/d/1xFJPvyJNlH0jzqzHRN16Hk5DmKGiGEJE/view) we provide.
5. Generating tokenized vocabularies as mentioned in [bookswiki part](#vocab)
6. Organize the files into following structure:

    ```
        DATA_PATH/
        β”œβ”€β”€ vocabulary_CLIP_with_endoftext.pkl
        └── sbucaption/
            β”œβ”€β”€ annotations
            β”‚  └── sbucaptions.json
            └── images
                β”œβ”€β”€ 4385058960_b0f291553e.jpg
                β”œβ”€β”€ 5148648301_1174ef59bc.jpg
                └── ...

    ```
### CC3M
1. Please download "Train_GCC-training.tsv" and "Validation_GCC-1.1.0-Validation.tsv" from [here](https://ai.google.com/research/ConceptualCaptions/download)
2. Filling the path of "Train_GCC-training.tsv" in [cc3m_train_download_list.py](./preprocess/cc3m/cc3m_train_download_list.py) and run it for generating the training download list.
3.  Filling the path of "Validation_GCC-1.1.0-Validation.tsv" in [cc3m_val_download_list.py](./preprocess/cc3m/cc3m_val_download_list.py) and run it for generating the validation download list.
4. Running the script [cc3m_train_download.sh](./preprocess/cc3m/cc3m_train_download.sh) and [cc3m_val_download.sh](./preprocess/cc3m/cc3m_val_download.sh) to download the cc3m images.
5. Zip (without compression) "train_image", "val_image" by:
    ```
    zip -0 ../train_image.zip ./*
    zip -0 ../val_image.zip ./*

    ```
6. a) You can run the [make_cc3m_train_json.py](./preprocess/cc3m/make_cc3m_train_json.py) and [make_cc3m_val_json.py](./preprocess/cc3m/make_cc3m_val_json.py) to get the annotation file:
    
    b) Or you can directly download the generated json files [train_spacy.json](https://drive.google.com/file/d/1_bqx0xQOQC3bd40GLMC27TyLRi1tHRlC/view) and [val_spacy.json](https://drive.google.com/file/d/11ibsX_K-hgdHiomk9c6JvuAl2kYW8tjt/view) we provide.
7. Generating tokenized vocabularies as mentioned in [bookswiki part](#vocab)
8. Organize the files into following structure:

    ```
        DATA_PATH/
        β”œβ”€β”€ vocabulary_CLIP_with_endoftext.pkl
        └── cc3m/
            β”œβ”€β”€ train_spacy.json
            β”œβ”€β”€ val_spacy.json
            β”œβ”€β”€train_image
            β”‚  Β β”œβ”€β”€ 00000000.jpg
            β”‚Β Β  └── ...
        Β Β   └── val_image
                β”œβ”€β”€ 00000000.jpg
            Β Β   └── ...

    ```

### CC12M
1. Please download "cc12m.tsv" from [here](https://github.com/google-research-datasets/conceptual-12m)
2. Filling the path of "cc12m.tsv" in [cc12m_train_download_list.py](./preprocess/cc12m/cc12m_train_download_list.py) and run it for generating the training download list.
3. Running the script [cc12m_train_download.sh](./preprocess/cc12m/cc12m_train_download.sh) to download the cc12m images.
5. Zip (without compression) "train_image" by:
    ```
    zip -0 ../train_image.zip ./*
    ```
5. a) You can run the [make_cc12m_train_json.py](./preprocess/cc12m/make_cc12m_train_json.py) to get the annotation file:
    
    b) Or you can directly download the generated json file [train_available.json](https://drive.google.com/file/d/1SVHmHpewvmpCbWDCsLSbwQ8lhusQXEIt/view) we provide.
6. Generating tokenized vocabularies as mentioned in [bookswiki part](#vocab)
7. Organize the files into following structure:

    ```
        DATA_PATH/
        β”œβ”€β”€ vocabulary_CLIP_with_endoftext.pkl
        └── c12m/
            β”œβ”€β”€ train_available.json
            └── train_image
               Β β”œβ”€β”€ 00000000.jpg
             Β Β  └── ...

    ```

### Kinetics-400 & Kinetics-700
1. Please download the Kinectics-400 & Kinetics-700 videos according to the instructions of [this](https://github.com/cvdfoundation/kinetics-dataset)

2. a) 

    i. Filling the path of K400's "training" and "validation" folder you download in [k400_construct_csv.py](./preprocess/k400_construct_csv.py) and run it for generating the K400 related files (K400_val.csv, K400_train.csv, categories.txt, annotation.json).

    ii. Filling the path of K700's "training" and "validation" folder you download in [k700_construct_csv.py](./preprocess/k700_construct_csv.py) and run it for generating the K700 related files (K700_val.csv, K700_train.csv, categories.txt, annotation.json).

    iii. Running script [video_categories.ipynb](../tools/video_categories.ipynb) to generate "category_mapping.txt".

    b) Or you can directly download the processed files we provide: [K400](https://drive.google.com/file/d/1YqchifEjoovZYJ77Egn5pHv3E1olRIpq/view?usp=sharing), [K700](https://drive.google.com/file/d/1fHdcBRdU27w7OfNijP0ZBsNbxLQSLfRa/view?usp=sharing)

3. a) Tokenizing K400, K700 class names to generate "k400_class_name_CLIP_with_endoftext.pkl" and "k700_class_name_CLIP_with_endoftext.pkl" using [generate_target_sets.ipynb](../tools/generate_target_sets.ipynb)

   b) Or using generated file we provide from [K400-CLIP](https://drive.google.com/file/d/1V-SpRzugmFgHR6j7ifFLqh7Ao5VW-gM8/view?usp=sharing) and [K700-CLIP](https://drive.google.com/file/d/1lq9WaEWh1lmfBv4pOs8Aj9yTrTxkQc3Z/view?usp=sharing)
   
   
4. Organize the files into following structure:
    ```
    DATA_PATH/
        β”œβ”€β”€ k400_class_name_CLIP_with_endoftext.pkl
        └── K400/
          Β  β”œβ”€β”€ training
            β”‚    β”œβ”€β”€ abseiling
            β”‚    β”‚   β”œβ”€β”€ _4YTwq0-73Y_000044_000054.mp4
            β”‚    β”‚   └── ...
            β”‚    β”œβ”€β”€ air_drumming
        Β Β   β”‚    └── ...
            β”œβ”€β”€ validation/
            β”‚    β”œβ”€β”€ abseiling
            β”‚    β”‚   β”œβ”€β”€ __NrybzYzUg.mkv
            β”‚    β”‚   └── ...
            β”‚    β”œβ”€β”€ air_drumming
        Β Β   β”‚    └── ...
            β”œβ”€β”€ annotation.json
            β”œβ”€β”€ category_mapping.txt
            β”œβ”€β”€ categories.txt
            β”œβ”€β”€ K400_train.csv
            └── K400_val.csv
    ```
    K700 is similar.

### MomentsInTime

1. Please download the MomentsInTime videos according to the instructions of [Official Website](http://moments.csail.mit.edu/)

2. a) 

    i. Filling the path of "training" folder you download in [moments_construct_csv.py](./preprocess/moments_construct_csv.py) and run it for generating the training files (moments_train.csv, categories.txt, annotation.json).

    ii. Running script [video_categories.ipynb](../tools/video_categories.ipynb) to generate "category_mapping.txt".

    b) Or you can directly download the processed files we provide: [moments](https://drive.google.com/file/d/1aXVCBKrocatZfT8TRKv4TuxHkTa7SxMz/view?usp=sharing).
3. a) Tokenizing momentsInTime class names to generate "MiT_class_name_CLIP_with_endoftext.pkl" using [generate_target_sets.ipynb](../tools/generate_target_sets.ipynb)

   b) Or using generated file we provide from [MiT-CLIP](https://drive.google.com/file/d/1xNC8Dld-0x735nO60cwUBYG3gTVvoPC8/view?usp=sharing)

4. Organize the files into following structure:
    ```
    DATA_PATH/
        β”œβ”€β”€ MiT_class_name_CLIP_with_endoftext.pkl
        └── MomentsInTime/
          Β  β”œβ”€β”€ training
            β”‚    β”œβ”€β”€ adult+female+singing
            β”‚    β”‚   β”œβ”€β”€ 0a2b81cb0ec5fde79b8c.mp4
            β”‚    β”‚   └── ...
            β”‚    β”œβ”€β”€ adult+female+speaking
        Β Β   β”‚    └── ...
            β”œβ”€β”€ annotation.json
            β”œβ”€β”€ categories.txt
            β”œβ”€β”€ category_mapping.txt
            └── moments_train.csv
    ```


### MSVD
1. Download MSVD videos "YoutTubeClips.tar" from [here](https://www.cs.utexas.edu/users/ml/clamp/videoDescription/) and preprocessed "txt_labels" from [here](https://github.com/nasib-ullah/video-captioning-models-in-Pytorch/tree/main/MSVD/captions).
2. a) Fill the path of downloaded files in [msvd_preprocess.py](./preprocess/msvd_preprocess.py)  to generate the annotation files (caption_msvd_train_cocostyle.json, caption_msvd_val_cocostyle.json, caption_msvd_test_cocostyle.json)
    
    b) Or directly download the annotation files we provide [new_annotations](https://drive.google.com/file/d/1VHT8waNVp8LUFlfY_YACCbVrzBQW3sWy/view)

3. Generating tokenized vocabularies as mentioned in [bookswiki part](#vocab)
4. Organize the files into following structure:
    ```
    DATA_PATH/
        β”œβ”€β”€ vocabulary_CLIP_with_endoftext.pkl
        └── msvd_dataset/
          Β  β”œβ”€β”€ new_annotations
            β”‚    β”œβ”€β”€ caption_msvd_test_cocostyle.json
            β”‚    β”œβ”€β”€ caption_msvd_train_cocostyle
        Β Β   β”‚    └── caption_msvd_val_cocostyle
            β”œβ”€β”€ txt_labels
            β”‚    β”œβ”€β”€ sents_test_lc_nopunc.txt
            β”‚    β”œβ”€β”€ sents_train_lc_nopunc.txt
            β”‚    β”œβ”€β”€ sents_train_lc_nopunc.txt
        Β Β   β”‚    └── youtube_mapping.txt
            └── YouTubeClips
                 β”œβ”€β”€ _0nX-El-ySo_83_93.avi
        Β Β        └── ...
    ```
### MSR-VTT
1. Download MSRVTT videos ("train_val_videos.zip", "test_videos.zip") and  annotation files ("train_val_annotation.zip", "test_videodatainfo.zip") from [here](https://www.mediafire.com/folder/h14iarbs62e7p/shared) and download dataset split info from [here](https://github.com/ArrowLuo/CLIP4Clip/releases/download/v0.0/msrvtt_data.zip).
2. Unzip downloaded files above, fill the paths of "test_videodatainfo.json", "train_val_videodatainfo.json", "MSRVTT_train.9k.csv", "MSRVTT_JSFUSION_test.csv" in the  [msrvtt_dataprocess_1k.ipynb](./preprocess/msrvtt_dataprocess_1k.ipynb) 
    
    b) Or directly download the annotation files ("caption_msrvtt_1k_trainval_cocostyle.json","caption_msrvtt_1k_test_cocostyle.json") we provide [annotations_new](https://drive.google.com/file/d/1ZnA4hEic6x9D7dfaEUPoa6MlQ30rITom/view)
3. Generating tokenized vocabularies as mentioned in [bookswiki part](#vocab)
4. Organize the files into following structure:
    ```
    DATA_PATH/
        β”œβ”€β”€ vocabulary_CLIP_with_endoftext.pkl
        └── msrvtt_dataset/
          Β  β”œβ”€β”€ annotations_new
            β”‚    β”œβ”€β”€ caption_msrvtt_1k_trainval_cocostyle.json
        Β Β   β”‚    └── caption_msrvtt_1k_test_cocostyle.json
            └── videos
                 β”œβ”€β”€ video0.mp4
        Β Β        └── ...
    ```

### VQA

1. Download VQA meta data from the datalink [vilbert](https://github.com/jiasenlu/vilbert_beta/tree/master/data) provided, files including:
    - dictionary.pkl
    - train_ids.pkl
    - val_ids.pkl
    - train_target.pkl
    - trainval_ans2label.pkl
    - val_target.pkl
    - trainval_label2ans.pkl

2. Download VG questions and answers from [here](https://drive.google.com/drive/folders/10XHRXg07lNbdZQrREhOLYVM3N0LrkTxB)
    
    
    
    
    

3. Download VQA annotations from the [link](https://visualqa.org/download.html) xmodaler provided, files including:
    - vg_target.pkl
    - VG_questions2.json
    - download
    - VG_annotations.json
4. Download VQA annotations from [VQA](https://visualqa.org/download.html) website, files including:   
    - v2_OpenEnded_mscoco_test2015_questions.json
    - v2_OpenEnded_mscoco_train2014_questions.json
    - v2_OpenEnded_mscoco_val2014_questions.json

5. a) Tokenizing all the possible answers using [generate_target_sets.ipynb](../tools/generate_target_sets.ipynb).

    b) Or you can use the tokenized answers we provide [VQA_Answers](https://drive.google.com/file/d/1X-1blHh2MrYhDq9bkdndNVRZ-49VCsuz/view?usp=sharing).
6. Organize the files into following structure:
    ```
    DATA_PATH/
    β”œβ”€β”€ vocabulary_CLIP_with_endoftext.pkl
    β”œβ”€β”€ mscoco_dataset/
    |    └── coco_origin 
    |   Β Β   β”œβ”€β”€ train2014
    |       β”‚  Β β”œβ”€β”€ COCO_train2014_000000000009.jpg
    |       |   β”œβ”€β”€ COCO_train2014_000000000025.jpg
    |       |   β”œβ”€β”€ COCO_train2014_000000000030.jpg
    |       β”‚Β Β  └── ...
    |   Β Β   └── val2014
    |           β”œβ”€β”€ COCO_val2014_000000000042.jpg
    |           β”œβ”€β”€ COCO_val2014_000000000073.jpg
    |           β”œβ”€β”€ COCO_val2014_000000000074.jpg
    |       Β Β   └── ...
    └── VQA
        β”œβ”€β”€ trainval_ans2label.pkl
        β”œβ”€β”€ trainval_label2ans.pkl
        β”œβ”€β”€ v2_OpenEnded_mscoco_train2014_questions.json
        β”œβ”€β”€ v2_OpenEnded_mscoco_val2014_questions.json
        β”œβ”€β”€ v2_OpenEnded_mscoco_test-dev2015_questions.json
        β”œβ”€β”€ val_target.pkl
        β”œβ”€β”€ VG_questions2.json
        β”œβ”€β”€ vg_target.pkl
        └── coco_map.json


    ```
### GLUE
1. Follow the instructions of [this](https://github.com/nyu-mll/GLUE-baselines) to download GLUE benchmark data and refer to [fairseq](https://github.com/facebookresearch/fairseq/blob/main/examples/roberta/README.glue.md) to preprocess datasets.
2. a) Tokenizing GLUE datasets using [generate_target_sets.ipynb](../tools/generate_target_sets.ipynb).

    b) Or you can use the tokenized answers we provide [GLUE_classnames](https://drive.google.com/file/d/1HR7xHsIRsS4iUwGr3CX6h5z_dVn-EJt-/view?usp=sharing).

3. Organize the files into following structure:
```    
    DATA_PATH/
        β”œβ”€β”€ GLUE_classnames
        └── bert_pretrain_data/
          Β  └── glue_data
                 β”œβ”€β”€ CoLA
                 β”œβ”€β”€ CoLA-bin
                 β”œβ”€β”€ diagnostic
                 β”œβ”€β”€ MNLI
                 β”œβ”€β”€ MNLI-bin
                 β”œβ”€β”€ MRPC
                 β”œβ”€β”€ MRPC-bin
                 β”œβ”€β”€ QNLI
                 β”œβ”€β”€ QNLI-bin
                 β”œβ”€β”€ QQP
                 β”œβ”€β”€ QQP-bin
                 β”œβ”€β”€ RTE
                 β”œβ”€β”€ RTE-bin
                 β”œβ”€β”€ SST-2
                 β”œβ”€β”€ SST-2-bin
                 β”œβ”€β”€ STS-B
                 β”œβ”€β”€ STS-B-bin
        Β Β        └── WNLI
```