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
bfe418a5
Commit
bfe418a5
authored
Dec 27, 2023
by
wangqyqq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add some codes for robust
parent
9feb034e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
13 deletions
+16
-13
modules/processing.py
modules/processing.py
+13
-11
modules/sd_models_xl.py
modules/sd_models_xl.py
+3
-2
No files found.
modules/processing.py
View file @
bfe418a5
...
@@ -108,17 +108,18 @@ def txt2img_image_conditioning(sd_model, x, width, height):
...
@@ -108,17 +108,18 @@ def txt2img_image_conditioning(sd_model, x, width, height):
else
:
else
:
sd
=
sd_model
.
model
.
state_dict
()
sd
=
sd_model
.
model
.
state_dict
()
diffusion_model_input
=
sd
.
get
(
'diffusion_model.input_blocks.0.0.weight'
,
None
)
diffusion_model_input
=
sd
.
get
(
'diffusion_model.input_blocks.0.0.weight'
,
None
)
if
diffusion_model_input
.
shape
[
1
]
==
9
:
if
diffusion_model_input
is
not
None
:
# The "masked-image" in this case will just be all 0.5 since the entire image is masked.
if
diffusion_model_input
.
shape
[
1
]
==
9
:
image_conditioning
=
torch
.
ones
(
x
.
shape
[
0
],
3
,
height
,
width
,
device
=
x
.
device
)
*
0.5
# The "masked-image" in this case will just be all 0.5 since the entire image is masked.
image_conditioning
=
images_tensor_to_samples
(
image_conditioning
,
image_conditioning
=
torch
.
ones
(
x
.
shape
[
0
],
3
,
height
,
width
,
device
=
x
.
device
)
*
0.5
approximation_indexes
.
get
(
opts
.
sd_vae_encode_method
))
image_conditioning
=
images_tensor_to_samples
(
image_conditioning
,
approximation_indexes
.
get
(
opts
.
sd_vae_encode_method
))
# Add the fake full 1s mask to the first dimension.
# Add the fake full 1s mask to the first dimension.
image_conditioning
=
torch
.
nn
.
functional
.
pad
(
image_conditioning
,
(
0
,
0
,
0
,
0
,
1
,
0
),
value
=
1.0
)
image_conditioning
=
torch
.
nn
.
functional
.
pad
(
image_conditioning
,
(
0
,
0
,
0
,
0
,
1
,
0
),
value
=
1.0
)
image_conditioning
=
image_conditioning
.
to
(
x
.
dtype
)
image_conditioning
=
image_conditioning
.
to
(
x
.
dtype
)
return
image_conditioning
return
image_conditioning
# Dummy zero conditioning if we're not using inpainting or unclip models.
# Dummy zero conditioning if we're not using inpainting or unclip models.
# Still takes up a bit of memory, but no encoder call.
# Still takes up a bit of memory, but no encoder call.
...
@@ -378,8 +379,9 @@ class StableDiffusionProcessing:
...
@@ -378,8 +379,9 @@ class StableDiffusionProcessing:
sd
=
self
.
sampler
.
model_wrap
.
inner_model
.
model
.
state_dict
()
sd
=
self
.
sampler
.
model_wrap
.
inner_model
.
model
.
state_dict
()
diffusion_model_input
=
sd
.
get
(
'diffusion_model.input_blocks.0.0.weight'
,
None
)
diffusion_model_input
=
sd
.
get
(
'diffusion_model.input_blocks.0.0.weight'
,
None
)
if
diffusion_model_input
.
shape
[
1
]
==
9
:
if
diffusion_model_input
is
not
None
:
return
self
.
inpainting_image_conditioning
(
source_image
,
latent_image
,
image_mask
=
image_mask
)
if
diffusion_model_input
.
shape
[
1
]
==
9
:
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.
# Dummy zero conditioning if we're not using inpainting or depth model.
return
latent_image
.
new_zeros
(
latent_image
.
shape
[
0
],
5
,
1
,
1
)
return
latent_image
.
new_zeros
(
latent_image
.
shape
[
0
],
5
,
1
,
1
)
...
...
modules/sd_models_xl.py
View file @
bfe418a5
...
@@ -36,8 +36,9 @@ def get_learned_conditioning(self: sgm.models.diffusion.DiffusionEngine, batch:
...
@@ -36,8 +36,9 @@ def get_learned_conditioning(self: sgm.models.diffusion.DiffusionEngine, batch:
def
apply_model
(
self
:
sgm
.
models
.
diffusion
.
DiffusionEngine
,
x
,
t
,
cond
):
def
apply_model
(
self
:
sgm
.
models
.
diffusion
.
DiffusionEngine
,
x
,
t
,
cond
):
sd
=
self
.
model
.
state_dict
()
sd
=
self
.
model
.
state_dict
()
diffusion_model_input
=
sd
.
get
(
'diffusion_model.input_blocks.0.0.weight'
,
None
)
diffusion_model_input
=
sd
.
get
(
'diffusion_model.input_blocks.0.0.weight'
,
None
)
if
diffusion_model_input
.
shape
[
1
]
==
9
:
if
diffusion_model_input
is
not
None
:
x
=
torch
.
cat
([
x
]
+
cond
[
'c_concat'
],
dim
=
1
)
if
diffusion_model_input
.
shape
[
1
]
==
9
:
x
=
torch
.
cat
([
x
]
+
cond
[
'c_concat'
],
dim
=
1
)
return
self
.
model
(
x
,
t
,
cond
)
return
self
.
model
(
x
,
t
,
cond
)
...
...
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