JotunnBurton commited on
Commit
0c4e2a8
·
verified ·
1 Parent(s): 2689609

Upload 9 files

Browse files
emotional/clap-htsat-fused/.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
emotional/clap-htsat-fused/README.md ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+ # Model card for CLAP
5
+
6
+ Model card for CLAP: Contrastive Language-Audio Pretraining
7
+
8
+ ![clap_image](https://s3.amazonaws.com/moonup/production/uploads/1678811100805-62441d1d9fdefb55a0b7d12c.png)
9
+
10
+
11
+ # Table of Contents
12
+
13
+ 0. [TL;DR](#TL;DR)
14
+ 1. [Model Details](#model-details)
15
+ 2. [Usage](#usage)
16
+ 3. [Uses](#uses)
17
+ 4. [Citation](#citation)
18
+
19
+ # TL;DR
20
+
21
+ The abstract of the paper states that:
22
+
23
+ > Contrastive learning has shown remarkable success in the field of multimodal representation learning. In this paper, we propose a pipeline of contrastive language-audio pretraining to develop an audio representation by combining audio data with natural language descriptions. To accomplish this target, we first release LAION-Audio-630K, a large collection of 633,526 audio-text pairs from different data sources. Second, we construct a contrastive language-audio pretraining model by considering different audio encoders and text encoders. We incorporate the feature fusion mechanism and keyword-to-caption augmentation into the model design to further enable the model to process audio inputs of variable lengths and enhance the performance. Third, we perform comprehensive experiments to evaluate our model across three tasks: text-to-audio retrieval, zero-shot audio classification, and supervised audio classification. The results demonstrate that our model achieves superior performance in text-to-audio retrieval task. In audio classification tasks, the model achieves state-of-the-art performance in the zero-shot setting and is able to obtain performance comparable to models' results in the non-zero-shot setting. LAION-Audio-630K and the proposed model are both available to the public.
24
+
25
+
26
+ # Usage
27
+
28
+ You can use this model for zero shot audio classification or extracting audio and/or textual features.
29
+
30
+ # Uses
31
+
32
+ ## Perform zero-shot audio classification
33
+
34
+ ### Using `pipeline`
35
+
36
+ ```python
37
+ from datasets import load_dataset
38
+ from transformers import pipeline
39
+
40
+ dataset = load_dataset("ashraq/esc50")
41
+ audio = dataset["train"]["audio"][-1]["array"]
42
+
43
+ audio_classifier = pipeline(task="zero-shot-audio-classification", model="laion/clap-htsat-fused")
44
+ output = audio_classifier(audio, candidate_labels=["Sound of a dog", "Sound of vaccum cleaner"])
45
+ print(output)
46
+ >>> [{"score": 0.999, "label": "Sound of a dog"}, {"score": 0.001, "label": "Sound of vaccum cleaner"}]
47
+ ```
48
+
49
+ ## Run the model:
50
+
51
+ You can also get the audio and text embeddings using `ClapModel`
52
+
53
+ ### Run the model on CPU:
54
+
55
+ ```python
56
+ from datasets import load_dataset
57
+ from transformers import ClapModel, ClapProcessor
58
+
59
+ librispeech_dummy = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
60
+ audio_sample = librispeech_dummy[0]
61
+
62
+ model = ClapModel.from_pretrained("laion/clap-htsat-fused")
63
+ processor = ClapProcessor.from_pretrained("laion/clap-htsat-fused")
64
+
65
+ inputs = processor(audios=audio_sample["audio"]["array"], return_tensors="pt")
66
+ audio_embed = model.get_audio_features(**inputs)
67
+ ```
68
+
69
+ ### Run the model on GPU:
70
+
71
+ ```python
72
+ from datasets import load_dataset
73
+ from transformers import ClapModel, ClapProcessor
74
+
75
+ librispeech_dummy = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
76
+ audio_sample = librispeech_dummy[0]
77
+
78
+ model = ClapModel.from_pretrained("laion/clap-htsat-fused").to(0)
79
+ processor = ClapProcessor.from_pretrained("laion/clap-htsat-fused")
80
+
81
+ inputs = processor(audios=audio_sample["audio"]["array"], return_tensors="pt").to(0)
82
+ audio_embed = model.get_audio_features(**inputs)
83
+ ```
84
+
85
+
86
+ # Citation
87
+
88
+ If you are using this model for your work, please consider citing the original paper:
89
+ ```
90
+ @misc{https://doi.org/10.48550/arxiv.2211.06687,
91
+ doi = {10.48550/ARXIV.2211.06687},
92
+
93
+ url = {https://arxiv.org/abs/2211.06687},
94
+
95
+ author = {Wu, Yusong and Chen, Ke and Zhang, Tianyu and Hui, Yuchen and Berg-Kirkpatrick, Taylor and Dubnov, Shlomo},
96
+
97
+ keywords = {Sound (cs.SD), Audio and Speech Processing (eess.AS), FOS: Computer and information sciences, FOS: Computer and information sciences, FOS: Electrical engineering, electronic engineering, information engineering, FOS: Electrical engineering, electronic engineering, information engineering},
98
+
99
+ title = {Large-scale Contrastive Language-Audio Pretraining with Feature Fusion and Keyword-to-Caption Augmentation},
100
+
101
+ publisher = {arXiv},
102
+
103
+ year = {2022},
104
+
105
+ copyright = {Creative Commons Attribution 4.0 International}
106
+ }
107
+ ```
emotional/clap-htsat-fused/config.json ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_commit_hash": null,
3
+ "architectures": [
4
+ "ClapModel"
5
+ ],
6
+ "audio_config": {
7
+ "_name_or_path": "",
8
+ "add_cross_attention": false,
9
+ "aff_block_r": 4,
10
+ "architectures": null,
11
+ "attention_probs_dropout_prob": 0.0,
12
+ "bad_words_ids": null,
13
+ "begin_suppress_tokens": null,
14
+ "bos_token_id": null,
15
+ "chunk_size_feed_forward": 0,
16
+ "cross_attention_hidden_size": null,
17
+ "decoder_start_token_id": null,
18
+ "depths": [
19
+ 2,
20
+ 2,
21
+ 6,
22
+ 2
23
+ ],
24
+ "diversity_penalty": 0.0,
25
+ "do_sample": false,
26
+ "drop_path_rate": 0.0,
27
+ "early_stopping": false,
28
+ "enable_fusion": true,
29
+ "enable_patch_fusion": true,
30
+ "enable_patch_layer_norm": true,
31
+ "encoder_no_repeat_ngram_size": 0,
32
+ "eos_token_id": null,
33
+ "exponential_decay_length_penalty": null,
34
+ "finetuning_task": null,
35
+ "flatten_patch_embeds": true,
36
+ "forced_bos_token_id": null,
37
+ "forced_eos_token_id": null,
38
+ "fusion_num_hidden_layers": 2,
39
+ "fusion_type": null,
40
+ "hidden_act": "gelu",
41
+ "hidden_dropout_prob": 0.1,
42
+ "hidden_size": 768,
43
+ "id2label": {
44
+ "0": "LABEL_0",
45
+ "1": "LABEL_1"
46
+ },
47
+ "initializer_factor": 1.0,
48
+ "is_decoder": false,
49
+ "is_encoder_decoder": false,
50
+ "label2id": {
51
+ "LABEL_0": 0,
52
+ "LABEL_1": 1
53
+ },
54
+ "layer_norm_eps": 1e-05,
55
+ "length_penalty": 1.0,
56
+ "max_length": 20,
57
+ "min_length": 0,
58
+ "mlp_ratio": 4.0,
59
+ "model_type": "clap_audio_model",
60
+ "no_repeat_ngram_size": 0,
61
+ "num_attention_heads": [
62
+ 4,
63
+ 8,
64
+ 16,
65
+ 32
66
+ ],
67
+ "num_beam_groups": 1,
68
+ "num_beams": 1,
69
+ "num_classes": 527,
70
+ "num_hidden_layers": 4,
71
+ "num_mel_bins": 64,
72
+ "num_return_sequences": 1,
73
+ "output_attentions": false,
74
+ "output_hidden_states": false,
75
+ "output_scores": false,
76
+ "pad_token_id": null,
77
+ "patch_embed_input_channels": 1,
78
+ "patch_embeds_hidden_size": 96,
79
+ "patch_size": 4,
80
+ "patch_stride": [
81
+ 4,
82
+ 4
83
+ ],
84
+ "prefix": null,
85
+ "problem_type": null,
86
+ "projection_dim": 512,
87
+ "projection_hidden_act": "relu",
88
+ "projection_hidden_size": 768,
89
+ "pruned_heads": {},
90
+ "qkv_bias": true,
91
+ "remove_invalid_values": false,
92
+ "repetition_penalty": 1.0,
93
+ "return_dict": true,
94
+ "return_dict_in_generate": false,
95
+ "sep_token_id": null,
96
+ "spec_size": 256,
97
+ "suppress_tokens": null,
98
+ "task_specific_params": null,
99
+ "temperature": 1.0,
100
+ "tf_legacy_loss": false,
101
+ "tie_encoder_decoder": false,
102
+ "tie_word_embeddings": true,
103
+ "tokenizer_class": null,
104
+ "top_k": 50,
105
+ "top_p": 1.0,
106
+ "torch_dtype": null,
107
+ "torchscript": false,
108
+ "transformers_version": "4.27.0.dev0",
109
+ "typical_p": 1.0,
110
+ "use_bfloat16": false,
111
+ "window_size": 8
112
+ },
113
+ "hidden_size": 768,
114
+ "initializer_factor": 1.0,
115
+ "logit_scale_init_value": 14.285714285714285,
116
+ "model_type": "clap",
117
+ "num_hidden_layers": 16,
118
+ "projection_dim": 512,
119
+ "projection_hidden_act": "relu",
120
+ "text_config": {
121
+ "_name_or_path": "",
122
+ "add_cross_attention": false,
123
+ "architectures": null,
124
+ "attention_probs_dropout_prob": 0.1,
125
+ "bad_words_ids": null,
126
+ "begin_suppress_tokens": null,
127
+ "bos_token_id": 0,
128
+ "chunk_size_feed_forward": 0,
129
+ "classifier_dropout": null,
130
+ "cross_attention_hidden_size": null,
131
+ "decoder_start_token_id": null,
132
+ "diversity_penalty": 0.0,
133
+ "do_sample": false,
134
+ "early_stopping": false,
135
+ "encoder_no_repeat_ngram_size": 0,
136
+ "eos_token_id": 2,
137
+ "exponential_decay_length_penalty": null,
138
+ "finetuning_task": null,
139
+ "forced_bos_token_id": null,
140
+ "forced_eos_token_id": null,
141
+ "fusion_hidden_size": 768,
142
+ "fusion_num_hidden_layers": 2,
143
+ "hidden_act": "gelu",
144
+ "hidden_dropout_prob": 0.1,
145
+ "hidden_size": 768,
146
+ "id2label": {
147
+ "0": "LABEL_0",
148
+ "1": "LABEL_1"
149
+ },
150
+ "initializer_factor": 1.0,
151
+ "initializer_range": 0.02,
152
+ "intermediate_size": 3072,
153
+ "is_decoder": false,
154
+ "is_encoder_decoder": false,
155
+ "label2id": {
156
+ "LABEL_0": 0,
157
+ "LABEL_1": 1
158
+ },
159
+ "layer_norm_eps": 1e-12,
160
+ "length_penalty": 1.0,
161
+ "max_length": 20,
162
+ "max_position_embeddings": 514,
163
+ "min_length": 0,
164
+ "model_type": "clap_text_model",
165
+ "no_repeat_ngram_size": 0,
166
+ "num_attention_heads": 12,
167
+ "num_beam_groups": 1,
168
+ "num_beams": 1,
169
+ "num_hidden_layers": 12,
170
+ "num_return_sequences": 1,
171
+ "output_attentions": false,
172
+ "output_hidden_states": false,
173
+ "output_scores": false,
174
+ "pad_token_id": 1,
175
+ "position_embedding_type": "absolute",
176
+ "prefix": null,
177
+ "problem_type": null,
178
+ "projection_dim": 512,
179
+ "projection_hidden_act": "relu",
180
+ "projection_hidden_size": 768,
181
+ "pruned_heads": {},
182
+ "remove_invalid_values": false,
183
+ "repetition_penalty": 1.0,
184
+ "return_dict": true,
185
+ "return_dict_in_generate": false,
186
+ "sep_token_id": null,
187
+ "suppress_tokens": null,
188
+ "task_specific_params": null,
189
+ "temperature": 1.0,
190
+ "tf_legacy_loss": false,
191
+ "tie_encoder_decoder": false,
192
+ "tie_word_embeddings": true,
193
+ "tokenizer_class": null,
194
+ "top_k": 50,
195
+ "top_p": 1.0,
196
+ "torch_dtype": null,
197
+ "torchscript": false,
198
+ "transformers_version": "4.27.0.dev0",
199
+ "type_vocab_size": 1,
200
+ "typical_p": 1.0,
201
+ "use_bfloat16": false,
202
+ "use_cache": true,
203
+ "vocab_size": 50265
204
+ },
205
+ "torch_dtype": "float32",
206
+ "transformers_version": null
207
+ }
emotional/clap-htsat-fused/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
emotional/clap-htsat-fused/preprocessor_config.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "chunk_length_s": 10,
3
+ "feature_extractor_type": "ClapFeatureExtractor",
4
+ "feature_size": 64,
5
+ "fft_window_size": 1024,
6
+ "frequency_max": 14000,
7
+ "frequency_min": 50,
8
+ "hop_length": 480,
9
+ "max_length_s": 10,
10
+ "n_fft": 1024,
11
+ "nb_frequency_bins": 513,
12
+ "nb_max_frames": 1000,
13
+ "nb_max_samples": 480000,
14
+ "padding": "repeatpad",
15
+ "padding_side": "right",
16
+ "padding_value": 0.0,
17
+ "processor_class": "ClapProcessor",
18
+ "return_attention_mask": false,
19
+ "sampling_rate": 48000,
20
+ "top_db": null,
21
+ "truncation": "fusion"
22
+ }
emotional/clap-htsat-fused/special_tokens_map.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<s>",
3
+ "cls_token": "<s>",
4
+ "eos_token": "</s>",
5
+ "mask_token": {
6
+ "content": "<mask>",
7
+ "lstrip": true,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false
11
+ },
12
+ "pad_token": "<pad>",
13
+ "sep_token": "</s>",
14
+ "unk_token": "<unk>"
15
+ }
emotional/clap-htsat-fused/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
emotional/clap-htsat-fused/tokenizer_config.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "bos_token": "<s>",
4
+ "cls_token": "<s>",
5
+ "eos_token": "</s>",
6
+ "errors": "replace",
7
+ "mask_token": "<mask>",
8
+ "model_max_length": 512,
9
+ "pad_token": "<pad>",
10
+ "processor_class": "ClapProcessor",
11
+ "sep_token": "</s>",
12
+ "special_tokens_map_file": null,
13
+ "tokenizer_class": "RobertaTokenizer",
14
+ "trim_offsets": true,
15
+ "unk_token": "<unk>"
16
+ }
emotional/clap-htsat-fused/vocab.json ADDED
The diff for this file is too large to render. See raw diff