yangwang825 commited on
Commit
35da3fc
·
verified ·
1 Parent(s): 99f8b60

Upload config

Browse files
Files changed (3) hide show
  1. README.md +199 -0
  2. config.json +0 -0
  3. configuration_ecapa_tdnn.py +196 -0
README.md ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ tags: []
4
+ ---
5
+
6
+ # Model Card for Model ID
7
+
8
+ <!-- Provide a quick summary of what the model is/does. -->
9
+
10
+
11
+
12
+ ## Model Details
13
+
14
+ ### Model Description
15
+
16
+ <!-- Provide a longer summary of what this model is. -->
17
+
18
+ This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
+
20
+ - **Developed by:** [More Information Needed]
21
+ - **Funded by [optional]:** [More Information Needed]
22
+ - **Shared by [optional]:** [More Information Needed]
23
+ - **Model type:** [More Information Needed]
24
+ - **Language(s) (NLP):** [More Information Needed]
25
+ - **License:** [More Information Needed]
26
+ - **Finetuned from model [optional]:** [More Information Needed]
27
+
28
+ ### Model Sources [optional]
29
+
30
+ <!-- Provide the basic links for the model. -->
31
+
32
+ - **Repository:** [More Information Needed]
33
+ - **Paper [optional]:** [More Information Needed]
34
+ - **Demo [optional]:** [More Information Needed]
35
+
36
+ ## Uses
37
+
38
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
+
40
+ ### Direct Use
41
+
42
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
+
44
+ [More Information Needed]
45
+
46
+ ### Downstream Use [optional]
47
+
48
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
+
50
+ [More Information Needed]
51
+
52
+ ### Out-of-Scope Use
53
+
54
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
+
56
+ [More Information Needed]
57
+
58
+ ## Bias, Risks, and Limitations
59
+
60
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
+
62
+ [More Information Needed]
63
+
64
+ ### Recommendations
65
+
66
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
+
68
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
+
70
+ ## How to Get Started with the Model
71
+
72
+ Use the code below to get started with the model.
73
+
74
+ [More Information Needed]
75
+
76
+ ## Training Details
77
+
78
+ ### Training Data
79
+
80
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
+
82
+ [More Information Needed]
83
+
84
+ ### Training Procedure
85
+
86
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
+
88
+ #### Preprocessing [optional]
89
+
90
+ [More Information Needed]
91
+
92
+
93
+ #### Training Hyperparameters
94
+
95
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
+
97
+ #### Speeds, Sizes, Times [optional]
98
+
99
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
+
101
+ [More Information Needed]
102
+
103
+ ## Evaluation
104
+
105
+ <!-- This section describes the evaluation protocols and provides the results. -->
106
+
107
+ ### Testing Data, Factors & Metrics
108
+
109
+ #### Testing Data
110
+
111
+ <!-- This should link to a Dataset Card if possible. -->
112
+
113
+ [More Information Needed]
114
+
115
+ #### Factors
116
+
117
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
+
119
+ [More Information Needed]
120
+
121
+ #### Metrics
122
+
123
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
+
125
+ [More Information Needed]
126
+
127
+ ### Results
128
+
129
+ [More Information Needed]
130
+
131
+ #### Summary
132
+
133
+
134
+
135
+ ## Model Examination [optional]
136
+
137
+ <!-- Relevant interpretability work for the model goes here -->
138
+
139
+ [More Information Needed]
140
+
141
+ ## Environmental Impact
142
+
143
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
+
145
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
+
147
+ - **Hardware Type:** [More Information Needed]
148
+ - **Hours used:** [More Information Needed]
149
+ - **Cloud Provider:** [More Information Needed]
150
+ - **Compute Region:** [More Information Needed]
151
+ - **Carbon Emitted:** [More Information Needed]
152
+
153
+ ## Technical Specifications [optional]
154
+
155
+ ### Model Architecture and Objective
156
+
157
+ [More Information Needed]
158
+
159
+ ### Compute Infrastructure
160
+
161
+ [More Information Needed]
162
+
163
+ #### Hardware
164
+
165
+ [More Information Needed]
166
+
167
+ #### Software
168
+
169
+ [More Information Needed]
170
+
171
+ ## Citation [optional]
172
+
173
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
+
175
+ **BibTeX:**
176
+
177
+ [More Information Needed]
178
+
179
+ **APA:**
180
+
181
+ [More Information Needed]
182
+
183
+ ## Glossary [optional]
184
+
185
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
+
187
+ [More Information Needed]
188
+
189
+ ## More Information [optional]
190
+
191
+ [More Information Needed]
192
+
193
+ ## Model Card Authors [optional]
194
+
195
+ [More Information Needed]
196
+
197
+ ## Model Card Contact
198
+
199
+ [More Information Needed]
config.json ADDED
The diff for this file is too large to render. See raw diff
 
configuration_ecapa_tdnn.py ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Any, Union
2
+
3
+ from transformers.configuration_utils import PretrainedConfig
4
+
5
+
6
+ class EcapaTdnnConfig(PretrainedConfig):
7
+
8
+ def __init__(
9
+ self,
10
+ sample_rate: int = 16000,
11
+ window_size: float = 0.02,
12
+ window_stride: float = 0.01,
13
+ n_window_size: Any = None,
14
+ n_window_stride: Any = None,
15
+ window: str = "hann",
16
+ normalize: str = "per_feature",
17
+ n_fft: Any = None,
18
+ preemph: float = 0.97,
19
+ features: int = 64,
20
+ lowfreq: int = 0,
21
+ highfreq: Any = None,
22
+ log: bool = True,
23
+ log_zero_guard_type: str = "add",
24
+ log_zero_guard_value: Any = 2 ** -24,
25
+ dither: float = 0.00001,
26
+ pad_to: int = 16,
27
+ frame_splicing: int = 1,
28
+ exact_pad: bool = False,
29
+ pad_value: int = 0,
30
+ mag_power: float = 2,
31
+ rng: Any = None,
32
+ nb_augmentation_prob: float = 0,
33
+ nb_max_freq: int = 4000,
34
+ use_torchaudio: bool = False,
35
+ mel_norm: str = "slaney",
36
+ freq_masks: int = 0,
37
+ time_masks: int = 0,
38
+ freq_width: int = 10,
39
+ time_width: int = 10,
40
+ rect_masks: int = 0,
41
+ rect_time: int = 5,
42
+ rect_freq: int = 20,
43
+ mask_value: float = 0,
44
+ use_vectorized_spec_augment: bool = True,
45
+ filters: list = [512, 512, 512, 512, 1500],
46
+ kernel_sizes: list = [5, 3, 3, 1, 1],
47
+ dilations: list = [1, 2, 3, 1, 1],
48
+ scale: int = 8,
49
+ res2net: bool = False,
50
+ res2net_scale: int = 8,
51
+ init_mode: str = 'xavier_uniform',
52
+ emb_sizes: Union[int, list] = 256,
53
+ pool_mode: str = 'xvector',
54
+ angular: bool = False,
55
+ attention_channels: int = 128,
56
+ objective: str = 'additive_angular_margin', # additive_margin, additive_angular_margin, cross_entropy
57
+ angular_scale = 30,
58
+ angular_margin: float = 0.2,
59
+ label_smoothing: float = 0.0,
60
+ initializer_range=0.02,
61
+ pad_token_id=0,
62
+ bos_token_id=1,
63
+ eos_token_id=2,
64
+ **kwargs,
65
+ ):
66
+ super().__init__(**kwargs, pad_token_id=pad_token_id, bos_token_id=bos_token_id, eos_token_id=eos_token_id)
67
+
68
+ self.initializer_range = initializer_range
69
+
70
+ # Mel-spectrogram configuration
71
+ self.sample_rate = sample_rate
72
+ self.window_size = window_size
73
+ self.window_stride = window_stride
74
+ self.n_window_size = n_window_size
75
+ self.n_window_stride = n_window_stride
76
+ self.window = window
77
+ self.normalize = normalize
78
+ self.n_fft = n_fft
79
+ self.preemph = preemph
80
+ self.features = features
81
+ self.lowfreq = lowfreq
82
+ self.highfreq = highfreq
83
+ self.log = log
84
+ self.log_zero_guard_type = log_zero_guard_type
85
+ self.log_zero_guard_value = log_zero_guard_value
86
+ self.dither = dither
87
+ self.pad_to = pad_to
88
+ self.frame_splicing = frame_splicing
89
+ self.exact_pad = exact_pad
90
+ self.pad_value = pad_value
91
+ self.mag_power = mag_power
92
+ self.rng = rng
93
+ self.nb_augmentation_prob = nb_augmentation_prob
94
+ self.nb_max_freq = nb_max_freq
95
+ self.use_torchaudio = use_torchaudio
96
+ self.mel_norm = mel_norm
97
+ self.mel_spectrogram_config = {
98
+ "sample_rate": sample_rate,
99
+ "window_size": window_size,
100
+ "window_stride": window_stride,
101
+ "n_window_size": n_window_size,
102
+ "n_window_stride": n_window_stride,
103
+ "window": window,
104
+ "normalize": normalize,
105
+ "n_fft": n_fft,
106
+ "preemph": preemph,
107
+ "features": features,
108
+ "lowfreq": lowfreq,
109
+ "highfreq": highfreq,
110
+ "log": log,
111
+ "log_zero_guard_type": log_zero_guard_type,
112
+ "log_zero_guard_value": log_zero_guard_value,
113
+ "dither": dither,
114
+ "pad_to": pad_to,
115
+ "frame_splicing": frame_splicing,
116
+ "exact_pad": exact_pad,
117
+ "pad_value": pad_value,
118
+ "mag_power": mag_power,
119
+ "rng": rng,
120
+ "nb_augmentation_prob": nb_augmentation_prob,
121
+ "nb_max_freq": nb_max_freq,
122
+ "use_torchaudio": use_torchaudio,
123
+ "mel_norm": mel_norm,
124
+ }
125
+
126
+ # Spectrogram Augmentation configuration
127
+ self.freq_masks = freq_masks
128
+ self.time_masks = time_masks
129
+ self.freq_width = freq_width
130
+ self.time_width = time_width
131
+ self.rect_masks = rect_masks
132
+ self.rect_time = rect_time
133
+ self.rect_freq = rect_freq
134
+ self.mask_value = mask_value
135
+ self.use_vectorized_spec_augment = use_vectorized_spec_augment
136
+ self.spectrogram_augmentation_config = {
137
+ "freq_masks": freq_masks,
138
+ "time_masks": time_masks,
139
+ "freq_width": freq_width,
140
+ "time_width": time_width,
141
+ "rect_masks": rect_masks,
142
+ "rect_time": rect_time,
143
+ "rect_freq": rect_freq,
144
+ "mask_value": mask_value,
145
+ "use_vectorized_spec_augment": use_vectorized_spec_augment,
146
+ }
147
+
148
+ # Encoder configuration
149
+ self.feat_in = features
150
+ self.filters = filters
151
+ self.kernel_sizes = kernel_sizes
152
+ self.dilations = dilations
153
+ self.scale = scale
154
+ self.res2net = res2net
155
+ self.res2net_scale = res2net_scale
156
+ self.init_mode = init_mode
157
+ self.encoder_config = {
158
+ "feat_in": self.features,
159
+ "filters": self.filters,
160
+ "kernel_sizes": self.kernel_sizes,
161
+ "dilations": self.dilations,
162
+ "scale": self.scale,
163
+ "res2net": self.res2net,
164
+ "res2net_scale": self.res2net_scale,
165
+ "init_mode": self.init_mode,
166
+ }
167
+
168
+ # Decoder configuration
169
+ self.emb_sizes = emb_sizes
170
+ self.pool_mode = pool_mode
171
+ self.angular = True if objective in ['additive_angular_margin', 'additive_margin'] else False
172
+ self.attention_channels = attention_channels
173
+ self.decoder_config = {
174
+ "feat_in": filters[-1],
175
+ "num_classes": self.num_labels,
176
+ "emb_sizes": emb_sizes,
177
+ "pool_mode": pool_mode,
178
+ "angular": angular,
179
+ "attention_channels": attention_channels,
180
+ "init_mode": init_mode,
181
+ }
182
+
183
+ # Loss function configuration
184
+ self.objective = objective
185
+ self.angular_scale = angular_scale
186
+ self.angular_margin = angular_margin
187
+ self.label_smoothing = label_smoothing
188
+ if objective in ['additive_angular_margin', 'additive_margin']:
189
+ self.objective_config = {
190
+ "scale": angular_scale,
191
+ "margin": angular_margin,
192
+ }
193
+ elif objective == 'cross_entropy':
194
+ self.objective_config = {
195
+ "label_smoothing": label_smoothing,
196
+ }