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
d875cda5
Commit
d875cda5
authored
Jun 08, 2024
by
huchenlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix sdxl inpaint
parent
547778b1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
9 deletions
+14
-9
modules/processing.py
modules/processing.py
+2
-2
modules/sd_models.py
modules/sd_models.py
+12
-7
No files found.
modules/processing.py
View file @
d875cda5
...
...
@@ -115,7 +115,7 @@ def txt2img_image_conditioning(sd_model, x, width, height):
return
x
.
new_zeros
(
x
.
shape
[
0
],
2
*
sd_model
.
noise_augmentor
.
time_embed
.
dim
,
dtype
=
x
.
dtype
,
device
=
x
.
device
)
else
:
if
getattr
(
sd_model
.
model
,
"is_sdxl_inpaint"
,
False
)
:
if
sd_model
.
is_sdxl_inpaint
:
# The "masked-image" in this case will just be all 0.5 since the entire image is masked.
image_conditioning
=
torch
.
ones
(
x
.
shape
[
0
],
3
,
height
,
width
,
device
=
x
.
device
)
*
0.5
image_conditioning
=
images_tensor_to_samples
(
image_conditioning
,
...
...
@@ -389,7 +389,7 @@ class StableDiffusionProcessing:
if
self
.
sampler
.
conditioning_key
==
"crossattn-adm"
:
return
self
.
unclip_image_conditioning
(
source_image
)
if
getattr
(
self
.
sampler
.
model_wrap
.
inner_model
.
model
,
"is_sdxl_inpaint"
,
False
)
:
if
self
.
sampler
.
model_wrap
.
inner_model
.
is_sdxl_inpaint
:
return
self
.
inpainting_image_conditioning
(
source_image
,
latent_image
,
image_mask
=
image_mask
)
# Dummy zero conditioning if we're not using inpainting or depth model.
...
...
modules/sd_models.py
View file @
d875cda5
...
...
@@ -386,13 +386,6 @@ def load_model_weights(model, checkpoint_info: CheckpointInfo, state_dict, timer
model
.
is_sd2
=
not
model
.
is_sdxl
and
hasattr
(
model
.
cond_stage_model
,
'model'
)
model
.
is_sd1
=
not
model
.
is_sdxl
and
not
model
.
is_sd2
model
.
is_ssd
=
model
.
is_sdxl
and
'model.diffusion_model.middle_block.1.transformer_blocks.0.attn1.to_q.weight'
not
in
state_dict
.
keys
()
# Set is_sdxl_inpaint flag.
diffusion_model_input
=
state_dict
.
get
(
'diffusion_model.input_blocks.0.0.weight'
,
None
)
model
.
is_sdxl_inpaint
=
(
model
.
is_sdxl
and
diffusion_model_input
is
not
None
and
diffusion_model_input
.
shape
[
1
]
==
9
)
if
model
.
is_sdxl
:
sd_models_xl
.
extend_sdxl
(
model
)
...
...
@@ -408,6 +401,18 @@ def load_model_weights(model, checkpoint_info: CheckpointInfo, state_dict, timer
del
state_dict
# Set is_sdxl_inpaint flag.
# Perform this check after model initialization to make sure state_dict
# structure is already known.
diffusion_model_input
=
model
.
model
.
state_dict
()
.
get
(
'diffusion_model.input_blocks.0.0.weight'
)
model
.
is_sdxl_inpaint
=
(
model
.
is_sdxl
and
diffusion_model_input
is
not
None
and
diffusion_model_input
.
shape
[
1
]
==
9
)
if
shared
.
cmd_opts
.
opt_channelslast
:
model
.
to
(
memory_format
=
torch
.
channels_last
)
timer
.
record
(
"apply channels_last"
)
...
...
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