Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
diffusers
Commits
a7cc468f
Unverified
Commit
a7cc468f
authored
Mar 15, 2023
by
Ilmari Heikkinen
Committed by
GitHub
Mar 14, 2023
Browse files
AutoencoderKL: clamp indices of blend_h and blend_v to input size (#2660)
parent
07a0c1cb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
src/diffusers/models/autoencoder_kl.py
src/diffusers/models/autoencoder_kl.py
+2
-2
tests/pipelines/stable_diffusion/test_stable_diffusion.py
tests/pipelines/stable_diffusion/test_stable_diffusion.py
+6
-0
No files found.
src/diffusers/models/autoencoder_kl.py
View file @
a7cc468f
...
@@ -190,12 +190,12 @@ class AutoencoderKL(ModelMixin, ConfigMixin):
...
@@ -190,12 +190,12 @@ class AutoencoderKL(ModelMixin, ConfigMixin):
return
DecoderOutput
(
sample
=
decoded
)
return
DecoderOutput
(
sample
=
decoded
)
def
blend_v
(
self
,
a
,
b
,
blend_extent
):
def
blend_v
(
self
,
a
,
b
,
blend_extent
):
for
y
in
range
(
blend_extent
):
for
y
in
range
(
min
(
a
.
shape
[
2
],
b
.
shape
[
2
],
blend_extent
)
)
:
b
[:,
:,
y
,
:]
=
a
[:,
:,
-
blend_extent
+
y
,
:]
*
(
1
-
y
/
blend_extent
)
+
b
[:,
:,
y
,
:]
*
(
y
/
blend_extent
)
b
[:,
:,
y
,
:]
=
a
[:,
:,
-
blend_extent
+
y
,
:]
*
(
1
-
y
/
blend_extent
)
+
b
[:,
:,
y
,
:]
*
(
y
/
blend_extent
)
return
b
return
b
def
blend_h
(
self
,
a
,
b
,
blend_extent
):
def
blend_h
(
self
,
a
,
b
,
blend_extent
):
for
x
in
range
(
blend_extent
):
for
x
in
range
(
min
(
a
.
shape
[
3
],
b
.
shape
[
3
],
blend_extent
)
)
:
b
[:,
:,
:,
x
]
=
a
[:,
:,
:,
-
blend_extent
+
x
]
*
(
1
-
x
/
blend_extent
)
+
b
[:,
:,
:,
x
]
*
(
x
/
blend_extent
)
b
[:,
:,
:,
x
]
=
a
[:,
:,
:,
-
blend_extent
+
x
]
*
(
1
-
x
/
blend_extent
)
+
b
[:,
:,
:,
x
]
*
(
x
/
blend_extent
)
return
b
return
b
...
...
tests/pipelines/stable_diffusion/test_stable_diffusion.py
View file @
a7cc468f
...
@@ -445,6 +445,12 @@ class StableDiffusionPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
...
@@ -445,6 +445,12 @@ class StableDiffusionPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
assert
np
.
abs
(
output_2
.
images
.
flatten
()
-
output_1
.
images
.
flatten
()).
max
()
<
5e-1
assert
np
.
abs
(
output_2
.
images
.
flatten
()
-
output_1
.
images
.
flatten
()).
max
()
<
5e-1
# test that tiled decode works with various shapes
shapes
=
[(
1
,
4
,
73
,
97
),
(
1
,
4
,
97
,
73
),
(
1
,
4
,
49
,
65
),
(
1
,
4
,
65
,
49
)]
for
shape
in
shapes
:
zeros
=
torch
.
zeros
(
shape
).
to
(
device
)
sd_pipe
.
vae
.
decode
(
zeros
)
def
test_stable_diffusion_negative_prompt
(
self
):
def
test_stable_diffusion_negative_prompt
(
self
):
device
=
"cpu"
# ensure determinism for the device-dependent torch.Generator
device
=
"cpu"
# ensure determinism for the device-dependent torch.Generator
components
=
self
.
get_dummy_components
()
components
=
self
.
get_dummy_components
()
...
...
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