Download convert/core.py from monokern/wobble-split: direct link, hf CLI and curl.
- Browser
- Download file 857 Bytes
-
https://huggingface.co/monokern/wobble-split/resolve/main/convert/core.py
- Command line
-
hf download hf://monokern/wobble-split/convert/core.py
-
curl -L -o core.py https://huggingface.co/monokern/wobble-split/resolve/main/convert/core.py
857 Bytes
| """SCNet without its STFT/iSTFT: spec [1,4,2049,T] -> stems [1,16,2049,T]. Same maths as SCNet.forward.""" | |
| from collections import deque | |
| import torch | |
| from torch import nn | |
| class SCNetCore(nn.Module): | |
| def __init__(self, m): | |
| super().__init__() | |
| self.m = m | |
| def forward(self, x): | |
| m = self.m | |
| B, C, Fr, T = x.shape | |
| mean = x.mean(dim=(1, 2, 3), keepdim=True) | |
| std = x.std(dim=(1, 2, 3), keepdim=True) | |
| x = (x - mean) / (1e-5 + std) | |
| skips, lens, olens = deque(), deque(), deque() | |
| for sd in m.encoder: | |
| x, skip, l, ol = sd(x) | |
| skips.append(skip); lens.append(l); olens.append(ol) | |
| x = m.separation_net(x) | |
| for fusion, su in m.decoder: | |
| x = fusion(x, skips.pop()) | |
| x = su(x, lens.pop(), olens.pop()) | |
| return x * std + mean | |