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
1ae860cf
Commit
1ae860cf
authored
Oct 29, 2022
by
Jonathan Beltran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
this fixes a bug with use_scale_latent_for_hires_fix
parent
ccf95b0e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
5 deletions
+29
-5
modules/processing.py
modules/processing.py
+29
-5
No files found.
modules/processing.py
View file @
1ae860cf
...
...
@@ -643,6 +643,27 @@ class StableDiffusionProcessingTxt2Img(StableDiffusionProcessing):
self
.
truncate_x
=
int
(
self
.
firstphase_width
-
firstphase_width_truncated
)
//
opt_f
self
.
truncate_y
=
int
(
self
.
firstphase_height
-
firstphase_height_truncated
)
//
opt_f
def
create_dummy_mask
(
self
,
x
,
width
=
None
,
height
=
None
):
if
self
.
sampler
.
conditioning_key
in
{
'hybrid'
,
'concat'
}:
height
=
height
or
self
.
height
width
=
width
or
self
.
width
# The "masked-image" in this case will just be all zeros since the entire image is masked.
image_conditioning
=
torch
.
zeros
(
x
.
shape
[
0
],
3
,
height
,
width
,
device
=
x
.
device
)
image_conditioning
=
self
.
sd_model
.
get_first_stage_encoding
(
self
.
sd_model
.
encode_first_stage
(
image_conditioning
))
# 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
=
image_conditioning
.
to
(
x
.
dtype
)
else
:
# Dummy zero conditioning if we're not using inpainting model.
# Still takes up a bit of memory, but no encoder call.
# Pretty sure we can just make this a 1x1 image since its not going to be used besides its batch size.
image_conditioning
=
torch
.
zeros
(
x
.
shape
[
0
],
5
,
1
,
1
,
dtype
=
x
.
dtype
,
device
=
x
.
device
)
return
image_conditioning
def
sample
(
self
,
conditioning
,
unconditional_conditioning
,
seeds
,
subseeds
,
subseed_strength
):
self
.
sampler
=
sd_samplers
.
create_sampler_with_index
(
sd_samplers
.
samplers
,
self
.
sampler_index
,
self
.
sd_model
)
...
...
@@ -690,11 +711,14 @@ class StableDiffusionProcessingTxt2Img(StableDiffusionProcessing):
x
=
None
devices
.
torch_gc
()
image_conditioning
=
self
.
img2img_image_conditioning
(
decoded_samples
,
samples
,
decoded_samples
.
new_ones
(
decoded_samples
.
shape
[
0
],
1
,
decoded_samples
.
shape
[
2
],
decoded_samples
.
shape
[
3
])
)
if
opts
.
use_scale_latent_for_hires_fix
:
image_conditioning
=
self
.
create_dummy_mask
(
samples
)
else
:
image_conditioning
=
self
.
img2img_image_conditioning
(
decoded_samples
,
samples
,
decoded_samples
.
new_ones
(
decoded_samples
.
shape
[
0
],
1
,
decoded_samples
.
shape
[
2
],
decoded_samples
.
shape
[
3
])
)
samples
=
self
.
sampler
.
sample_img2img
(
self
,
samples
,
noise
,
conditioning
,
unconditional_conditioning
,
steps
=
self
.
steps
,
image_conditioning
=
image_conditioning
)
return
samples
...
...
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