AttributeError: 'HifiGAN' object has no attribute 'model'
I'm following the instructions to train a model for DiffSinger, but there seem to be some issues with vocoders/hifigan.py:
"# first run fs2 infer;"
$ CUDA_VISIBLE_DEVICES=0 python tasks/run.py --config usr/configs/popcs_fs2.yaml --exp_name popcs_fs2_pmf0_1230 --reset --infer
...
| model Trainable Parameters: 24.256M
0%| | 0/1 [00:00<?, ?it/s]
Traceback (most recent call last): | 0/1 [00:00<?, ?it/s]
File "tasks/run.py", line 15, in <module>
run_task()
File "tasks/run.py", line 10, in run_task
task_cls.start()
File "/.../DiffSinger/tasks/base_task.py", line 258, in start
trainer.test(task)
File "/.../DiffSinger/utils/pl_utils.py", line 586, in test
self.fit(model)
File "/.../DiffSinger/utils/pl_utils.py", line 489, in fit
self.run_pretrain_routine(model)
File "/.../DiffSinger/utils/pl_utils.py", line 545, in run_pretrain_routine
self.run_evaluation(test=True)
File "/.../DiffSinger/utils/pl_utils.py", line 1245, in run_evaluation
eval_results = self.evaluate(self.model,
File "/.../DiffSinger/utils/pl_utils.py", line 1185, in evaluate
output = self.evaluation_forward(model,
File "/.../DiffSinger/utils/pl_utils.py", line 1307, in evaluation_forward
output = model.test_step(*args)
File "/.../DiffSinger/tasks/tts/fs2.py", line 363, in test_step
return self.after_infer(sample)
File "/.../DiffSinger/tasks/tts/fs2.py", line 410, in after_infer
wav_pred = self.vocoder.spec2wav(mel_pred, f0=f0_pred)
File "/.../DiffSinger/vocoders/hifigan.py", line 56, in spec2wav
device = self.device
AttributeError: 'HifiGAN' object has no attribute 'device'
Testing: 0%| | 0/14 [00:01<?, ?batch/s]
So I've added self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu") to the __init__ of HifiGAN, but then I get this:
| model Trainable Parameters: 24.256M
0%| | 0/1 [00:00<?, ?it/s]
Traceback (most recent call last): | 0/1 [00:00<?, ?it/s]
File "tasks/run.py", line 15, in <module>
run_task()
File "tasks/run.py", line 10, in run_task
task_cls.start()
File "/.../DiffSinger/tasks/base_task.py", line 258, in start
trainer.test(task)
File "/.../DiffSinger/utils/pl_utils.py", line 586, in test
self.fit(model)
File "/.../DiffSinger/utils/pl_utils.py", line 489, in fit
self.run_pretrain_routine(model)
File "/.../DiffSinger/utils/pl_utils.py", line 545, in run_pretrain_routine
self.run_evaluation(test=True)
File "/.../DiffSinger/utils/pl_utils.py", line 1245, in run_evaluation
eval_results = self.evaluate(self.model,
File "/.../DiffSinger/utils/pl_utils.py", line 1185, in evaluate
output = self.evaluation_forward(model,
File "/.../DiffSinger/utils/pl_utils.py", line 1307, in evaluation_forward
output = model.test_step(*args)
File "/.../DiffSinger/tasks/tts/fs2.py", line 363, in test_step
return self.after_infer(sample)
File "/.../DiffSinger/tasks/tts/fs2.py", line 410, in after_infer
wav_pred = self.vocoder.spec2wav(mel_pred, f0=f0_pred)
File "/.../DiffSinger/vocoders/hifigan.py", line 64, in spec2wav
y = self.model(c, f0).view(-1)
AttributeError: 'HifiGAN' object has no attribute 'model'
Testing: 0%| | 0/14 [00:01<?, ?batch/s]
I never meet this problem. Is there anyone who could help him?
I confirm that I have the exactly same issue. I have not resolved it yet.
I deleted my 'checkpoints/0109_hifigan_bigpopcs_hop128' folder, then your bug-logs came. So, why not download the checkpoint file for the vocoder first, before conducting the experiments.
Ah, placing the original checkpoint file in checkpoints/0109_hifigan_bigpopcs_hop128 does resolve this issue.
But this requires the use of the original phone_set to be used. The point of training the model is to train it on a completely new data set, with its own phone_set. Can you please indicate how to train a model from scratch?
https://github.com/MoonInTheRiver/DiffSinger/blob/3d050f76aefb766d004fddcf52e9307affefd3c4/vocoders/hifigan.py#L41
There is no super call from the __init__ method of HifiGAN, which I think is a reason of this error. The PWG class has a device attribute. I have come through this also.