File size: 10,045 Bytes
e857f97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
We provide the **off-the-shelf** scripts in the [scripts folder](scripts).

## Training LanguageBind 


<div align="center">
<table border="1" width="100%">
    <tr align="center">
        <th>Cache of pretrained weight</th><th>Baidu Yun</th><th>Google Cloud</th><th>Peking University Yun</th>
    </tr>
    <tr align="center">
        <td>Large</td><td><a href="https://pan.baidu.com/s/1co46bkuUJXr8ePPKp1WWgA?pwd=ofm6">Link</a></td><td><a href="https://drive.google.com/drive/folders/1VQYZlqfKmCMuHffypf5F96odyMCEI87H?usp=drive_link">Link</a></td><td><a href="https://disk.pku.edu.cn:443/link/9CA764E6307790B01D2D4F7E314E8E43">Link</a></td>
    </tr>
    <tr align="center">
        <td>Huge</td><td><a href="https://pan.baidu.com/s/1QLpyXEYunoXS-oqGsvzKKA?pwd=vgo2">Link</a></td><td>-</td><td><a href="https://disk.pku.edu.cn:443/link/720A77A7DB9EFD167C5AC8E3FC4B6068">Link</a></td>
    </tr>
</table>
</div>


For example, to **train** LanguageBind on **Depth-Language** with 8 GPUs (1 nodes x 8 GPUs).
* First download the cache of pretrained weight above. and specify `CACHE_DIR=path/to/LanguageBind`.
* The second step is to develop a path to `ANNOTATION` and `DATA` [here](https://github.com/PKU-YuanGroup/LanguageBind/blob/main/data/base_datasets.py#L37) according to the [dataset preparation](https://github.com/PKU-YuanGroup/LanguageBind#-vidal-10m).
* Then you can run

```bash
CACHE_DIR="/path/to/LanguageBind"
ANNOTATION="path/to/data"
cd /path/to/LanguageBind
TORCH_DISTRIBUTED_DEBUG=DETAIL HF_DATASETS_OFFLINE=1 TRANSFORMERS_OFFLINE=1 torchrun --nnodes=1 --nproc_per_node 8 \
    -m main  \
    --train-data ${ANNOTATION} \
    --train-num-samples 3020000 \
    --clip-type "dl" --max-depth 10 \
    --do_train \
    --lock-text --lock-image --text-type "polish_mplug" \
    --init-temp 0.07 --learn-temp \
    --model "ViT-L-14" --cache-dir ${CACHE_DIR} \
    --convert_to_lora --lora_r 2 \
    --lr 5e-4 --coef-lr 1e-3 \
    --beta1 0.9 --beta2 0.98 --wd 0.2 --eps 1e-6 \
    --num-frames 1 --force-patch-dropout 0.5 \
    --epochs 1 --batch-size 128 --accum-freq 1 --warmup 200 \
    --precision "amp" --workers 10 --video-decode-backend "imgs" \
    --save-frequency 1 --log-every-n-steps 20 --report-to "tensorboard" --resume "latest" \
    --do_eval \
    --val_d_cls_data "NYUV2"
```


## Validating LanguageBind 

For example, to **validate** LanguageBind on **Depth-Language** with 1 GPUs.
* First specify ```RESUME```.
* The second step is to prepare the [downstream dataset](https://github.com/PKU-YuanGroup/LanguageBind/blob/main/TRAIN_AND_VALIDATE.md#downstream-datasets).
* Then you can run

```bash
CACHE_DIR="/path/to/LanguageBind"
RESUME="thermal_language.pt"
ANNOTATION="path/to/data"
cd /path/to/LanguageBind
TORCH_DISTRIBUTED_DEBUG=DETAIL HF_DATASETS_OFFLINE=1 TRANSFORMERS_OFFLINE=1 torchrun --nproc_per_node 1 \
    -m main  \
    --train-data ${ANNOTATION} \
    --train-num-samples 3020000 \
    --clip-type "dl" --max-depth 10 \
    --lock-text --lock-image --text-type "polish_mplug" \
    --init-temp 0.07 --learn-temp \
    --model "ViT-L-14" --cache-dir ${CACHE_DIR} \
    --convert_to_lora --lora_r 2 \
    --lr 5e-4 --coef-lr 1e-3 \
    --beta1 0.9 --beta2 0.98 --wd 0.2 --eps 1e-6 \
    --num-frames 1 --force-patch-dropout 0.5 \
    --epochs 1 --batch-size 128 --accum-freq 1 --warmup 200 \
    --precision "amp" --workers 10 --video-decode-backend "imgs" \
    --save-frequency 1 --log-every-n-steps 20 --report-to "tensorboard" --resume ${RESUME} \
    --do_eval \
    --val_d_cls_data "NYUV2"
```

## Downstream datasets

### Depth
NYU V2 dataset is downloaded from [this repo](https://github.com/TUI-NICR/nicr-scene-analysis-datasets/tree/main/nicr_scene_analysis_datasets/datasets/nyuv2) and we reformat them to conform to the standard ImageNet format. We also provide data as follows. Change the ```data_root``` [here](https://github.com/PKU-YuanGroup/LanguageBind/blob/main/data/build_datasets.py#L221).

<div align="center">
<table border="1" width="100%">
    <tr align="center">
        <th>Datasets</th><th>Baidu Yun</th><th>Google Cloud</th><th>Peking University Yun</th>
    </tr>
    <tr align="center">
        <td>NYU</td><td><a href="https://pan.baidu.com/s/1AGOG8U3F7W8AvJiEmuzs-A?pwd=1dsg">Link</a></td><td><a href="https://drive.google.com/file/d/1CltzrTBLFqLxJzpztSIN-5ZosZpXQQ6u/view?usp=sharing">Link</a></td><td><a href="https://disk.pku.edu.cn:443/link/7D7B164DEA64059793D3C3E3A65C0F64">Link</a></td>
    </tr>
</table>
</div>

### Video
Video datasets are downloaded from [this repo](https://github.com/jpthu17/HBI) and we show the folder structure. Change the ```data_root``` [here](https://github.com/PKU-YuanGroup/LanguageBind/blob/main/data/build_datasets.py#L74).

### Audio
Audio datasets are downloaded from [this repo](https://github.com/OFA-Sys/ONE-PEACE/blob/main/datasets.md#audio) and Audioset from [here](https://github.com/qiuqiangkong/audioset_tagging_cnn#1-download-dataset).We reformat them to conform to the standard ImageNet format. Change the ```data_root``` [here1](https://github.com/PKU-YuanGroup/LanguageBind/blob/main/data/build_datasets.py#L144) and [here2](https://github.com/PKU-YuanGroup/LanguageBind/blob/main/data/build_datasets.py#L159).

### Infrared (Thermal)
We download LLVIP from [official website](https://bupt-ai-cz.github.io/LLVIP/), and FLIR from [here](https://www.flir.com/oem/adas/adas-dataset-form/). We reformat them to conform to the standard ImageNet format. Change the ```data_root``` [here](https://github.com/PKU-YuanGroup/LanguageBind/blob/main/data/build_datasets.py#L233). We also provide the processed data as follows.

<div align="center">
<table border="1" width="100%">
    <tr align="center">
        <th>Datasets</th><th>Baidu Yun</th><th>Google Cloud</th><th>Peking University Yun</th>
    </tr>
    <tr align="center">
        <td>LLVIP</td><td><a href="https://pan.baidu.com/s/15HPVr016F7eO9005NDRJTg?pwd=46fh">Link</a></td><td><a href="https://drive.google.com/file/d/1RfKNR8q6dHiAHB4OlYecnkUSx-ghLuEO/view?usp=drive_link">Link</a></td><td><a href="https://disk.pku.edu.cn:443/link/30D592EA37AC7C411264801A74994376">Link</a></td>
    </tr>
    <tr align="center">
        <td>FLIR V1</td><td><a href="https://pan.baidu.com/s/1ZDSo5VPxJ4SA7wS_rNk0uQ?pwd=l491">Link</a></td><td><a href="https://drive.google.com/file/d/1CezCLJ4GUfPMFimitPfK40OV2j2Kr8t8/view?usp=drive_link">Link</a></td><td><a href="https://disk.pku.edu.cn:443/link/AD89D6ADE2CAC2407B00650870CBBDEC">Link</a></td>
    </tr>
    <tr align="center">
        <td>FLIR V2</td><td><a href="https://pan.baidu.com/s/16xdr2aQkHo3zJ4KbaTmO3Q?pwd=tj9f">Link</a></td><td><a href="https://drive.google.com/file/d/1Z2ThG5QH-9biFI2-Z8k2fBKSA6Nrees6/view?usp=drive_link">Link</a></td><td><a href="https://disk.pku.edu.cn:443/link/E06C010970B0ED51926700D2F7A21EA8">Link</a></td>
    </tr>
</table>
</div>

### Folder structure
```bash
downstream_datasets
β”œβ”€β”€ Audio
β”‚Β Β  β”œβ”€β”€ audiocaps
β”‚Β Β  β”‚   └── audio
β”‚Β Β  β”‚       β”œβ”€β”€ test
β”‚Β Β  β”‚       β”œβ”€β”€ train
β”‚Β Β  β”‚       └── val
β”‚   β”œβ”€β”€ audioset
β”‚Β Β  β”‚   β”œβ”€β”€ balanced_train_segments
β”‚Β Β  β”‚   β”œβ”€β”€ eval_segments
β”‚Β Β  β”‚   └── unbalanced_train_segments
β”‚Β Β  β”‚       β”œβ”€β”€ unbalanced_train_segments_part00
β”‚Β Β  β”‚       β”œβ”€β”€ unbalanced_train_segments_part01
β”‚Β Β  β”‚       β”œβ”€β”€ ...
β”‚Β Β  β”‚       └── unbalanced_train_segments_part40
β”‚   β”œβ”€β”€ clotho
β”‚Β Β  β”‚   β”œβ”€β”€ CLOTHO_retrieval_dataset
β”‚Β Β  β”‚   └── evaluation
β”‚   β”œβ”€β”€ esc50
β”‚Β Β  β”‚   └── test
β”‚Β Β  β”‚       β”œβ”€β”€ airplane
β”‚Β Β  β”‚       β”œβ”€β”€ breathing
β”‚Β Β  β”‚       β”œβ”€β”€ ...
β”‚Β Β  β”‚       └── wind
β”œβ”€β”€ laionaudio
β”‚Β Β  β”‚   β”œβ”€β”€ audios
β”‚Β Β  β”‚   β”œβ”€β”€ freesound_no_overlap
β”‚Β Β  β”‚   └── jsons
β”œβ”€β”€ vggsound
β”‚       └── test
β”‚           β”œβ”€β”€ air\ conditioning\ noise
β”‚           β”œβ”€β”€ air\ horn
β”‚           β”œβ”€β”€ ...
β”‚           └── zebra\ braying
β”œβ”€β”€ Depth
β”‚Β Β  β”œβ”€β”€ nyuv2
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ data
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── val
β”‚Β Β  β”‚Β Β  β”‚Β Β      β”œβ”€β”€ bathroom
β”‚Β Β  β”‚Β Β  β”‚Β Β      β”œβ”€β”€ bedroom
β”‚Β Β  β”‚Β Β  β”‚Β Β      β”œβ”€β”€ bookstore
β”‚Β Β  β”‚Β Β  β”‚Β Β      β”œβ”€β”€ classroom
β”‚Β Β  β”‚Β Β  β”‚Β Β      β”œβ”€β”€ dining_room
β”‚Β Β  β”‚Β Β  β”‚Β Β      β”œβ”€β”€ home_office
β”‚Β Β  β”‚Β Β  β”‚Β Β      β”œβ”€β”€ kitchen
β”‚Β Β  β”‚Β Β  β”‚Β Β      β”œβ”€β”€ living_room
β”‚Β Β  β”‚Β Β  β”‚Β Β      β”œβ”€β”€ office
β”‚Β Β  β”‚Β Β  β”‚Β Β      └── others
β”œβ”€β”€ Thermal
β”‚Β Β  β”œβ”€β”€ flirv1
β”‚Β Β  β”‚Β Β  └── val
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ bicycle
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ car
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ dog
β”‚Β Β  β”‚Β Β      └── person
β”‚Β Β  β”œβ”€β”€ flirv2
β”‚Β Β  β”‚Β Β  └── val
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ bike
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ bus
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ car
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ hydrant
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ light
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ motor
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ other\ vehicle
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ person
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ sign
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ skateboard
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ stroller
β”‚Β Β  β”‚Β Β      └── truck
β”‚Β Β  β”œβ”€β”€ llvip
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ train
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ background
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── person
β”‚Β Β  β”‚Β Β  └── val
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ background
β”‚Β Β  β”‚Β Β      └── person
└── VideoTextRetrieval
    β”œβ”€β”€ vtRetdata
    β”‚Β Β  β”œβ”€β”€ ActivityNet
    β”‚Β Β  β”‚Β Β  └── Videos
    β”‚Β Β  β”‚Β Β      └── Activity_Videos
    β”‚Β Β  β”œβ”€β”€ Didemo
    β”‚Β Β  β”‚Β Β  └── videos
    β”‚Β Β  β”œβ”€β”€ MSRVTT
    β”‚Β Β  β”‚Β Β  └── MSRVTT_Videos
    β”‚Β Β  └── MSVD
    β”‚Β Β      └── MSVD_Videos
```