To implement a new model architecture, you can build upon the provided spectrogram model template. A custom model should typically inherit from nn.Module and implement the forward pass.
If your model works with spectrograms, you will likely need to include a transformation step (like STFT) within the forward method to convert the time-domain input into the frequency domain.
from model import Spectrogram, STFT
class Model(nn.Module):
def __init__(
self,
n_fft=4096,
n_hop=1024,
nb_channels=2,
input_is_spectrogram=False,
sample_rate=44100.0,
):
"""
Input: (batch, channel, sample)
or (frame, batch, channels, frequency)
Output: (frame, batch, channels, frequency)
"""
super(OpenUnmix, self).__init__()
def forward(self, mix):
# transform to spectrogram on the fly
X = self.transform(mix)
nb_frames, nb_samples, nb_channels, nb_bins = x.data.shape
# transform X to estimate
# ....
return X