Raemih Satya10 commited on
Commit
461b631
·
0 Parent(s):

Duplicate from superb/hubert-base-superb-er

Browse files

Co-authored-by: Satya <Satya10@users.noreply.huggingface.co>

Files changed (5) hide show
  1. .gitattributes +17 -0
  2. README.md +98 -0
  3. config.json +85 -0
  4. preprocessor_config.json +9 -0
  5. pytorch_model.bin +3 -0
.gitattributes ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
2
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.h5 filter=lfs diff=lfs merge=lfs -text
5
+ *.tflite filter=lfs diff=lfs merge=lfs -text
6
+ *.tar.gz filter=lfs diff=lfs merge=lfs -text
7
+ *.ot filter=lfs diff=lfs merge=lfs -text
8
+ *.onnx filter=lfs diff=lfs merge=lfs -text
9
+ *.arrow filter=lfs diff=lfs merge=lfs -text
10
+ *.ftz filter=lfs diff=lfs merge=lfs -text
11
+ *.joblib 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
+ *.pb filter=lfs diff=lfs merge=lfs -text
15
+ *.pt filter=lfs diff=lfs merge=lfs -text
16
+ *.pth filter=lfs diff=lfs merge=lfs -text
17
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ datasets:
4
+ - superb
5
+ tags:
6
+ - speech
7
+ - audio
8
+ - hubert
9
+ - audio-classification
10
+ license: apache-2.0
11
+ widget:
12
+ - example_title: IEMOCAP clip "happy"
13
+ src: https://cdn-media.huggingface.co/speech_samples/IEMOCAP_Ses01F_impro03_F013.wav
14
+ - example_title: IEMOCAP clip "neutral"
15
+ src: https://cdn-media.huggingface.co/speech_samples/IEMOCAP_Ses01F_impro04_F000.wav
16
+ ---
17
+
18
+ # Hubert-Base for Emotion Recognition
19
+
20
+ ## Model description
21
+
22
+ This is a ported version of
23
+ [S3PRL's Hubert for the SUPERB Emotion Recognition task](https://github.com/s3prl/s3prl/tree/master/s3prl/downstream/emotion).
24
+
25
+ The base model is [hubert-base-ls960](https://huggingface.co/facebook/hubert-base-ls960), which is pretrained on 16kHz
26
+ sampled speech audio. When using the model make sure that your speech input is also sampled at 16Khz.
27
+
28
+ For more information refer to [SUPERB: Speech processing Universal PERformance Benchmark](https://arxiv.org/abs/2105.01051)
29
+
30
+ ## Task and dataset description
31
+
32
+ Emotion Recognition (ER) predicts an emotion class for each utterance. The most widely used ER dataset
33
+ [IEMOCAP](https://sail.usc.edu/iemocap/) is adopted, and we follow the conventional evaluation protocol:
34
+ we drop the unbalanced emotion classes to leave the final four classes with a similar amount of data points and
35
+ cross-validate on five folds of the standard splits.
36
+
37
+ For the original model's training and evaluation instructions refer to the
38
+ [S3PRL downstream task README](https://github.com/s3prl/s3prl/tree/master/s3prl/downstream#er-emotion-recognition).
39
+
40
+
41
+ ## Usage examples
42
+
43
+ You can use the model via the Audio Classification pipeline:
44
+ ```python
45
+ from datasets import load_dataset
46
+ from transformers import pipeline
47
+
48
+ dataset = load_dataset("anton-l/superb_demo", "er", split="session1")
49
+
50
+ classifier = pipeline("audio-classification", model="superb/hubert-base-superb-er")
51
+ labels = classifier(dataset[0]["file"], top_k=5)
52
+ ```
53
+
54
+ Or use the model directly:
55
+ ```python
56
+ import torch
57
+ import librosa
58
+ from datasets import load_dataset
59
+ from transformers import HubertForSequenceClassification, Wav2Vec2FeatureExtractor
60
+
61
+ def map_to_array(example):
62
+ speech, _ = librosa.load(example["file"], sr=16000, mono=True)
63
+ example["speech"] = speech
64
+ return example
65
+
66
+ # load a demo dataset and read audio files
67
+ dataset = load_dataset("anton-l/superb_demo", "er", split="session1")
68
+ dataset = dataset.map(map_to_array)
69
+
70
+ model = HubertForSequenceClassification.from_pretrained("superb/hubert-base-superb-er")
71
+ feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained("superb/hubert-base-superb-er")
72
+
73
+ # compute attention masks and normalize the waveform if needed
74
+ inputs = feature_extractor(dataset[:4]["speech"], sampling_rate=16000, padding=True, return_tensors="pt")
75
+
76
+ logits = model(**inputs).logits
77
+ predicted_ids = torch.argmax(logits, dim=-1)
78
+ labels = [model.config.id2label[_id] for _id in predicted_ids.tolist()]
79
+ ```
80
+
81
+ ## Eval results
82
+
83
+ The evaluation metric is accuracy.
84
+
85
+ | | **s3prl** | **transformers** |
86
+ |--------|-----------|------------------|
87
+ |**session1**| `0.6492` | `0.6359` |
88
+
89
+ ### BibTeX entry and citation info
90
+
91
+ ```bibtex
92
+ @article{yang2021superb,
93
+ title={SUPERB: Speech processing Universal PERformance Benchmark},
94
+ author={Yang, Shu-wen and Chi, Po-Han and Chuang, Yung-Sung and Lai, Cheng-I Jeff and Lakhotia, Kushal and Lin, Yist Y and Liu, Andy T and Shi, Jiatong and Chang, Xuankai and Lin, Guan-Ting and others},
95
+ journal={arXiv preprint arXiv:2105.01051},
96
+ year={2021}
97
+ }
98
+ ```
config.json ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "facebook/hubert-base-ls960",
3
+ "activation_dropout": 0.1,
4
+ "apply_spec_augment": true,
5
+ "architectures": [
6
+ "HubertForSequenceClassification"
7
+ ],
8
+ "attention_dropout": 0.1,
9
+ "bos_token_id": 1,
10
+ "classifier_proj_size": 256,
11
+ "conv_bias": false,
12
+ "conv_dim": [
13
+ 512,
14
+ 512,
15
+ 512,
16
+ 512,
17
+ 512,
18
+ 512,
19
+ 512
20
+ ],
21
+ "conv_kernel": [
22
+ 10,
23
+ 3,
24
+ 3,
25
+ 3,
26
+ 3,
27
+ 2,
28
+ 2
29
+ ],
30
+ "conv_stride": [
31
+ 5,
32
+ 2,
33
+ 2,
34
+ 2,
35
+ 2,
36
+ 2,
37
+ 2
38
+ ],
39
+ "ctc_loss_reduction": "sum",
40
+ "ctc_zero_infinity": false,
41
+ "do_stable_layer_norm": false,
42
+ "eos_token_id": 2,
43
+ "feat_extract_activation": "gelu",
44
+ "feat_extract_dropout": 0.0,
45
+ "feat_extract_norm": "group",
46
+ "feat_proj_dropout": 0.1,
47
+ "final_dropout": 0.1,
48
+ "gradient_checkpointing": false,
49
+ "hidden_act": "gelu",
50
+ "hidden_dropout": 0.1,
51
+ "hidden_dropout_prob": 0.1,
52
+ "hidden_size": 768,
53
+ "id2label": {
54
+ "0": "neu",
55
+ "1": "hap",
56
+ "2": "ang",
57
+ "3": "sad"
58
+ },
59
+ "initializer_range": 0.02,
60
+ "intermediate_size": 3072,
61
+ "label2id": {
62
+ "ang": 2,
63
+ "hap": 1,
64
+ "neu": 0,
65
+ "sad": 3
66
+ },
67
+ "layer_norm_eps": 1e-05,
68
+ "layerdrop": 0.1,
69
+ "mask_feature_length": 10,
70
+ "mask_feature_prob": 0.0,
71
+ "mask_time_length": 10,
72
+ "mask_time_prob": 0.05,
73
+ "model_type": "hubert",
74
+ "num_attention_heads": 12,
75
+ "num_conv_pos_embedding_groups": 16,
76
+ "num_conv_pos_embeddings": 128,
77
+ "num_feat_extract_layers": 7,
78
+ "num_hidden_layers": 12,
79
+ "pad_token_id": 0,
80
+ "problem_type": "single_label_classification",
81
+ "torch_dtype": "float32",
82
+ "transformers_version": "4.10.0.dev0",
83
+ "use_weighted_layer_sum": true,
84
+ "vocab_size": 32
85
+ }
preprocessor_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_normalize": false,
3
+ "feature_extractor_type": "Wav2Vec2FeatureExtractor",
4
+ "feature_size": 1,
5
+ "padding_side": "right",
6
+ "padding_value": 0,
7
+ "return_attention_mask": true,
8
+ "sampling_rate": 16000
9
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9e10f7a1672ad8f262012d3698bfbcdc232fe9483f9fbee3d9a1de405d134a2a
3
+ size 378360273