Update README.md
Browse files
README.md
CHANGED
@@ -3,197 +3,206 @@ library_name: transformers
|
|
3 |
tags: []
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
tags: []
|
4 |
---
|
5 |
|
6 |
+
# Huggingface Implementation of AV-HuBERT on the MuAViC Dataset
|
7 |
+
|
8 |
+
This repository contains a Huggingface implementation of the AV-HuBERT (Audio-Visual Hidden Unit BERT) model, specifically trained and tested on the MuAViC (Multilingual Audio-Visual Corpus) dataset. AV-HuBERT is a self-supervised model designed for audio-visual speech recognition, leveraging both audio and visual modalities to achieve robust performance, especially in noisy environments.
|
9 |
+
|
10 |
+
|
11 |
+
Key features of this repository include:
|
12 |
+
|
13 |
+
- Pre-trained Models: Access pre-trained AV-HuBERT models fine-tuned on the MuAViC dataset. The pre-trained model been exported from [MuAViC](https://github.com/facebookresearch/muavic) repository.
|
14 |
+
|
15 |
+
- Inference scripts: Easily pipelines using Huggingface’s interface.
|
16 |
+
|
17 |
+
- Data preprocessing scripts: Including normalize frame rate, extract lips and audio.
|
18 |
+
|
19 |
+
### Inference code
|
20 |
+
|
21 |
+
```sh
|
22 |
+
git clone https://github.com/nguyenvulebinh/AV-HuBERT-S2S.git
|
23 |
+
cd AV-HuBERT-S2S
|
24 |
+
conda create -n avhuberts2s python=3.9
|
25 |
+
conda activate avhuberts2s
|
26 |
+
pip install -r requirements.txt
|
27 |
+
python run_example.py
|
28 |
+
```
|
29 |
+
|
30 |
+
```python
|
31 |
+
from src.model.avhubert2text import AV2TextForConditionalGeneration
|
32 |
+
from src.dataset.load_data import load_feature
|
33 |
+
from transformers import Speech2TextTokenizer
|
34 |
+
import torch
|
35 |
+
|
36 |
+
if __name__ == "__main__":
|
37 |
+
# Load pretrained english model
|
38 |
+
model = AV2TextForConditionalGeneration.from_pretrained('nguyenvulebinh/AV-HuBERT')
|
39 |
+
tokenizer = Speech2TextTokenizer.from_pretrained('nguyenvulebinh/AV-HuBERT')
|
40 |
+
|
41 |
+
# cuda
|
42 |
+
model = model.cuda().eval()
|
43 |
+
|
44 |
+
# Load normalized input data
|
45 |
+
sample = load_feature(
|
46 |
+
'./example/lip_movement.mp4',
|
47 |
+
"./example/noisy_audio.wav"
|
48 |
+
)
|
49 |
+
|
50 |
+
# cuda
|
51 |
+
audio_feats = sample['audio_source'].cuda()
|
52 |
+
video_feats = sample['video_source'].cuda()
|
53 |
+
attention_mask = torch.BoolTensor(audio_feats.size(0), audio_feats.size(-1)).fill_(False).cuda()
|
54 |
+
|
55 |
+
# Generate output sequence using HF interface
|
56 |
+
output = model.generate(
|
57 |
+
audio_feats,
|
58 |
+
attention_mask=attention_mask,
|
59 |
+
video=video_feats,
|
60 |
+
)
|
61 |
+
|
62 |
+
# decode output sequence
|
63 |
+
print(tokenizer.batch_decode(output, skip_special_tokens=True))
|
64 |
+
|
65 |
+
# check output
|
66 |
+
assert output.detach().cpu().numpy().tolist() == [[ 2, 16, 130, 516, 8, 339, 541, 808, 210, 195, 541, 79, 130, 317, 269, 4, 2]]
|
67 |
+
print("Example run successfully")
|
68 |
+
```
|
69 |
+
|
70 |
+
### Data preprocessing scripts
|
71 |
+
|
72 |
+
```sh
|
73 |
+
mkdir model-bin
|
74 |
+
cd model-bin
|
75 |
+
wget https://huggingface.co/nguyenvulebinh/AV-HuBERT/resolve/main/20words_mean_face.npy .
|
76 |
+
wget https://huggingface.co/nguyenvulebinh/AV-HuBERT/resolve/main/shape_predictor_68_face_landmarks.dat .
|
77 |
+
|
78 |
+
# raw video only support 4:3 ratio now
|
79 |
+
cp raw_video.mp4 ./example/
|
80 |
+
|
81 |
+
python src/dataset/video_to_audio_lips.py
|
82 |
+
```
|
83 |
+
|
84 |
+
### Pretrained model
|
85 |
+
|
86 |
+
<table align="center">
|
87 |
+
<tr>
|
88 |
+
<th>Task</th>
|
89 |
+
<th>Languages</th>
|
90 |
+
<th>Huggingface</th>
|
91 |
+
</tr>
|
92 |
+
<tr>
|
93 |
+
<td rowspan="10">AVSR</td>
|
94 |
+
<th>ar</th>
|
95 |
+
<th><a href="todo">TODO</a></th>
|
96 |
+
</tr>
|
97 |
+
<tr>
|
98 |
+
<th>de</th>
|
99 |
+
<th><a href="todo">TODO</a></th>
|
100 |
+
</tr>
|
101 |
+
<tr>
|
102 |
+
<th>el</th>
|
103 |
+
<th><a href="todo">TODO</a></th>
|
104 |
+
</tr>
|
105 |
+
<tr>
|
106 |
+
<th>en</th>
|
107 |
+
<th><a href="nguyenvulebinh/AV-HuBERT">English Chekpoint</a></th>
|
108 |
+
</tr>
|
109 |
+
<tr>
|
110 |
+
<th>es</th>
|
111 |
+
<th><a href="todo">TODO</a></th>
|
112 |
+
</tr>
|
113 |
+
<tr>
|
114 |
+
<th>fr</th>
|
115 |
+
<th><a href="todo">TODO</a></th>
|
116 |
+
</tr>
|
117 |
+
<tr>
|
118 |
+
<th>it</th>
|
119 |
+
<th><a href="todo">TODO</a></th>
|
120 |
+
</tr>
|
121 |
+
<tr>
|
122 |
+
<th>pt</th>
|
123 |
+
<th><a href="todo">TODO</a></th>
|
124 |
+
</tr>
|
125 |
+
<tr>
|
126 |
+
<th>ru</th>
|
127 |
+
<th><a href="todo">TODO</a></th>
|
128 |
+
</tr>
|
129 |
+
<tr>
|
130 |
+
<th>ar,de,el,es,fr,it,pt,ru</th>
|
131 |
+
<th><a href="todo">TODO</a></th>
|
132 |
+
</tr>
|
133 |
+
<tr>
|
134 |
+
<td rowspan="13">AVST</td>
|
135 |
+
<th>en-el</th>
|
136 |
+
<th><a href="todo">TODO</a></th>
|
137 |
+
</tr>
|
138 |
+
<tr>
|
139 |
+
<th>en-es</th>
|
140 |
+
<th><a href="todo">TODO</a></th>
|
141 |
+
</tr>
|
142 |
+
<tr>
|
143 |
+
<th>en-fr</th>
|
144 |
+
<th><a href="todo">TODO</a></th>
|
145 |
+
</tr>
|
146 |
+
<tr>
|
147 |
+
<th>en-it</th>
|
148 |
+
<th><a href="todo">TODO</a></th>
|
149 |
+
</tr>
|
150 |
+
<tr>
|
151 |
+
<th>en-pt</th>
|
152 |
+
<th><a href="todo">TODO</a></th>
|
153 |
+
</tr>
|
154 |
+
<tr>
|
155 |
+
<th>en-ru</th>
|
156 |
+
<th><a href="todo">TODO</a></th>
|
157 |
+
</tr>
|
158 |
+
<tr>
|
159 |
+
<th>el-en</th>
|
160 |
+
<th><a href="todo">TODO</a></th>
|
161 |
+
</tr>
|
162 |
+
<tr>
|
163 |
+
<th>es-en</th>
|
164 |
+
<th><a href="todo">TODO</a></th>
|
165 |
+
</tr>
|
166 |
+
<tr>
|
167 |
+
<th>fr-en</th>
|
168 |
+
<th><a href="todo">TODO</a></th>
|
169 |
+
</tr>
|
170 |
+
<tr>
|
171 |
+
<th>it-en</th>
|
172 |
+
<th><a href="todo">TODO</a></th>
|
173 |
+
</tr>
|
174 |
+
<tr>
|
175 |
+
<th>pt-en</th>
|
176 |
+
<th><a href="todo">TODO</a></th>
|
177 |
+
</tr>
|
178 |
+
<tr>
|
179 |
+
<th>ru-en</th>
|
180 |
+
<th><a href="todo">TODO</a></th>
|
181 |
+
</tr>
|
182 |
+
<tr>
|
183 |
+
<th>{el,es,fr,it,pt,ru}-en</th>
|
184 |
+
<th><a href="todo">TODO</a></th>
|
185 |
+
</tr>
|
186 |
+
</table>
|
187 |
+
|
188 |
+
|
189 |
+
## Acknowledgments
|
190 |
+
|
191 |
+
**AV-HuBERT**: A significant portion of the codebase in this repository has been adapted from the original AV-HuBERT implementation.
|
192 |
+
|
193 |
+
**MuAViC Repository**: We also gratefully acknowledge the creators of the MuAViC dataset and repository for providing the pre-trained models used in this project
|
194 |
+
|
195 |
+
## License
|
196 |
+
|
197 |
+
CC-BY-NC 4.0
|
198 |
+
|
199 |
+
## Citation
|
200 |
+
|
201 |
+
```bibtex
|
202 |
+
@article{anwar2023muavic,
|
203 |
+
title={MuAViC: A Multilingual Audio-Visual Corpus for Robust Speech Recognition and Robust Speech-to-Text Translation},
|
204 |
+
author={Anwar, Mohamed and Shi, Bowen and Goswami, Vedanuj and Hsu, Wei-Ning and Pino, Juan and Wang, Changhan},
|
205 |
+
journal={arXiv preprint arXiv:2303.00628},
|
206 |
+
year={2023}
|
207 |
+
}
|
208 |
+
```
|