Download app/models/ESRGAN/net_intrep.py from savetrees/StegNet: direct link, hf CLI and curl.
- Browser
- Download file 564 Bytes
-
https://huggingface.co/spaces/savetrees/StegNet/resolve/main/app/models/ESRGAN/net_intrep.py
- Command line
-
hf download hf://spaces/savetrees/StegNet/app/models/ESRGAN/net_intrep.py
-
curl -L -o net_intrep.py https://huggingface.co/spaces/savetrees/StegNet/resolve/main/app/models/ESRGAN/net_intrep.py
564 Bytes
| import sys | |
| import torch | |
| from collections import OrderedDict | |
| alpha = float(sys.argv[1]) | |
| net_PSNR_path = './models/RRDB_PSNR_x4.pth' | |
| net_ESRGAN_path = 'models/RRDB_ESRGAN_x4.pth' | |
| net_interp_path = './models/interp_{:02d}.pth'.format(int(alpha*10)) | |
| net_PSNR = torch.load(net_PSNR_path) | |
| net_ESRGAN = torch.load(net_ESRGAN_path) | |
| net_interp = OrderedDict() | |
| print('Interpolating with alpha = ', alpha) | |
| for k, v_PSNR in net_PSNR.items(): | |
| v_ESRGAN = net_ESRGAN[k] | |
| net_interp[k] = (1 - alpha) * v_PSNR + alpha * v_ESRGAN | |
| torch.save(net_interp, net_interp_path) |