Flux9665 commited on
Commit
56c4b39
1 Parent(s): 1f46e8d

Update Modules/Vocoder/HiFiGAN_Generator.py

Browse files
Modules/Vocoder/HiFiGAN_Generator.py CHANGED
@@ -15,10 +15,10 @@ class HiFiGAN(torch.nn.Module):
15
  def __init__(self,
16
  in_channels=128,
17
  out_channels=1,
18
- channels=512,
19
  kernel_size=7,
20
- upsample_scales=(8, 6, 4, 2), # CAREFUL: Avocodo assumes that there are always 4 upsample scales, because it takes intermediate results.
21
- upsample_kernel_sizes=(16, 12, 8, 4),
22
  resblock_kernel_sizes=(3, 7, 11),
23
  resblock_dilations=((1, 3, 5), (1, 3, 5), (1, 3, 5)),
24
  use_additional_convs=True,
@@ -87,9 +87,6 @@ class HiFiGAN(torch.nn.Module):
87
  1,
88
  padding=(kernel_size - 1) // 2, ), torch.nn.Tanh(), )
89
 
90
- self.out_proj_x1 = torch.nn.Conv1d(channels // 4, 1, 7, 1, padding=3)
91
- self.out_proj_x2 = torch.nn.Conv1d(channels // 8, 1, 7, 1, padding=3)
92
-
93
  # apply weight norm
94
  self.apply_weight_norm()
95
 
@@ -118,13 +115,9 @@ class HiFiGAN(torch.nn.Module):
118
  for j in range(self.num_blocks):
119
  cs += self.blocks[i * self.num_blocks + j](c)
120
  c = cs / self.num_blocks
121
- if i == 1:
122
- x1 = self.out_proj_x1(c)
123
- elif i == 2:
124
- x2 = self.out_proj_x2(c)
125
  c = self.output_conv(c)
126
 
127
- return c, x2, x1
128
 
129
  def reset_parameters(self):
130
  """
@@ -185,4 +178,5 @@ class HiFiGAN(torch.nn.Module):
185
 
186
  if __name__ == "__main__":
187
  hifi = HiFiGAN()
188
- print(f"HiFiGAN parameter count: {sum(p.numel() for p in hifi.parameters() if p.requires_grad)}")
 
 
15
  def __init__(self,
16
  in_channels=128,
17
  out_channels=1,
18
+ channels=768,
19
  kernel_size=7,
20
+ upsample_scales=(8, 6, 2, 2, 2), # CAREFUL: Avocodo assumes that there are always 4 upsample scales, because it takes intermediate results.
21
+ upsample_kernel_sizes=(16, 12, 4, 4, 4),
22
  resblock_kernel_sizes=(3, 7, 11),
23
  resblock_dilations=((1, 3, 5), (1, 3, 5), (1, 3, 5)),
24
  use_additional_convs=True,
 
87
  1,
88
  padding=(kernel_size - 1) // 2, ), torch.nn.Tanh(), )
89
 
 
 
 
90
  # apply weight norm
91
  self.apply_weight_norm()
92
 
 
115
  for j in range(self.num_blocks):
116
  cs += self.blocks[i * self.num_blocks + j](c)
117
  c = cs / self.num_blocks
 
 
 
 
118
  c = self.output_conv(c)
119
 
120
+ return c
121
 
122
  def reset_parameters(self):
123
  """
 
178
 
179
  if __name__ == "__main__":
180
  hifi = HiFiGAN()
181
+ print(f"HiFiGAN parameter count: {sum(p.numel() for p in hifi.parameters() if p.requires_grad)}")
182
+ print(hifi(torch.randn([1, 128, 100]))[0].shape)