openvpi / DiffSinger

An advanced singing voice synthesis system with high fidelity, expressiveness, controllability and flexibility based on DiffSinger: Singing Voice Synthesis via Shallow Diffusion Mechanism
Apache License 2.0
2.73k stars 288 forks source link

TypeError running variance inference (previously working) #173

Closed blueyred closed 8 months ago

blueyred commented 9 months ago

Hi

I was testing a newly trained model with a sample file.

When attempting variance inferencing it is throwing an error. This file has been working with previous verions and previously trained models. If I move the models to an older (Jul 17 2023) diffsinger commit before the melody_encoder code was added it works okay. For this model config - use_melody_encoder: false .

This is the inference ds file - test_on.ds.txt

The command run is

python scripts/infer.py variance samples/test_on.ds --exp lara_variance --predict dur --predict pitch

The output is:

Traceback (most recent call last):
  File "scripts/infer.py", line 248, in <module>
    main()
  File "/home/blue/anaconda3/envs/diffactor/lib/python3.8/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/blue/anaconda3/envs/diffactor/lib/python3.8/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/blue/anaconda3/envs/diffactor/lib/python3.8/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/blue/anaconda3/envs/diffactor/lib/python3.8/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/blue/anaconda3/envs/diffactor/lib/python3.8/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "scripts/infer.py", line 239, in variance
    infer_ins.run_inference(
  File "/var/repos/DiffSinger/inference/ds_variance.py", line 396, in run_inference
    dur_pred, pitch_pred, variance_pred = self.forward_model(batch)
  File "/home/blue/anaconda3/envs/diffactor/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "/var/repos/DiffSinger/inference/ds_variance.py", line 307, in forward_model
    dur_pred, pitch_pred, variance_pred = self.model(
  File "/home/blue/anaconda3/envs/diffactor/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/var/repos/DiffSinger/modules/toplevel.py", line 245, in forward
    base_pitch = base_pitch * pitch_retake + pitch * ~pitch_retake
TypeError: unsupported operand type(s) for *: 'NoneType' and 'Tensor'

I've taken a look through the code and I'm unable to spot what could be causing the issue. Debugging it I can see the "pitch" variable is None

yqzhishen commented 8 months ago

Seems like a bug and I reproduced it. Thanks for reporting!