Spaces:
Sleeping
Sleeping
Download model.py from Armyman91/FontStyleTransfer: direct link, hf CLI and curl.
- Browser
- Download file 620 Bytes
-
https://huggingface.co/spaces/Armyman91/FontStyleTransfer/resolve/main/model.py
- Command line
-
hf download hf://spaces/Armyman91/FontStyleTransfer/model.py
-
curl -L -o model.py https://huggingface.co/spaces/Armyman91/FontStyleTransfer/resolve/main/model.py
620 Bytes
| import torch | |
| from models.networks import define_G | |
| def load_generator(checkpoint_path): | |
| checkpoint = torch.load(checkpoint_path, map_location='cpu') | |
| if 'G_A' in checkpoint: | |
| state_dict = checkpoint['G_A'] | |
| elif 'state_dict' in checkpoint: | |
| state_dict = checkpoint['state_dict'] | |
| else: | |
| state_dict = checkpoint | |
| # Match your trained generator architecture here! | |
| netG = define_G(input_nc=1, output_nc=1, ngf=64, netG='unet_128', norm='batch', use_dropout=False, init_type='normal', init_gain=0.02, gpu_ids=[]) | |
| netG.load_state_dict(state_dict) | |
| netG.eval() | |
| return netG |