Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stable-diffusion-webui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
stable-diffusion-webui
Commits
10421f93
Commit
10421f93
authored
Jan 26, 2023
by
brkirch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix full previews, --no-half-vae
parent
6cff4401
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
processing.py
modules/processing.py
+4
-4
sd_hijack_utils.py
modules/sd_hijack_utils.py
+1
-1
No files found.
modules/processing.py
View file @
10421f93
...
@@ -172,7 +172,7 @@ class StableDiffusionProcessing:
...
@@ -172,7 +172,7 @@ class StableDiffusionProcessing:
midas_in
=
torch
.
from_numpy
(
transformed
[
"midas_in"
][
None
,
...
])
.
to
(
device
=
shared
.
device
)
midas_in
=
torch
.
from_numpy
(
transformed
[
"midas_in"
][
None
,
...
])
.
to
(
device
=
shared
.
device
)
midas_in
=
repeat
(
midas_in
,
"1 ... -> n ..."
,
n
=
self
.
batch_size
)
midas_in
=
repeat
(
midas_in
,
"1 ... -> n ..."
,
n
=
self
.
batch_size
)
conditioning_image
=
self
.
sd_model
.
get_first_stage_encoding
(
self
.
sd_model
.
encode_first_stage
(
source_image
.
to
(
devices
.
dtype_
unet
)
if
devices
.
unet_needs_upcast
else
source_image
))
conditioning_image
=
self
.
sd_model
.
get_first_stage_encoding
(
self
.
sd_model
.
encode_first_stage
(
source_image
.
to
(
devices
.
dtype_
vae
)
if
devices
.
unet_needs_upcast
else
source_image
))
conditioning_image
=
conditioning_image
.
float
()
if
devices
.
unet_needs_upcast
else
conditioning_image
conditioning_image
=
conditioning_image
.
float
()
if
devices
.
unet_needs_upcast
else
conditioning_image
conditioning
=
torch
.
nn
.
functional
.
interpolate
(
conditioning
=
torch
.
nn
.
functional
.
interpolate
(
self
.
sd_model
.
depth_model
(
midas_in
),
self
.
sd_model
.
depth_model
(
midas_in
),
...
@@ -217,7 +217,7 @@ class StableDiffusionProcessing:
...
@@ -217,7 +217,7 @@ class StableDiffusionProcessing:
)
)
# Encode the new masked image using first stage of network.
# Encode the new masked image using first stage of network.
conditioning_image
=
self
.
sd_model
.
get_first_stage_encoding
(
self
.
sd_model
.
encode_first_stage
(
conditioning_image
.
to
(
devices
.
dtype_
unet
)
if
devices
.
unet_needs_upcast
else
conditioning_image
))
conditioning_image
=
self
.
sd_model
.
get_first_stage_encoding
(
self
.
sd_model
.
encode_first_stage
(
conditioning_image
.
to
(
devices
.
dtype_
vae
)
if
devices
.
unet_needs_upcast
else
conditioning_image
))
# Create the concatenated conditioning tensor to be fed to `c_concat`
# Create the concatenated conditioning tensor to be fed to `c_concat`
conditioning_mask
=
torch
.
nn
.
functional
.
interpolate
(
conditioning_mask
,
size
=
latent_image
.
shape
[
-
2
:])
conditioning_mask
=
torch
.
nn
.
functional
.
interpolate
(
conditioning_mask
,
size
=
latent_image
.
shape
[
-
2
:])
...
@@ -417,7 +417,7 @@ def create_random_tensors(shape, seeds, subseeds=None, subseed_strength=0.0, see
...
@@ -417,7 +417,7 @@ def create_random_tensors(shape, seeds, subseeds=None, subseed_strength=0.0, see
def
decode_first_stage
(
model
,
x
):
def
decode_first_stage
(
model
,
x
):
with
devices
.
autocast
(
disable
=
x
.
dtype
==
devices
.
dtype_vae
):
with
devices
.
autocast
(
disable
=
x
.
dtype
==
devices
.
dtype_vae
):
x
=
model
.
decode_first_stage
(
x
)
x
=
model
.
decode_first_stage
(
x
.
to
(
devices
.
dtype_vae
)
if
devices
.
unet_needs_upcast
else
x
)
return
x
return
x
...
@@ -1001,7 +1001,7 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing):
...
@@ -1001,7 +1001,7 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing):
image
=
torch
.
from_numpy
(
batch_images
)
image
=
torch
.
from_numpy
(
batch_images
)
image
=
2.
*
image
-
1.
image
=
2.
*
image
-
1.
image
=
image
.
to
(
device
=
shared
.
device
,
dtype
=
devices
.
dtype_
unet
if
devices
.
unet_needs_upcast
else
None
)
image
=
image
.
to
(
device
=
shared
.
device
,
dtype
=
devices
.
dtype_
vae
if
devices
.
unet_needs_upcast
else
None
)
self
.
init_latent
=
self
.
sd_model
.
get_first_stage_encoding
(
self
.
sd_model
.
encode_first_stage
(
image
))
self
.
init_latent
=
self
.
sd_model
.
get_first_stage_encoding
(
self
.
sd_model
.
encode_first_stage
(
image
))
...
...
modules/sd_hijack_utils.py
View file @
10421f93
...
@@ -5,7 +5,7 @@ class CondFunc:
...
@@ -5,7 +5,7 @@ class CondFunc:
self
=
super
(
CondFunc
,
cls
)
.
__new__
(
cls
)
self
=
super
(
CondFunc
,
cls
)
.
__new__
(
cls
)
if
isinstance
(
orig_func
,
str
):
if
isinstance
(
orig_func
,
str
):
func_path
=
orig_func
.
split
(
'.'
)
func_path
=
orig_func
.
split
(
'.'
)
for
i
in
range
(
len
(
func_path
)
-
2
,
-
1
,
-
1
):
for
i
in
range
(
len
(
func_path
)
-
1
,
-
1
,
-
1
):
try
:
try
:
resolved_obj
=
importlib
.
import_module
(
'.'
.
join
(
func_path
[:
i
]))
resolved_obj
=
importlib
.
import_module
(
'.'
.
join
(
func_path
[:
i
]))
break
break
...
...
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