Download model.py from Armyman91/Font_style_transfer: direct link, hf CLI and curl.
- Browser
- Download file 468 Bytes
-
https://huggingface.co/Armyman91/Font_style_transfer/resolve/main/model.py
- Command line
-
hf download hf://Armyman91/Font_style_transfer/model.py
-
curl -L -o model.py https://huggingface.co/Armyman91/Font_style_transfer/resolve/main/model.py
468 Bytes
| # model.py | |
| import torch | |
| from models.networks import define_G | |
| def load_generator(model_path): | |
| # Define the generator with default CycleGAN config | |
| netG = define_G( | |
| input_nc=1, output_nc=1, ngf=64, | |
| netG='resnet_9blocks', norm='instance', | |
| use_dropout=False, init_type='normal', init_gain=0.02, gpu_ids=[] | |
| ) | |
| state_dict = torch.load(model_path, map_location='cpu') | |
| netG.load_state_dict(state_dict) | |
| netG.eval() | |
| return netG |