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
150142c5
Unverified
Commit
150142c5
authored
Jun 28, 2024
by
Dhruv Nair
Committed by
GitHub
Jun 28, 2024
Browse files
[Tests] Fix precision related issues in slow pipeline tests (#8720)
update
parent
35f45ecd
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
21 additions
and
13 deletions
+21
-13
tests/pipelines/ip_adapters/test_ip_adapter_stable_diffusion.py
...pipelines/ip_adapters/test_ip_adapter_stable_diffusion.py
+4
-9
tests/pipelines/kandinsky/test_kandinsky_combined.py
tests/pipelines/kandinsky/test_kandinsky_combined.py
+1
-0
tests/pipelines/latent_consistency_models/test_latent_consistency_models_img2img.py
...sistency_models/test_latent_consistency_models_img2img.py
+2
-2
tests/pipelines/stable_diffusion_2/test_stable_diffusion_attend_and_excite.py
...le_diffusion_2/test_stable_diffusion_attend_and_excite.py
+3
-0
tests/pipelines/stable_diffusion_adapter/test_stable_diffusion_adapter.py
...stable_diffusion_adapter/test_stable_diffusion_adapter.py
+3
-0
tests/pipelines/stable_diffusion_xl/test_stable_diffusion_xl.py
...pipelines/stable_diffusion_xl/test_stable_diffusion_xl.py
+3
-2
tests/pipelines/test_pipelines_common.py
tests/pipelines/test_pipelines_common.py
+5
-0
No files found.
tests/pipelines/ip_adapters/test_ip_adapter_stable_diffusion.py
View file @
150142c5
...
...
@@ -364,9 +364,7 @@ class IPAdapterSDIntegrationTests(IPAdapterNightlyTestsMixin):
images
=
pipeline
(
**
inputs
).
images
image_slice
=
images
[
0
,
:
3
,
:
3
,
-
1
].
flatten
()
expected_slice
=
np
.
array
(
[
0.32714844
,
0.3239746
,
0.3466797
,
0.31835938
,
0.30004883
,
0.3251953
,
0.3215332
,
0.3552246
,
0.3251953
]
)
expected_slice
=
np
.
array
([
0.3237
,
0.3186
,
0.3406
,
0.3154
,
0.2942
,
0.3220
,
0.3188
,
0.3528
,
0.3242
])
max_diff
=
numpy_cosine_similarity_distance
(
image_slice
,
expected_slice
)
assert
max_diff
<
5e-4
...
...
@@ -427,9 +425,7 @@ class IPAdapterSDXLIntegrationTests(IPAdapterNightlyTestsMixin):
images
=
pipeline
(
**
inputs
).
images
image_slice
=
images
[
0
,
:
3
,
:
3
,
-
1
].
flatten
()
expected_slice
=
np
.
array
(
[
0.0576596
,
0.05600825
,
0.04479006
,
0.05288461
,
0.05461192
,
0.05137569
,
0.04867965
,
0.05301541
,
0.04939842
]
)
expected_slice
=
np
.
array
([
0.0596
,
0.0539
,
0.0459
,
0.0580
,
0.0560
,
0.0548
,
0.0501
,
0.0563
,
0.0500
])
max_diff
=
numpy_cosine_similarity_distance
(
image_slice
,
expected_slice
)
assert
max_diff
<
5e-4
...
...
@@ -644,9 +640,8 @@ class IPAdapterSDXLIntegrationTests(IPAdapterNightlyTestsMixin):
inputs
[
"cross_attention_kwargs"
][
"ip_adapter_masks"
]
=
[
masks1
,
masks2
]
images
=
pipeline
(
**
inputs
).
images
image_slice
=
images
[
0
,
:
3
,
:
3
,
-
1
].
flatten
()
expected_slice
=
np
.
array
(
[
0.23551631
,
0.20476806
,
0.14099443
,
0.0
,
0.07675594
,
0.05672678
,
0.0
,
0.0
,
0.02099729
]
)
expected_slice
=
np
.
array
([
0.2323
,
0.1026
,
0.1338
,
0.0638
,
0.0662
,
0.0000
,
0.0000
,
0.0000
,
0.0199
])
max_diff
=
numpy_cosine_similarity_distance
(
image_slice
,
expected_slice
)
assert
max_diff
<
5e-4
...
...
tests/pipelines/kandinsky/test_kandinsky_combined.py
View file @
150142c5
...
...
@@ -348,6 +348,7 @@ class KandinskyPipelineInpaintCombinedFastTests(PipelineTesterMixin, unittest.Te
def
test_inference_batch_single_identical
(
self
):
super
().
test_inference_batch_single_identical
(
expected_max_diff
=
1e-2
)
@
unittest
.
skip
(
"Difference between FP16 and FP32 too large on CI"
)
def
test_float16_inference
(
self
):
super
().
test_float16_inference
(
expected_max_diff
=
5e-1
)
...
...
tests/pipelines/latent_consistency_models/test_latent_consistency_models_img2img.py
View file @
150142c5
...
...
@@ -263,7 +263,7 @@ class LatentConsistencyModelImg2ImgPipelineSlowTests(unittest.TestCase):
assert
image
.
shape
==
(
1
,
512
,
512
,
3
)
image_slice
=
image
[
0
,
-
3
:,
-
3
:,
-
1
].
flatten
()
expected_slice
=
np
.
array
([
0.
1950
,
0.1961
,
0.2308
,
0.1786
,
0.1837
,
0.2320
,
0.1898
,
0.1885
,
0.2309
])
expected_slice
=
np
.
array
([
0.
3479
,
0.3314
,
0.3555
,
0.3430
,
0.3649
,
0.3423
,
0.3239
,
0.3117
,
0.3240
])
assert
np
.
abs
(
image_slice
-
expected_slice
).
max
()
<
1e-3
def
test_lcm_multistep
(
self
):
...
...
@@ -279,5 +279,5 @@ class LatentConsistencyModelImg2ImgPipelineSlowTests(unittest.TestCase):
assert
image
.
shape
==
(
1
,
512
,
512
,
3
)
image_slice
=
image
[
0
,
-
3
:,
-
3
:,
-
1
].
flatten
()
expected_slice
=
np
.
array
([
0.
3756
,
0.3816
,
0.3767
,
0.3718
,
0.3739
,
0.3735
,
0.3863
,
0.3803
,
0.3563
])
expected_slice
=
np
.
array
([
0.
1442
,
0.1201
,
0.1598
,
0.1281
,
0.1412
,
0.1502
,
0.1455
,
0.1544
,
0.1231
])
assert
np
.
abs
(
image_slice
-
expected_slice
).
max
()
<
1e-3
tests/pipelines/stable_diffusion_2/test_stable_diffusion_attend_and_excite.py
View file @
150142c5
...
...
@@ -201,6 +201,9 @@ class StableDiffusionAttendAndExcitePipelineFastTests(
def
test_karras_schedulers_shape
(
self
):
super
().
test_karras_schedulers_shape
(
num_inference_steps_for_strength_for_iterations
=
3
)
def
test_from_pipe_consistent_forward_pass_cpu_offload
(
self
):
super
().
test_from_pipe_consistent_forward_pass_cpu_offload
(
expected_max_diff
=
5e-3
)
@
require_torch_gpu
@
nightly
...
...
tests/pipelines/stable_diffusion_adapter/test_stable_diffusion_adapter.py
View file @
150142c5
...
...
@@ -361,6 +361,9 @@ class StableDiffusionFullAdapterPipelineFastTests(
expected_slice
=
np
.
array
([
0.4858
,
0.5500
,
0.4278
,
0.4669
,
0.6184
,
0.4322
,
0.5010
,
0.5033
,
0.4746
])
assert
np
.
abs
(
image_slice
.
flatten
()
-
expected_slice
).
max
()
<
5e-3
def
test_from_pipe_consistent_forward_pass_cpu_offload
(
self
):
super
().
test_from_pipe_consistent_forward_pass_cpu_offload
(
expected_max_diff
=
6e-3
)
class
StableDiffusionLightAdapterPipelineFastTests
(
AdapterTests
,
PipelineTesterMixin
,
unittest
.
TestCase
):
def
get_dummy_components
(
self
,
time_cond_proj_dim
=
None
):
...
...
tests/pipelines/stable_diffusion_xl/test_stable_diffusion_xl.py
View file @
150142c5
...
...
@@ -1072,8 +1072,9 @@ class StableDiffusionXLPipelineIntegrationTests(unittest.TestCase):
prompt
=
"a red car standing on the side of the street"
image
=
sd_pipe
(
prompt
,
num_inference_steps
=
4
,
guidance_scale
=
8.0
).
images
[
0
]
image
=
sd_pipe
(
prompt
,
num_inference_steps
=
4
,
guidance_scale
=
8.0
,
generator
=
torch
.
Generator
(
"cpu"
).
manual_seed
(
0
)
).
images
[
0
]
expected_image
=
load_image
(
"https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/lcm_full/stable_diffusion_ssd_1b_lcm.png"
)
...
...
tests/pipelines/test_pipelines_common.py
View file @
150142c5
...
...
@@ -786,7 +786,12 @@ class PipelineFromPipeTesterMixin:
if
hasattr
(
component
,
"set_default_attn_processor"
):
component
.
set_default_attn_processor
()
pipe_original
.
set_progress_bar_config
(
disable
=
None
)
pipe_from_original
=
self
.
pipeline_class
.
from_pipe
(
pipe_original
,
**
current_pipe_additional_components
)
for
component
in
pipe_from_original
.
components
.
values
():
if
hasattr
(
component
,
"set_default_attn_processor"
):
component
.
set_default_attn_processor
()
pipe_from_original
.
enable_model_cpu_offload
()
pipe_from_original
.
set_progress_bar_config
(
disable
=
None
)
inputs
=
self
.
get_dummy_inputs_pipe
(
torch_device
)
...
...
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