Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
73e635ce
Commit
73e635ce
authored
Mar 06, 2024
by
continue-revolution
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
bef51aed
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
6 deletions
+20
-6
extensions-builtin/soft-inpainting/scripts/soft_inpainting.py
...nsions-builtin/soft-inpainting/scripts/soft_inpainting.py
+20
-6
No files found.
extensions-builtin/soft-inpainting/scripts/soft_inpainting.py
View file @
73e635ce
...
...
@@ -57,10 +57,14 @@ def latent_blend(settings, a, b, t):
# NOTE: We use inplace operations wherever possible.
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.
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%
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
)
...
...
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