Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
renzhc
diffusers_dcu
Commits
c803a8f8
Unverified
Commit
c803a8f8
authored
Nov 08, 2023
by
Patrick von Platen
Committed by
GitHub
Nov 08, 2023
Browse files
[LCM] Fix img2img (#5698)
* [LCM] Fix img2img * make fix-copies * make fix-copies * make fix-copies * up
parent
d384265d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
6 deletions
+6
-6
src/diffusers/models/attention_processor.py
src/diffusers/models/attention_processor.py
+1
-1
src/diffusers/pipelines/latent_consistency_models/pipeline_latent_consistency_img2img.py
...consistency_models/pipeline_latent_consistency_img2img.py
+1
-1
tests/pipelines/latent_consistency_models/test_latent_consistency_models_img2img.py
...sistency_models/test_latent_consistency_models_img2img.py
+4
-4
No files found.
src/diffusers/models/attention_processor.py
View file @
c803a8f8
...
@@ -378,7 +378,7 @@ class Attention(nn.Module):
...
@@ -378,7 +378,7 @@ class Attention(nn.Module):
_remove_lora (`bool`, *optional*, defaults to `False`):
_remove_lora (`bool`, *optional*, defaults to `False`):
Set to `True` to remove LoRA layers from the model.
Set to `True` to remove LoRA layers from the model.
"""
"""
if
hasattr
(
self
,
"processor"
)
and
_remove_lora
and
self
.
to_q
.
lora_layer
is
not
None
:
if
not
USE_PEFT_BACKEND
and
hasattr
(
self
,
"processor"
)
and
_remove_lora
and
self
.
to_q
.
lora_layer
is
not
None
:
deprecate
(
deprecate
(
"set_processor to offload LoRA"
,
"set_processor to offload LoRA"
,
"0.26.0"
,
"0.26.0"
,
...
...
src/diffusers/pipelines/latent_consistency_models/pipeline_latent_consistency_img2img.py
View file @
c803a8f8
...
@@ -738,7 +738,7 @@ class LatentConsistencyModelImg2ImgPipeline(
...
@@ -738,7 +738,7 @@ class LatentConsistencyModelImg2ImgPipeline(
if
original_inference_steps
is
not
None
if
original_inference_steps
is
not
None
else
self
.
scheduler
.
config
.
original_inference_steps
else
self
.
scheduler
.
config
.
original_inference_steps
)
)
latent_timestep
=
t
orch
.
tensor
(
int
(
strength
*
original_inference_
steps
))
latent_timestep
=
t
ime
steps
[:
1
]
latents
=
self
.
prepare_latents
(
latents
=
self
.
prepare_latents
(
image
,
latent_timestep
,
batch_size
,
num_images_per_prompt
,
prompt_embeds
.
dtype
,
device
,
generator
image
,
latent_timestep
,
batch_size
,
num_images_per_prompt
,
prompt_embeds
.
dtype
,
device
,
generator
)
)
...
...
tests/pipelines/latent_consistency_models/test_latent_consistency_models_img2img.py
View file @
c803a8f8
...
@@ -133,7 +133,7 @@ class LatentConsistencyModelImg2ImgPipelineFastTests(
...
@@ -133,7 +133,7 @@ class LatentConsistencyModelImg2ImgPipelineFastTests(
assert
image
.
shape
==
(
1
,
32
,
32
,
3
)
assert
image
.
shape
==
(
1
,
32
,
32
,
3
)
image_slice
=
image
[
0
,
-
3
:,
-
3
:,
-
1
]
image_slice
=
image
[
0
,
-
3
:,
-
3
:,
-
1
]
expected_slice
=
np
.
array
([
0.
5865
,
0.2854
,
0.2
828
,
0.7
47
3
,
0.6
006
,
0.
4580
,
0.4397
,
0.6
415
,
0.
6069
])
expected_slice
=
np
.
array
([
0.
4388
,
0.3717
,
0.2
202
,
0.7
21
3
,
0.6
370
,
0.
3664
,
0.5815
,
0.6
080
,
0.
4977
])
assert
np
.
abs
(
image_slice
.
flatten
()
-
expected_slice
).
max
()
<
1e-3
assert
np
.
abs
(
image_slice
.
flatten
()
-
expected_slice
).
max
()
<
1e-3
def
test_lcm_multistep
(
self
):
def
test_lcm_multistep
(
self
):
...
@@ -150,7 +150,7 @@ class LatentConsistencyModelImg2ImgPipelineFastTests(
...
@@ -150,7 +150,7 @@ class LatentConsistencyModelImg2ImgPipelineFastTests(
assert
image
.
shape
==
(
1
,
32
,
32
,
3
)
assert
image
.
shape
==
(
1
,
32
,
32
,
3
)
image_slice
=
image
[
0
,
-
3
:,
-
3
:,
-
1
]
image_slice
=
image
[
0
,
-
3
:,
-
3
:,
-
1
]
expected_slice
=
np
.
array
([
0.4
903
,
0.3
304
,
0.
350
3
,
0.
5
24
1
,
0.
5153
,
0.4585
,
0.3222
,
0.4764
,
0.4
891
])
expected_slice
=
np
.
array
([
0.4
150
,
0.3
719
,
0.2479
,
0.
633
3
,
0.
60
24
,
0.
3778
,
0.5036
,
0.5420
,
0.4
678
])
assert
np
.
abs
(
image_slice
.
flatten
()
-
expected_slice
).
max
()
<
1e-3
assert
np
.
abs
(
image_slice
.
flatten
()
-
expected_slice
).
max
()
<
1e-3
def
test_inference_batch_single_identical
(
self
):
def
test_inference_batch_single_identical
(
self
):
...
@@ -237,7 +237,7 @@ class LatentConsistencyModelImg2ImgPipelineSlowTests(unittest.TestCase):
...
@@ -237,7 +237,7 @@ class LatentConsistencyModelImg2ImgPipelineSlowTests(unittest.TestCase):
assert
image
.
shape
==
(
1
,
512
,
512
,
3
)
assert
image
.
shape
==
(
1
,
512
,
512
,
3
)
image_slice
=
image
[
0
,
-
3
:,
-
3
:,
-
1
].
flatten
()
image_slice
=
image
[
0
,
-
3
:,
-
3
:,
-
1
].
flatten
()
expected_slice
=
np
.
array
([
0.1
025
,
0.
091
1
,
0.
0984
,
0.0981
,
0.0901
,
0.0918
,
0.1
055
,
0.
0940
,
0.
07
30
])
expected_slice
=
np
.
array
([
0.1
950
,
0.
196
1
,
0.
2308
,
0.1786
,
0.1837
,
0.2320
,
0.1
898
,
0.
1885
,
0.
2
30
9
])
assert
np
.
abs
(
image_slice
-
expected_slice
).
max
()
<
1e-3
assert
np
.
abs
(
image_slice
-
expected_slice
).
max
()
<
1e-3
def
test_lcm_multistep
(
self
):
def
test_lcm_multistep
(
self
):
...
@@ -253,5 +253,5 @@ class LatentConsistencyModelImg2ImgPipelineSlowTests(unittest.TestCase):
...
@@ -253,5 +253,5 @@ class LatentConsistencyModelImg2ImgPipelineSlowTests(unittest.TestCase):
assert
image
.
shape
==
(
1
,
512
,
512
,
3
)
assert
image
.
shape
==
(
1
,
512
,
512
,
3
)
image_slice
=
image
[
0
,
-
3
:,
-
3
:,
-
1
].
flatten
()
image_slice
=
image
[
0
,
-
3
:,
-
3
:,
-
1
].
flatten
()
expected_slice
=
np
.
array
([
0.
01855
,
0.01855
,
0.01489
,
0.
01
39
2
,
0.
01782
,
0.01465
,
0.01831
,
0.02539
,
0.0
])
expected_slice
=
np
.
array
([
0.
3756
,
0.3816
,
0.3767
,
0.3718
,
0.
37
39
,
0.
3735
,
0.3863
,
0.3803
,
0.3563
])
assert
np
.
abs
(
image_slice
-
expected_slice
).
max
()
<
1e-3
assert
np
.
abs
(
image_slice
-
expected_slice
).
max
()
<
1e-3
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