mrprimenotes commited on
Commit
3b51d88
·
verified ·
1 Parent(s): 78e5ba3

Update model.py

Browse files
Files changed (1) hide show
  1. model.py +33 -25
model.py CHANGED
@@ -6,12 +6,21 @@ import types
6
 
7
  class ConvLayerConfig:
8
  """Configuration for a single convolutional layer"""
9
- in_channels: int
10
- out_channels: int
11
- kernel_size: int
12
- stride: int = 1
13
- padding: int = 0
14
- activation: Literal["gelu", "relu", "none"] = "gelu"
 
 
 
 
 
 
 
 
 
15
 
16
  class CustomWhisperConfig(WhisperConfig):
17
  def __init__(
@@ -28,30 +37,29 @@ class CustomWhisperConfig(WhisperConfig):
28
  ):
29
  super().__init__(**kwargs)
30
 
31
- # Original custom parameters
32
  self.use_first_embeddings = use_first_embeddings
33
  self.embedding_stride = embedding_stride
34
  self.slide_feature_dim = slide_feature_dim
35
 
36
- # New convolutional layer customization parameters
37
- self.conv_preprocessing_layers = conv_preprocessing_layers or [
38
- # Default Whisper conv layers configuration
39
- ConvLayerConfig(
40
- in_channels=self.num_mel_bins,
41
- out_channels=self.d_model,
42
- kernel_size=3,
43
- padding=1
44
- ),
45
- ConvLayerConfig(
46
- in_channels=self.d_model,
47
- out_channels=self.d_model,
48
- kernel_size=3,
49
- stride=2,
50
- padding=1
51
- )
52
- ]
 
53
 
54
- # Additional conv layer parameters
55
  self.conv_dropout = conv_dropout
56
  self.conv_bias = conv_bias
57
  self.conv_activation = conv_activation
 
6
 
7
  class ConvLayerConfig:
8
  """Configuration for a single convolutional layer"""
9
+ def __init__(
10
+ self,
11
+ in_channels: int,
12
+ out_channels: int,
13
+ kernel_size: int,
14
+ stride: int = 1,
15
+ padding: int = 0,
16
+ activation: Literal["gelu", "relu", "none"] = "gelu"
17
+ ):
18
+ self.in_channels = in_channels
19
+ self.out_channels = out_channels
20
+ self.kernel_size = kernel_size
21
+ self.stride = stride
22
+ self.padding = padding
23
+ self.activation = activation
24
 
25
  class CustomWhisperConfig(WhisperConfig):
26
  def __init__(
 
37
  ):
38
  super().__init__(**kwargs)
39
 
 
40
  self.use_first_embeddings = use_first_embeddings
41
  self.embedding_stride = embedding_stride
42
  self.slide_feature_dim = slide_feature_dim
43
 
44
+ if conv_preprocessing_layers is None:
45
+ conv_preprocessing_layers = [
46
+ ConvLayerConfig(
47
+ in_channels=self.num_mel_bins,
48
+ out_channels=self.d_model,
49
+ kernel_size=3,
50
+ padding=1
51
+ ),
52
+ ConvLayerConfig(
53
+ in_channels=self.d_model,
54
+ out_channels=self.d_model,
55
+ kernel_size=3,
56
+ stride=2,
57
+ padding=1
58
+ )
59
+ ]
60
+
61
+ self.conv_preprocessing_layers = conv_preprocessing_layers
62
 
 
63
  self.conv_dropout = conv_dropout
64
  self.conv_bias = conv_bias
65
  self.conv_activation = conv_activation