Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stable-diffusion-webui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
stable-diffusion-webui
Commits
ed769977
Commit
ed769977
authored
Oct 09, 2022
by
C43H66N12O12S2
Committed by
AUTOMATIC1111
Oct 10, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add swinir v2 support
parent
ece27fe9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
7 deletions
+28
-7
swinir_model.py
modules/swinir_model.py
+28
-7
No files found.
modules/swinir_model.py
View file @
ed769977
...
@@ -10,6 +10,7 @@ from tqdm import tqdm
...
@@ -10,6 +10,7 @@ from tqdm import tqdm
from
modules
import
modelloader
from
modules
import
modelloader
from
modules.shared
import
cmd_opts
,
opts
,
device
from
modules.shared
import
cmd_opts
,
opts
,
device
from
modules.swinir_model_arch
import
SwinIR
as
net
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
from
modules.upscaler
import
Upscaler
,
UpscalerData
precision_scope
=
(
precision_scope
=
(
...
@@ -57,22 +58,42 @@ class UpscalerSwinIR(Upscaler):
...
@@ -57,22 +58,42 @@ class UpscalerSwinIR(Upscaler):
filename
=
path
filename
=
path
if
filename
is
None
or
not
os
.
path
.
exists
(
filename
):
if
filename
is
None
or
not
os
.
path
.
exists
(
filename
):
return
None
return
None
model
=
net
(
if
filename
.
endswith
(
".v2.pth"
):
model
=
net2
(
upscale
=
scale
,
upscale
=
scale
,
in_chans
=
3
,
in_chans
=
3
,
img_size
=
64
,
img_size
=
64
,
window_size
=
8
,
window_size
=
8
,
img_range
=
1.0
,
img_range
=
1.0
,
depths
=
[
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
],
depths
=
[
6
,
6
,
6
,
6
,
6
,
6
],
embed_dim
=
24
0
,
embed_dim
=
18
0
,
num_heads
=
[
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
],
num_heads
=
[
6
,
6
,
6
,
6
,
6
,
6
],
mlp_ratio
=
2
,
mlp_ratio
=
2
,
upsampler
=
"nearest+conv"
,
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
)
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
:
if
not
cmd_opts
.
no_half
:
model
=
model
.
half
()
model
=
model
.
half
()
return
model
return
model
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment