Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
3f7f61e5
S
Stable Diffusion Webui
项目概览
Overbill1683
/
Stable Diffusion Webui
10 个月 前同步成功
通知
1746
Star
81
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
S
Stable Diffusion Webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
3f7f61e5
编写于
1月 04, 2024
作者:
A
AUTOMATIC1111
提交者:
GitHub
1月 04, 2024
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14524 from akx/fix-swinir-issues
Fix SwinIR issues
上级
1e7a8ce5
62470ee2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
7 addition
and
6 deletion
+7
-6
extensions-builtin/SwinIR/scripts/swinir_model.py
extensions-builtin/SwinIR/scripts/swinir_model.py
+3
-2
modules/upscaler_utils.py
modules/upscaler_utils.py
+4
-4
未找到文件。
extensions-builtin/SwinIR/scripts/swinir_model.py
浏览文件 @
3f7f61e5
import
logging
import
sys
import
torch
from
PIL
import
Image
from
modules
import
devices
,
modelloader
,
script_callbacks
,
shared
,
upscaler_utils
...
...
@@ -50,7 +51,7 @@ class UpscalerSwinIR(Upscaler):
model
,
tile_size
=
shared
.
opts
.
SWIN_tile
,
tile_overlap
=
shared
.
opts
.
SWIN_tile_overlap
,
scale
=
4
,
# TODO: This was hard-coded before too...
scale
=
model
.
scale
,
desc
=
"SwinIR"
,
)
devices
.
torch_gc
()
...
...
@@ -69,7 +70,7 @@ class UpscalerSwinIR(Upscaler):
model_descriptor
=
modelloader
.
load_spandrel_model
(
filename
,
device
=
self
.
_get_device
(),
dtype
=
devices
.
dtype
,
prefer_half
=
(
devices
.
dtype
==
torch
.
float16
)
,
expected_architecture
=
"SwinIR"
,
)
if
getattr
(
shared
.
opts
,
'SWIN_torch_compile'
,
False
):
...
...
modules/upscaler_utils.py
浏览文件 @
3f7f61e5
...
...
@@ -94,6 +94,7 @@ def tiled_upscale_2(
tile_size
:
int
,
tile_overlap
:
int
,
scale
:
int
,
device
:
torch
.
device
,
desc
=
"Tiled upscale"
,
):
# Alternative implementation of `upscale_with_model` originally used by
...
...
@@ -101,9 +102,6 @@ def tiled_upscale_2(
# weighting is done in PyTorch space, as opposed to `images.Grid` doing it in
# Pillow space without weighting.
# Grab the device the model is on, and use it.
device
=
torch_utils
.
get_param
(
model
).
device
b
,
c
,
h
,
w
=
img
.
size
()
tile_size
=
min
(
tile_size
,
h
,
w
)
...
...
@@ -175,7 +173,8 @@ def upscale_2(
"""
Convenience wrapper around `tiled_upscale_2` that handles PIL images.
"""
tensor
=
pil_image_to_torch_bgr
(
img
).
float
().
unsqueeze
(
0
)
# add batch dimension
param
=
torch_utils
.
get_param
(
model
)
tensor
=
pil_image_to_torch_bgr
(
img
).
to
(
dtype
=
param
.
dtype
).
unsqueeze
(
0
)
# add batch dimension
with
torch
.
no_grad
():
output
=
tiled_upscale_2
(
...
...
@@ -185,5 +184,6 @@ def upscale_2(
tile_overlap
=
tile_overlap
,
scale
=
scale
,
desc
=
desc
,
device
=
param
.
device
,
)
return
torch_bgr_to_pil_image
(
output
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录