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
657074a7
Commit
657074a7
authored
Sep 03, 2022
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
option to invert mask for inpainting
parent
e67a56db
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
5 deletions
+18
-5
modules/img2img.py
modules/img2img.py
+2
-1
modules/processing.py
modules/processing.py
+8
-2
modules/ui.py
modules/ui.py
+8
-2
No files found.
modules/img2img.py
View file @
657074a7
...
...
@@ -9,7 +9,7 @@ from modules.ui import plaintext_to_html
import
modules.images
as
images
import
modules.scripts
def
img2img
(
prompt
:
str
,
init_img
,
init_img_with_mask
,
steps
:
int
,
sampler_index
:
int
,
mask_blur
:
int
,
inpainting_fill
:
int
,
use_GFPGAN
:
bool
,
mode
:
int
,
n_iter
:
int
,
batch_size
:
int
,
cfg_scale
:
float
,
denoising_strength
:
float
,
seed
:
int
,
height
:
int
,
width
:
int
,
resize_mode
:
int
,
upscaler_name
:
str
,
upscale_overlap
:
int
,
inpaint_full_res
:
bool
,
*
args
):
def
img2img
(
prompt
:
str
,
init_img
,
init_img_with_mask
,
steps
:
int
,
sampler_index
:
int
,
mask_blur
:
int
,
inpainting_fill
:
int
,
use_GFPGAN
:
bool
,
mode
:
int
,
n_iter
:
int
,
batch_size
:
int
,
cfg_scale
:
float
,
denoising_strength
:
float
,
seed
:
int
,
height
:
int
,
width
:
int
,
resize_mode
:
int
,
upscaler_name
:
str
,
upscale_overlap
:
int
,
inpaint_full_res
:
bool
,
inpainting_mask_invert
:
int
,
*
args
):
is_inpaint
=
mode
==
1
is_loopback
=
mode
==
2
is_upscale
=
mode
==
3
...
...
@@ -44,6 +44,7 @@ def img2img(prompt: str, init_img, init_img_with_mask, steps: int, sampler_index
resize_mode
=
resize_mode
,
denoising_strength
=
denoising_strength
,
inpaint_full_res
=
inpaint_full_res
,
inpainting_mask_invert
=
inpainting_mask_invert
,
extra_generation_params
=
{
"Denoising Strength"
:
denoising_strength
}
)
...
...
modules/processing.py
View file @
657074a7
...
...
@@ -282,7 +282,7 @@ def fill(image, mask):
class
StableDiffusionProcessingImg2Img
(
StableDiffusionProcessing
):
sampler
=
None
def
__init__
(
self
,
init_images
=
None
,
resize_mode
=
0
,
denoising_strength
=
0.75
,
mask
=
None
,
mask_blur
=
4
,
inpainting_fill
=
0
,
inpaint_full_res
=
True
,
**
kwargs
):
def
__init__
(
self
,
init_images
=
None
,
resize_mode
=
0
,
denoising_strength
=
0.75
,
mask
=
None
,
mask_blur
=
4
,
inpainting_fill
=
0
,
inpaint_full_res
=
True
,
inpainting_mask_invert
=
0
,
**
kwargs
):
super
()
.
__init__
(
**
kwargs
)
self
.
init_images
=
init_images
...
...
@@ -294,6 +294,7 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing):
self
.
mask_blur
=
mask_blur
self
.
inpainting_fill
=
inpainting_fill
self
.
inpaint_full_res
=
inpaint_full_res
self
.
inpainting_mask_invert
=
inpainting_mask_invert
self
.
mask
=
None
self
.
nmask
=
None
...
...
@@ -302,8 +303,13 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing):
crop_region
=
None
if
self
.
image_mask
is
not
None
:
self
.
image_mask
=
self
.
image_mask
.
convert
(
'L'
)
if
self
.
inpainting_mask_invert
:
self
.
image_mask
=
ImageOps
.
invert
(
self
.
image_mask
)
if
self
.
mask_blur
>
0
:
self
.
image_mask
=
self
.
image_mask
.
filter
(
ImageFilter
.
GaussianBlur
(
self
.
mask_blur
))
.
convert
(
'L'
)
self
.
image_mask
=
self
.
image_mask
.
filter
(
ImageFilter
.
GaussianBlur
(
self
.
mask_blur
))
if
self
.
inpaint_full_res
:
self
.
mask_for_overlay
=
self
.
image_mask
...
...
modules/ui.py
View file @
657074a7
...
...
@@ -241,11 +241,14 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
steps
=
gr
.
Slider
(
minimum
=
1
,
maximum
=
150
,
step
=
1
,
label
=
"Sampling Steps"
,
value
=
20
)
sampler_index
=
gr
.
Radio
(
label
=
'Sampling method'
,
choices
=
[
x
.
name
for
x
in
samplers_for_img2img
],
value
=
samplers_for_img2img
[
0
]
.
name
,
type
=
"index"
)
mask_blur
=
gr
.
Slider
(
label
=
'Mask blur'
,
minimum
=
0
,
maximum
=
64
,
step
=
1
,
value
=
4
,
visible
=
False
)
inpainting_fill
=
gr
.
Radio
(
label
=
'Msked content'
,
choices
=
[
'fill'
,
'original'
,
'latent noise'
,
'latent nothing'
],
value
=
'fill'
,
type
=
"index"
,
visible
=
False
)
inpainting_fill
=
gr
.
Radio
(
label
=
'M
a
sked content'
,
choices
=
[
'fill'
,
'original'
,
'latent noise'
,
'latent nothing'
],
value
=
'fill'
,
type
=
"index"
,
visible
=
False
)
with
gr
.
Row
():
use_gfpgan
=
gr
.
Checkbox
(
label
=
'GFPGAN'
,
value
=
False
,
visible
=
gfpgan
.
have_gfpgan
)
inpaint_full_res
=
gr
.
Checkbox
(
label
=
'Inpaint at full resolution'
,
value
=
True
,
visible
=
False
)
inpainting_mask_invert
=
gr
.
Radio
(
label
=
'Masking mode'
,
choices
=
[
'Inpaint masked'
,
'Inpaint not masked'
],
value
=
'Inpaint masked'
,
type
=
"index"
,
visible
=
False
)
with
gr
.
Row
():
use_gfpgan
=
gr
.
Checkbox
(
label
=
'GFPGAN'
,
value
=
False
,
visible
=
gfpgan
.
have_gfpgan
)
with
gr
.
Row
():
sd_upscale_upscaler_name
=
gr
.
Radio
(
label
=
'Upscaler'
,
choices
=
list
(
shared
.
sd_upscalers
.
keys
()),
value
=
list
(
shared
.
sd_upscalers
.
keys
())[
0
],
visible
=
False
)
...
...
@@ -299,6 +302,7 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
sd_upscale_upscaler_name
:
gr_show
(
is_upscale
),
sd_upscale_overlap
:
gr_show
(
is_upscale
),
inpaint_full_res
:
gr_show
(
is_inpaint
),
inpainting_mask_invert
:
gr_show
(
is_inpaint
),
}
switch_mode
.
change
(
...
...
@@ -314,6 +318,7 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
sd_upscale_upscaler_name
,
sd_upscale_overlap
,
inpaint_full_res
,
inpainting_mask_invert
,
]
)
...
...
@@ -340,6 +345,7 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
sd_upscale_upscaler_name
,
sd_upscale_overlap
,
inpaint_full_res
,
inpainting_mask_invert
,
]
+
custom_inputs
,
outputs
=
[
img2img_gallery
,
...
...
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