p0p4k / pflowtts_pytorch

Unofficial implementation of NVIDIA P-Flow TTS paper
https://neurips.cc/virtual/2023/poster/69899
MIT License
214 stars 30 forks source link

How to perform fine-tuning? #17

Closed HobisPL closed 7 months ago

HobisPL commented 9 months ago

I've trained a model and would like to use it as a base for training another speaker, where should I specify the path to the pre-trained model?

p0p4k commented 9 months ago

See train.yaml checkpoint path, under configs.

HobisPL commented 9 months ago

See train.yaml checkpoint path, under configs.

Do you mean the 'ckpt_path:' ? But that is for resuming training; epochs, etc., are from the previous training.

p0p4k commented 9 months ago

Yes you can resume with a new dataset and set epochs to 0 using on load checkpoint, see pytorch lightning details for more info.

HobisPL commented 9 months ago

Ok, thanks for the reply

p0p4k commented 9 months ago

Hi, in train.py after Instantiating model ... add this

    if cfg.get("transfer_ckpt_path"):
        model.load_state_dict(torch.load(cfg.get("transfer_ckpt_path"), map_location="cpu")['state_dict'])
        log.info(f"Loaded model from {cfg.get('transfer_ckpt_path')}")

In train.yaml, add a new flag "transfer_ckpt_path" (like cpkt_path). This flag will just load the state dict (weights) and ignore everything else from the pretrained model. Try and let me know if it works.

p0p4k commented 9 months ago

if you use pytorch lightning , load_from_checkpoint , it loads everything (hparams, etc) and then it is basically almost like resuming training, instead of transfer. So i think using pytorch state dict load is better.

Oleksandr2505 commented 7 months ago

if you use pytorch lightning , load_from_checkpoint , it loads everything (hparams, etc) and then it is basically almost like resuming training, instead of transfer. So i think using pytorch state dict load is better.

Hi, It is working , Thank you!