SayaSS / vits-finetuning

Fine-Tuning your VITS model using a pre-trained model
MIT License
546 stars 86 forks source link

Reduce Model Size #11

Closed MikuAuahDark closed 1 year ago

MikuAuahDark commented 1 year ago

Thank you for the previous assistance. Now I have my own model.

However the size of the model is large (almost 500MB). How to reduce the model size?

SayaSS commented 1 year ago
import torch

if __name__ == '__main__':
    input_path = fr"D:\backup\tannhauser\G_4000.pth"
    output_path = fr"D:\backup\tannhauser\tannhauser.pth"
    checkpoint_dict = torch.load(input_path, map_location='cpu')
    checkpoint_dict_new = {}
    for k, v in checkpoint_dict.items():
        if k == "optimizer":
            print(f"remove optimizer")
            continue
        checkpoint_dict_new[k] = v
    torch.save(checkpoint_dict_new, output_path)
MikuAuahDark commented 1 year ago

Sweet, thank you very much.