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
d09d33bc
Commit
d09d33bc
authored
Aug 15, 2023
by
AUTOMATIC1111
Committed by
GitHub
Aug 15, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12588 from catboxanon/fix/inpaint-upload
Fix inpaint upload for alpha masks
parents
85fcb7b8
0f771392
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
3 deletions
+11
-3
modules/img2img.py
modules/img2img.py
+1
-1
modules/processing.py
modules/processing.py
+9
-1
modules/ui.py
modules/ui.py
+1
-1
No files found.
modules/img2img.py
View file @
d09d33bc
...
@@ -129,7 +129,7 @@ def img2img(id_task: str, mode: int, prompt: str, negative_prompt: str, prompt_s
...
@@ -129,7 +129,7 @@ def img2img(id_task: str, mode: int, prompt: str, negative_prompt: str, prompt_s
mask
=
None
mask
=
None
elif
mode
==
2
:
# inpaint
elif
mode
==
2
:
# inpaint
image
,
mask
=
init_img_with_mask
[
"image"
],
init_img_with_mask
[
"mask"
]
image
,
mask
=
init_img_with_mask
[
"image"
],
init_img_with_mask
[
"mask"
]
mask
=
mask
.
split
()[
-
1
]
.
convert
(
"L"
)
.
point
(
lambda
x
:
255
if
x
>
128
else
0
)
mask
=
processing
.
create_binary_mask
(
mask
)
image
=
image
.
convert
(
"RGB"
)
image
=
image
.
convert
(
"RGB"
)
elif
mode
==
3
:
# inpaint sketch
elif
mode
==
3
:
# inpaint sketch
image
=
inpaint_color_sketch
image
=
inpaint_color_sketch
...
...
modules/processing.py
View file @
d09d33bc
...
@@ -81,6 +81,12 @@ def apply_overlay(image, paste_loc, index, overlays):
...
@@ -81,6 +81,12 @@ def apply_overlay(image, paste_loc, index, overlays):
return
image
return
image
def
create_binary_mask
(
image
):
if
image
.
mode
==
'RGBA'
and
image
.
getextrema
()[
-
1
]
!=
(
255
,
255
):
image
=
image
.
split
()[
-
1
]
.
convert
(
"L"
)
.
point
(
lambda
x
:
255
if
x
>
128
else
0
)
else
:
image
=
image
.
convert
(
'L'
)
return
image
def
txt2img_image_conditioning
(
sd_model
,
x
,
width
,
height
):
def
txt2img_image_conditioning
(
sd_model
,
x
,
width
,
height
):
if
sd_model
.
model
.
conditioning_key
in
{
'hybrid'
,
'concat'
}:
# Inpainting models
if
sd_model
.
model
.
conditioning_key
in
{
'hybrid'
,
'concat'
}:
# Inpainting models
...
@@ -1385,7 +1391,9 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing):
...
@@ -1385,7 +1391,9 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing):
image_mask
=
self
.
image_mask
image_mask
=
self
.
image_mask
if
image_mask
is
not
None
:
if
image_mask
is
not
None
:
image_mask
=
image_mask
.
convert
(
'L'
)
# image_mask is passed in as RGBA by Gradio to support alpha masks,
# but we still want to support binary masks.
image_mask
=
create_binary_mask
(
image_mask
)
if
self
.
inpainting_mask_invert
:
if
self
.
inpainting_mask_invert
:
image_mask
=
ImageOps
.
invert
(
image_mask
)
image_mask
=
ImageOps
.
invert
(
image_mask
)
...
...
modules/ui.py
View file @
d09d33bc
...
@@ -598,7 +598,7 @@ def create_ui():
...
@@ -598,7 +598,7 @@ def create_ui():
with
gr
.
TabItem
(
'Inpaint upload'
,
id
=
'inpaint_upload'
,
elem_id
=
"img2img_inpaint_upload_tab"
)
as
tab_inpaint_upload
:
with
gr
.
TabItem
(
'Inpaint upload'
,
id
=
'inpaint_upload'
,
elem_id
=
"img2img_inpaint_upload_tab"
)
as
tab_inpaint_upload
:
init_img_inpaint
=
gr
.
Image
(
label
=
"Image for img2img"
,
show_label
=
False
,
source
=
"upload"
,
interactive
=
True
,
type
=
"pil"
,
elem_id
=
"img_inpaint_base"
)
init_img_inpaint
=
gr
.
Image
(
label
=
"Image for img2img"
,
show_label
=
False
,
source
=
"upload"
,
interactive
=
True
,
type
=
"pil"
,
elem_id
=
"img_inpaint_base"
)
init_mask_inpaint
=
gr
.
Image
(
label
=
"Mask"
,
source
=
"upload"
,
interactive
=
True
,
type
=
"pil"
,
elem_id
=
"img_inpaint_mask"
)
init_mask_inpaint
=
gr
.
Image
(
label
=
"Mask"
,
source
=
"upload"
,
interactive
=
True
,
type
=
"pil"
,
image_mode
=
"RGBA"
,
elem_id
=
"img_inpaint_mask"
)
with
gr
.
TabItem
(
'Batch'
,
id
=
'batch'
,
elem_id
=
"img2img_batch_tab"
)
as
tab_batch
:
with
gr
.
TabItem
(
'Batch'
,
id
=
'batch'
,
elem_id
=
"img2img_batch_tab"
)
as
tab_batch
:
hidden
=
'<br>Disabled when launched with --hide-ui-dir-config.'
if
shared
.
cmd_opts
.
hide_ui_dir_config
else
''
hidden
=
'<br>Disabled when launched with --hide-ui-dir-config.'
if
shared
.
cmd_opts
.
hide_ui_dir_config
else
''
...
...
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