Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,125 @@
|
|
1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
license: cc-by-nc-4.0
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
# For reference on model card metadata, see the spec: https://github.com/huggingface/hub-docs/blob/main/modelcard.md?plain=1
|
3 |
+
# Doc / guide: https://huggingface.co/docs/hub/model-cards
|
4 |
+
datasets:
|
5 |
+
- AudioSet
|
6 |
+
- AudioCaps
|
7 |
+
- Clotho-v2.1
|
8 |
+
metrics:
|
9 |
+
- TODO
|
10 |
+
model-index:
|
11 |
+
- name: whisper-TODO-audio-captioning
|
12 |
+
results:
|
13 |
+
- task:
|
14 |
+
type: audio-captioning
|
15 |
+
name: Audio Captioning
|
16 |
+
dataset:
|
17 |
+
type: TODO
|
18 |
+
name: TODO
|
19 |
+
split: validation
|
20 |
+
metrics:
|
21 |
+
- type: Spider
|
22 |
+
value: TODO
|
23 |
+
- type: SPICE
|
24 |
+
value: TODO
|
25 |
+
- type: CIDEr
|
26 |
+
value: TODO
|
27 |
+
- type: SPIDEr
|
28 |
+
value: TODO
|
29 |
+
- type: METEOR
|
30 |
+
value: TODO
|
31 |
+
- type: SacreBLEU
|
32 |
+
value: TODO
|
33 |
license: cc-by-nc-4.0
|
34 |
+
language:
|
35 |
+
- en
|
36 |
---
|
37 |
+
|
38 |
+
|
39 |
+
# Model Card for Whisper Audio Captioning
|
40 |
+
|
41 |
+
A transformer encoder-decoder model for automatic audio captioning. As opposed to speech-to-text, captioning describes the content of audio clips, such as prominent sounds or environmental noises. This task has numerous practical applications, e.g., for providing access to audio information for people with hearing impairments or improving the searchability of audio content.
|
42 |
+
|
43 |
+
- **Model type:** Whisper encoder-decoder transformer
|
44 |
+
- **Language(s) (NLP):** en
|
45 |
+
- **License:** cc-by-4.0
|
46 |
+
- **Parent Model:** openai/whisper-TODO
|
47 |
+
- **Resources for more information:**
|
48 |
+
- [GitHub Repo](https://github.com/prompteus/audio-captioning)
|
49 |
+
- [Technical Report](TODO)
|
50 |
+
|
51 |
+
|
52 |
+
## Usage
|
53 |
+
|
54 |
+
The model expects an audio clip (up to 30s) to the encoder as an input and information about caption style as forced prefix to the decoder.
|
55 |
+
|
56 |
+
Minimal example:
|
57 |
+
|
58 |
+
```python3
|
59 |
+
# Load model
|
60 |
+
architecture = "openai/whisper-tiny"
|
61 |
+
checkpoint = "TODO"
|
62 |
+
model = audiocap.WhisperForAudioCaptioning.from_pretrained(checkpoint)
|
63 |
+
tokenizer = transformers.WhisperTokenizer.from_pretrained(checkpoint, language="en", task="transcribe")
|
64 |
+
feature_extractor = transformers.WhisperFeatureExtractor.from_pretrained(architecture)
|
65 |
+
|
66 |
+
# Load and preprocess audio
|
67 |
+
input_file = "TODO"
|
68 |
+
audio, sampling_rate = librosa.load(input_file, sr=feature_extractor.sampling_rate)
|
69 |
+
features = feature_extractor(audio, sampling_rate=sampling_rate, return_tensors="pt").input_features
|
70 |
+
|
71 |
+
# Prepare caption style
|
72 |
+
style_prefix = "clotho > caption: "
|
73 |
+
style_prefix_tokens = tokenizer("", text_target=style_prefix, return_tensors="pt", add_special_tokens=False).labels
|
74 |
+
|
75 |
+
# Generate caption
|
76 |
+
model.eval()
|
77 |
+
outputs = model.generate(
|
78 |
+
inputs=features.to(model.device),
|
79 |
+
forced_ac_decoder_ids=style_prefix_tokens,
|
80 |
+
max_length=100,
|
81 |
+
)
|
82 |
+
|
83 |
+
print(tokenizer.batch_decode(outputs, skip_special_tokens=True)[0])
|
84 |
+
```
|
85 |
+
|
86 |
+
Example output:
|
87 |
+
*clotho > caption: Rain is pouring down and thunder is rumbling in the background.*
|
88 |
+
|
89 |
+
The style prefix influences the style of the caption. Model knows 3 styles: `audioset > keywords: `, `audiocaps > caption: `, and `clotho > caption: `. It was finetuned on Clotho and that is the indended "default" style.
|
90 |
+
|
91 |
+
WhisperTokenizer must be initialized with `language="en"` and `task="transcribe"`.
|
92 |
+
|
93 |
+
Our model class `WhisperForAudioCaptioning` can be found in our git repository or here on the HuggingFace Hub in the model repository. The class overrides default Whisper `generate` method to support forcing decoder prefix.
|
94 |
+
|
95 |
+
|
96 |
+
## Training details
|
97 |
+
|
98 |
+
The model was initialized by original speech-to-text `openai/whisper-TODO` weights. Then, it was pretrained on a mix of (1) subset of AudioSet with synthetic labels, (2) AudioCaps captioning dataset and (3) Clotho v2.1 captioning dataset. Finally, it was finetuned on Clotho v2.1 to focus the model on the specific style of the captions. For each traning input, the model was informed about the source of the data, so it can mimic the caption style in all 3 styles.
|
99 |
+
|
100 |
+
During pretraining, the ratio of samples in each batch was approximately 12:3:1 (AudioSet:AudioCaps:Clotho). The pretraining took TODO steps with batch size 32 and learning rate 2e-5. Finetuning was done on Clotho only, and the model was trained for TODO steps with batch size 32 and learning rate 4e-6. All layers except *fc1* layers were frozen during finetuning.
|
101 |
+
|
102 |
+
For more information about the training regime, see the [technical report](TODO).
|
103 |
+
|
104 |
+
|
105 |
+
## Evaluation details
|
106 |
+
|
107 |
+
Metrics reported in the metadata were computed on Clotho v2.1 test split with captions generated using a beam search with 5 beams.
|
108 |
+
|
109 |
+
|
110 |
+
## Limitations
|
111 |
+
|
112 |
+
The captions generated by the model can be misleading or not truthful, even if they appear convincing. The hallucination occurs especially in domains that were not present in the finetuning data.
|
113 |
+
|
114 |
+
While the original speech-to-text checkpoints by OpenAI were trained on multilingual data, our training contains only English captions, and therefore is not expected for the model to support other languages.
|
115 |
+
|
116 |
+
|
117 |
+
|
118 |
+
## Licence
|
119 |
+
|
120 |
+
The model weights are published under non-commercial license CC BY-NC 4.0 as the model was finetuned on a dataset for non-commercial use.
|
121 |
+
|
122 |
+
|
123 |
+
## Contact
|
124 |
+
|
125 |
+
If you'd like to chat about this, please get in touch with is via email at kadlcik`<at>`mail.muni.cz or ahajek`<at>`mail.muni.cz.
|