Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
c9bb33dd
S
Stable Diffusion Webui
项目概览
Overbill1683
/
Stable Diffusion Webui
11 个月 前同步成功
通知
1771
Star
81
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
S
Stable Diffusion Webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
体验新版 GitCode,发现更多精彩内容 >>
提交
c9bb33dd
编写于
10月 30, 2022
作者:
V
victorca25
提交者:
victorca25
10月 30, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add resrgan 8x, allow use 1x and up to 8x extra models, move BSRGAN model, add nearest
上级
17a2076f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
33 addition
and
6 deletion
+33
-6
modules/esrgan_model.py
modules/esrgan_model.py
+13
-4
modules/modelloader.py
modules/modelloader.py
+3
-0
modules/ui.py
modules/ui.py
+1
-1
modules/upscaler.py
modules/upscaler.py
+16
-1
未找到文件。
modules/esrgan_model.py
浏览文件 @
c9bb33dd
...
@@ -50,6 +50,7 @@ def mod2normal(state_dict):
...
@@ -50,6 +50,7 @@ def mod2normal(state_dict):
def
resrgan2normal
(
state_dict
,
nb
=
23
):
def
resrgan2normal
(
state_dict
,
nb
=
23
):
# this code is copied from https://github.com/victorca25/iNNfer
# this code is copied from https://github.com/victorca25/iNNfer
if
"conv_first.weight"
in
state_dict
and
"body.0.rdb1.conv1.weight"
in
state_dict
:
if
"conv_first.weight"
in
state_dict
and
"body.0.rdb1.conv1.weight"
in
state_dict
:
re8x
=
0
crt_net
=
{}
crt_net
=
{}
items
=
[]
items
=
[]
for
k
,
v
in
state_dict
.
items
():
for
k
,
v
in
state_dict
.
items
():
...
@@ -75,10 +76,18 @@ def resrgan2normal(state_dict, nb=23):
...
@@ -75,10 +76,18 @@ def resrgan2normal(state_dict, nb=23):
crt_net
[
'model.3.bias'
]
=
state_dict
[
'conv_up1.bias'
]
crt_net
[
'model.3.bias'
]
=
state_dict
[
'conv_up1.bias'
]
crt_net
[
'model.6.weight'
]
=
state_dict
[
'conv_up2.weight'
]
crt_net
[
'model.6.weight'
]
=
state_dict
[
'conv_up2.weight'
]
crt_net
[
'model.6.bias'
]
=
state_dict
[
'conv_up2.bias'
]
crt_net
[
'model.6.bias'
]
=
state_dict
[
'conv_up2.bias'
]
crt_net
[
'model.8.weight'
]
=
state_dict
[
'conv_hr.weight'
]
crt_net
[
'model.8.bias'
]
=
state_dict
[
'conv_hr.bias'
]
if
'conv_up3.weight'
in
state_dict
:
crt_net
[
'model.10.weight'
]
=
state_dict
[
'conv_last.weight'
]
# modification supporting: https://github.com/ai-forever/Real-ESRGAN/blob/main/RealESRGAN/rrdbnet_arch.py
crt_net
[
'model.10.bias'
]
=
state_dict
[
'conv_last.bias'
]
re8x
=
3
crt_net
[
'model.9.weight'
]
=
state_dict
[
'conv_up3.weight'
]
crt_net
[
'model.9.bias'
]
=
state_dict
[
'conv_up3.bias'
]
crt_net
[
f
'model.
{
8
+
re8x
}
.weight'
]
=
state_dict
[
'conv_hr.weight'
]
crt_net
[
f
'model.
{
8
+
re8x
}
.bias'
]
=
state_dict
[
'conv_hr.bias'
]
crt_net
[
f
'model.
{
10
+
re8x
}
.weight'
]
=
state_dict
[
'conv_last.weight'
]
crt_net
[
f
'model.
{
10
+
re8x
}
.bias'
]
=
state_dict
[
'conv_last.bias'
]
state_dict
=
crt_net
state_dict
=
crt_net
return
state_dict
return
state_dict
...
...
modules/modelloader.py
浏览文件 @
c9bb33dd
...
@@ -85,6 +85,9 @@ def cleanup_models():
...
@@ -85,6 +85,9 @@ def cleanup_models():
src_path
=
os
.
path
.
join
(
root_path
,
"ESRGAN"
)
src_path
=
os
.
path
.
join
(
root_path
,
"ESRGAN"
)
dest_path
=
os
.
path
.
join
(
models_path
,
"ESRGAN"
)
dest_path
=
os
.
path
.
join
(
models_path
,
"ESRGAN"
)
move_files
(
src_path
,
dest_path
)
move_files
(
src_path
,
dest_path
)
src_path
=
os
.
path
.
join
(
models_path
,
"BSRGAN"
)
dest_path
=
os
.
path
.
join
(
models_path
,
"ESRGAN"
)
move_files
(
src_path
,
dest_path
,
".pth"
)
src_path
=
os
.
path
.
join
(
root_path
,
"gfpgan"
)
src_path
=
os
.
path
.
join
(
root_path
,
"gfpgan"
)
dest_path
=
os
.
path
.
join
(
models_path
,
"GFPGAN"
)
dest_path
=
os
.
path
.
join
(
models_path
,
"GFPGAN"
)
move_files
(
src_path
,
dest_path
)
move_files
(
src_path
,
dest_path
)
...
...
modules/ui.py
浏览文件 @
c9bb33dd
...
@@ -1059,7 +1059,7 @@ def create_ui(wrap_gradio_gpu_call):
...
@@ -1059,7 +1059,7 @@ def create_ui(wrap_gradio_gpu_call):
with
gr
.
Tabs
(
elem_id
=
"extras_resize_mode"
):
with
gr
.
Tabs
(
elem_id
=
"extras_resize_mode"
):
with
gr
.
TabItem
(
'Scale by'
):
with
gr
.
TabItem
(
'Scale by'
):
upscaling_resize
=
gr
.
Slider
(
minimum
=
1.0
,
maximum
=
4.0
,
step
=
0.05
,
label
=
"Resize"
,
value
=
2
)
upscaling_resize
=
gr
.
Slider
(
minimum
=
1.0
,
maximum
=
8.0
,
step
=
0.05
,
label
=
"Resize"
,
value
=
4
)
with
gr
.
TabItem
(
'Scale to'
):
with
gr
.
TabItem
(
'Scale to'
):
with
gr
.
Group
():
with
gr
.
Group
():
with
gr
.
Row
():
with
gr
.
Row
():
...
...
modules/upscaler.py
浏览文件 @
c9bb33dd
...
@@ -10,6 +10,7 @@ import modules.shared
...
@@ -10,6 +10,7 @@ import modules.shared
from
modules
import
modelloader
,
shared
from
modules
import
modelloader
,
shared
LANCZOS
=
(
Image
.
Resampling
.
LANCZOS
if
hasattr
(
Image
,
'Resampling'
)
else
Image
.
LANCZOS
)
LANCZOS
=
(
Image
.
Resampling
.
LANCZOS
if
hasattr
(
Image
,
'Resampling'
)
else
Image
.
LANCZOS
)
NEAREST
=
(
Image
.
Resampling
.
NEAREST
if
hasattr
(
Image
,
'Resampling'
)
else
Image
.
NEAREST
)
from
modules.paths
import
models_path
from
modules.paths
import
models_path
...
@@ -57,7 +58,7 @@ class Upscaler:
...
@@ -57,7 +58,7 @@ class Upscaler:
dest_w
=
img
.
width
*
scale
dest_w
=
img
.
width
*
scale
dest_h
=
img
.
height
*
scale
dest_h
=
img
.
height
*
scale
for
i
in
range
(
3
):
for
i
in
range
(
3
):
if
img
.
width
>
=
dest_w
and
img
.
height
>=
dest_h
:
if
img
.
width
>
dest_w
and
img
.
height
>
dest_h
:
break
break
img
=
self
.
do_upscale
(
img
,
selected_model
)
img
=
self
.
do_upscale
(
img
,
selected_model
)
if
img
.
width
!=
dest_w
or
img
.
height
!=
dest_h
:
if
img
.
width
!=
dest_w
or
img
.
height
!=
dest_h
:
...
@@ -120,3 +121,17 @@ class UpscalerLanczos(Upscaler):
...
@@ -120,3 +121,17 @@ class UpscalerLanczos(Upscaler):
self
.
name
=
"Lanczos"
self
.
name
=
"Lanczos"
self
.
scalers
=
[
UpscalerData
(
"Lanczos"
,
None
,
self
)]
self
.
scalers
=
[
UpscalerData
(
"Lanczos"
,
None
,
self
)]
class
UpscalerNearest
(
Upscaler
):
scalers
=
[]
def
do_upscale
(
self
,
img
,
selected_model
=
None
):
return
img
.
resize
((
int
(
img
.
width
*
self
.
scale
),
int
(
img
.
height
*
self
.
scale
)),
resample
=
NEAREST
)
def
load_model
(
self
,
_
):
pass
def
__init__
(
self
,
dirname
=
None
):
super
().
__init__
(
False
)
self
.
name
=
"Nearest"
self
.
scalers
=
[
UpscalerData
(
"Nearest"
,
None
,
self
)]
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录