Spaces:
Build error
Build error
Download checkpoints/clean.py from Silentlin/DiffSinger: direct link, hf CLI and curl.
- Browser
- Download file 484 Bytes
-
https://huggingface.co/spaces/Silentlin/DiffSinger/resolve/main/checkpoints/clean.py
- Command line
-
hf download hf://spaces/Silentlin/DiffSinger/checkpoints/clean.py
-
curl -L -o clean.py https://huggingface.co/spaces/Silentlin/DiffSinger/resolve/main/checkpoints/clean.py
484 Bytes
| import sys | |
| import torch | |
| if __name__ == '__main__': | |
| ckpt_path = sys.argv[1] | |
| checkpoint = torch.load(ckpt_path, map_location='cpu') | |
| print(checkpoint['state_dict'].keys()) | |
| if 'model' in checkpoint['state_dict']: | |
| checkpoint = {'state_dict': {'model': checkpoint['state_dict']['model']}} | |
| else: | |
| checkpoint = {'state_dict': {'model_gen': checkpoint['state_dict']['model_gen']}} | |
| torch.save(checkpoint, ckpt_path, _use_new_zipfile_serialization=False) | |