Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in train.py, if config.inference['normalize'] is True, transform estimates after demix #68

Open
hunterhogan opened this issue Aug 21, 2024 · 2 comments

Comments

@hunterhogan
Copy link
Contributor

When the new parameter in config.inference, normalize, was added in this commit, logic was added to valid.py and inference.py to remove the normalization transformation from estimates. In train.py, the logic to transform mix was added, however, nothing was added for estimates.

mix_orig = mix.copy()
mix = mix.T # (channels, waveform)
if 'normalize' in config.inference:
if config.inference['normalize'] is True:
mono = mix.mean(0)
mean = mono.mean()
std = mono.std()
mix = (mix - mean) / std
folder = os.path.dirname(path)
folder_name = os.path.abspath(folder)
if verbose:
print('Song: {}'.format(folder_name))
res = demix(config, model, mix, device, model_type=args.model_type)
if 1:
pbar_dict = {}
for instr in instruments:
if instr != 'other' or config.training.other_fix is False:
try:
track, sr1 = sf.read(folder + '/{}.wav'.format(instr))
except Exception as e:
# print('No data for stem: {}. Skip!'.format(instr))
continue
else:
# other is actually instrumental
track, sr1 = sf.read(folder + '/{}.wav'.format('vocals'))
track = mix_orig - track
references = np.expand_dims(track, axis=0)
estimates = np.expand_dims(res[instr].T, axis=0)
sdr_val = sdr(references, estimates)[0]

Would this affect the SDR calculation in sdr_val = sdr(references, estimates)[0]?

@ZFTurbo
Copy link
Owner

ZFTurbo commented Aug 21, 2024

I added normalize only to support one model (SCNet) for inference. I didn't change training to support normalization.

@Kenus23
Copy link

Kenus23 commented Oct 10, 2024

how use training for stem separation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants