Skip to content

https://hf.co/hexgrad/Kokoro-82M

Python

Add additional onnx compat for https://github.com/pytorch/pytorch/issues/92977 (#104)

Adrian Lyjake648c0605a5e
diff --git a/kokoro/istftnet.py b/kokoro/istftnet.py
index e61e510..5e4143e 100644
--- a/kokoro/istftnet.py
+++ b/kokoro/istftnet.py
@@ -23,7 +23,8 @@ def get_padding(kernel_size, dilation=1):
class AdaIN1d(nn.Module):
def __init__(self, style_dim, num_features):
super().__init__()
- self.norm = nn.InstanceNorm1d(num_features, affine=False)
+ # affine should be False, however there's a bug in the old torch.onnx.export (not newer dynamo) that causes the channel dimension to be lost if affine=False. When affine is true, there's additional learnably parameters. This shouldn't really matter setting it to True, since we're in inference mode
+ self.norm = nn.InstanceNorm1d(num_features, affine=True)
self.fc = nn.Linear(style_dim, num_features*2)
def forward(self, x, s):