diff options
author | JC-Array <44535867+JC-Array@users.noreply.github.com> | 2022-10-10 23:06:07 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-10 23:06:07 +0000 |
commit | aca1553bde726e1455f3a73a6378b31e93d3e8f2 (patch) | |
tree | b5492fb630f58deddd9fbf812fdd7d9134a59cc1 /modules/swinir_model.py | |
parent | 45fbd1c5fec887988ab555aac75a999d4f3aff40 (diff) | |
parent | 42bf5fa3256bff5e4640e5a626e750d4e49e01e1 (diff) | |
download | stable-diffusion-webui-gfx803-aca1553bde726e1455f3a73a6378b31e93d3e8f2.tar.gz stable-diffusion-webui-gfx803-aca1553bde726e1455f3a73a6378b31e93d3e8f2.tar.bz2 stable-diffusion-webui-gfx803-aca1553bde726e1455f3a73a6378b31e93d3e8f2.zip |
Merge pull request #1 from AUTOMATIC1111/master
updating files to resolve merge conflicts
Diffstat (limited to 'modules/swinir_model.py')
-rw-r--r-- | modules/swinir_model.py | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/modules/swinir_model.py b/modules/swinir_model.py index fbd11f84..baa02e3d 100644 --- a/modules/swinir_model.py +++ b/modules/swinir_model.py @@ -10,6 +10,7 @@ from tqdm import tqdm from modules import modelloader from modules.shared import cmd_opts, opts, device from modules.swinir_model_arch import SwinIR as net +from modules.swinir_model_arch_v2 import Swin2SR as net2 from modules.upscaler import Upscaler, UpscalerData precision_scope = ( @@ -57,22 +58,42 @@ class UpscalerSwinIR(Upscaler): filename = path if filename is None or not os.path.exists(filename): return None - model = net( + if filename.endswith(".v2.pth"): + model = net2( upscale=scale, in_chans=3, img_size=64, window_size=8, img_range=1.0, - depths=[6, 6, 6, 6, 6, 6, 6, 6, 6], - embed_dim=240, - num_heads=[8, 8, 8, 8, 8, 8, 8, 8, 8], + depths=[6, 6, 6, 6, 6, 6], + embed_dim=180, + num_heads=[6, 6, 6, 6, 6, 6], mlp_ratio=2, upsampler="nearest+conv", - resi_connection="3conv", - ) + resi_connection="1conv", + ) + params = None + else: + model = net( + upscale=scale, + in_chans=3, + img_size=64, + window_size=8, + img_range=1.0, + depths=[6, 6, 6, 6, 6, 6, 6, 6, 6], + embed_dim=240, + num_heads=[8, 8, 8, 8, 8, 8, 8, 8, 8], + mlp_ratio=2, + upsampler="nearest+conv", + resi_connection="3conv", + ) + params = "params_ema" pretrained_model = torch.load(filename) - model.load_state_dict(pretrained_model["params_ema"], strict=True) + if params is not None: + model.load_state_dict(pretrained_model[params], strict=True) + else: + model.load_state_dict(pretrained_model, strict=True) if not cmd_opts.no_half: model = model.half() return model |