Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
73e635ce
S
Stable Diffusion Webui
项目概览
Overbill1683
/
Stable Diffusion Webui
9 个月 前同步成功
通知
1727
Star
80
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
S
Stable Diffusion Webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
73e635ce
编写于
3月 06, 2024
作者:
C
continue-revolution
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix
上级
bef51aed
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
20 addition
and
6 deletion
+20
-6
extensions-builtin/soft-inpainting/scripts/soft_inpainting.py
...nsions-builtin/soft-inpainting/scripts/soft_inpainting.py
+20
-6
未找到文件。
extensions-builtin/soft-inpainting/scripts/soft_inpainting.py
浏览文件 @
73e635ce
...
...
@@ -57,10 +57,14 @@ def latent_blend(settings, a, b, t):
# NOTE: We use inplace operations wherever possible.
# [4][w][h] to [1][4][w][h]
t2
=
t
.
unsqueeze
(
0
)
# [4][w][h] to [1][1][w][h] - the [4] seem redundant.
t3
=
t
[
0
].
unsqueeze
(
0
).
unsqueeze
(
0
)
if
len
(
t
.
shape
)
==
3
:
# [4][w][h] to [1][4][w][h]
t2
=
t
.
unsqueeze
(
0
)
# [4][w][h] to [1][1][w][h] - the [4] seem redundant.
t3
=
t
[
0
].
unsqueeze
(
0
).
unsqueeze
(
0
)
else
:
t2
=
t
t3
=
t
[:,
0
][:,
None
]
one_minus_t2
=
1
-
t2
one_minus_t3
=
1
-
t3
...
...
@@ -135,7 +139,10 @@ def apply_adaptive_masks(
from
PIL
import
Image
,
ImageOps
,
ImageFilter
# TODO: Bias the blending according to the latent mask, add adjustable parameter for bias control.
latent_mask
=
nmask
[
0
].
float
()
if
len
(
nmask
.
shape
)
==
3
:
latent_mask
=
nmask
[
0
].
float
()
else
:
latent_mask
=
nmask
[:,
0
].
float
()
# convert the original mask into a form we use to scale distances for thresholding
mask_scalar
=
1
-
(
torch
.
clamp
(
latent_mask
,
min
=
0
,
max
=
1
)
**
(
settings
.
mask_blend_scale
/
2
))
mask_scalar
=
(
0.5
*
(
1
-
settings
.
composite_mask_influence
)
...
...
@@ -157,7 +164,14 @@ def apply_adaptive_masks(
percentile_min
=
0.25
,
percentile_max
=
0.75
,
min_width
=
1
)
# The distance at which opacity of original decreases to 50%
half_weighted_distance
=
settings
.
composite_difference_threshold
*
mask_scalar
if
len
(
mask_scalar
.
shape
)
==
3
:
if
mask_scalar
.
shape
[
0
]
>
i
:
half_weighted_distance
=
settings
.
composite_difference_threshold
*
mask_scalar
[
i
]
else
:
half_weighted_distance
=
settings
.
composite_difference_threshold
*
mask_scalar
[
0
]
else
:
# len(mask_scalar.shape) == 3:
half_weighted_distance
=
settings
.
composite_difference_threshold
*
mask_scalar
converted_mask
=
converted_mask
/
half_weighted_distance
converted_mask
=
1
/
(
1
+
converted_mask
**
settings
.
composite_difference_contrast
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录