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
OpenDAS
diffusers
Commits
eb1abee6
Unverified
Commit
eb1abee6
authored
Dec 07, 2022
by
Anton Lozhkov
Committed by
GitHub
Dec 07, 2022
Browse files
[ONNX] Fix flaky tests (#1593)
* [ONNX] Fix flaky tests * revert
parent
5e036921
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
5 deletions
+24
-5
tests/pipelines/stable_diffusion/test_onnx_stable_diffusion.py
.../pipelines/stable_diffusion/test_onnx_stable_diffusion.py
+10
-1
tests/pipelines/stable_diffusion/test_onnx_stable_diffusion_img2img.py
...es/stable_diffusion/test_onnx_stable_diffusion_img2img.py
+6
-2
tests/pipelines/stable_diffusion/test_onnx_stable_diffusion_inpaint.py
...es/stable_diffusion/test_onnx_stable_diffusion_inpaint.py
+6
-2
tests/pipelines/stable_diffusion/test_onnx_stable_diffusion_inpaint_legacy.py
...le_diffusion/test_onnx_stable_diffusion_inpaint_legacy.py
+2
-0
No files found.
tests/pipelines/stable_diffusion/test_onnx_stable_diffusion.py
View file @
eb1abee6
...
...
@@ -58,6 +58,8 @@ class OnnxStableDiffusionPipelineIntegrationTests(unittest.TestCase):
sd_pipe
=
OnnxStableDiffusionPipeline
.
from_pretrained
(
"CompVis/stable-diffusion-v1-4"
,
revision
=
"onnx"
,
safety_checker
=
None
,
feature_extractor
=
None
,
provider
=
self
.
gpu_provider
,
sess_options
=
self
.
gpu_options
,
)
...
...
@@ -82,6 +84,8 @@ class OnnxStableDiffusionPipelineIntegrationTests(unittest.TestCase):
"runwayml/stable-diffusion-v1-5"
,
revision
=
"onnx"
,
scheduler
=
ddim_scheduler
,
safety_checker
=
None
,
feature_extractor
=
None
,
provider
=
self
.
gpu_provider
,
sess_options
=
self
.
gpu_options
,
)
...
...
@@ -105,6 +109,8 @@ class OnnxStableDiffusionPipelineIntegrationTests(unittest.TestCase):
"runwayml/stable-diffusion-v1-5"
,
revision
=
"onnx"
,
scheduler
=
lms_scheduler
,
safety_checker
=
None
,
feature_extractor
=
None
,
provider
=
self
.
gpu_provider
,
sess_options
=
self
.
gpu_options
,
)
...
...
@@ -147,6 +153,8 @@ class OnnxStableDiffusionPipelineIntegrationTests(unittest.TestCase):
pipe
=
OnnxStableDiffusionPipeline
.
from_pretrained
(
"runwayml/stable-diffusion-v1-5"
,
revision
=
"onnx"
,
safety_checker
=
None
,
feature_extractor
=
None
,
provider
=
self
.
gpu_provider
,
sess_options
=
self
.
gpu_options
,
)
...
...
@@ -170,9 +178,10 @@ class OnnxStableDiffusionPipelineIntegrationTests(unittest.TestCase):
pipe
=
OnnxStableDiffusionPipeline
.
from_pretrained
(
"runwayml/stable-diffusion-v1-5"
,
revision
=
"onnx"
,
safety_checker
=
None
,
feature_extractor
=
None
,
provider
=
self
.
gpu_provider
,
sess_options
=
self
.
gpu_options
,
safety_checker
=
None
,
)
assert
isinstance
(
pipe
,
OnnxStableDiffusionPipeline
)
assert
pipe
.
safety_checker
is
None
...
...
tests/pipelines/stable_diffusion/test_onnx_stable_diffusion_img2img.py
View file @
eb1abee6
...
...
@@ -62,6 +62,8 @@ class OnnxStableDiffusionImg2ImgPipelineIntegrationTests(unittest.TestCase):
pipe
=
OnnxStableDiffusionImg2ImgPipeline
.
from_pretrained
(
"CompVis/stable-diffusion-v1-4"
,
revision
=
"onnx"
,
safety_checker
=
None
,
feature_extractor
=
None
,
provider
=
self
.
gpu_provider
,
sess_options
=
self
.
gpu_options
,
)
...
...
@@ -100,6 +102,8 @@ class OnnxStableDiffusionImg2ImgPipelineIntegrationTests(unittest.TestCase):
"runwayml/stable-diffusion-v1-5"
,
revision
=
"onnx"
,
scheduler
=
lms_scheduler
,
safety_checker
=
None
,
feature_extractor
=
None
,
provider
=
self
.
gpu_provider
,
sess_options
=
self
.
gpu_options
,
)
...
...
@@ -113,7 +117,7 @@ class OnnxStableDiffusionImg2ImgPipelineIntegrationTests(unittest.TestCase):
image
=
init_image
,
strength
=
0.75
,
guidance_scale
=
7.5
,
num_inference_steps
=
1
0
,
num_inference_steps
=
2
0
,
generator
=
generator
,
output_type
=
"np"
,
)
...
...
@@ -121,6 +125,6 @@ class OnnxStableDiffusionImg2ImgPipelineIntegrationTests(unittest.TestCase):
image_slice
=
images
[
0
,
255
:
258
,
383
:
386
,
-
1
]
assert
images
.
shape
==
(
1
,
512
,
768
,
3
)
expected_slice
=
np
.
array
([
0.
7950
,
0.
7
92
3
,
0.
7903
,
0.5516
,
0.5501
,
0.5476
,
0.4965
,
0.
493
3
,
0.
4910
])
expected_slice
=
np
.
array
([
0.
8043
,
0.92
6
,
0.
9581
,
0.8119
,
0.8954
,
0.913
,
0.7209
,
0.
746
3
,
0.
7431
])
# TODO: lower the tolerance after finding the cause of onnxruntime reproducibility issues
assert
np
.
abs
(
image_slice
.
flatten
()
-
expected_slice
).
max
()
<
2e-2
tests/pipelines/stable_diffusion/test_onnx_stable_diffusion_inpaint.py
View file @
eb1abee6
...
...
@@ -64,6 +64,8 @@ class OnnxStableDiffusionInpaintPipelineIntegrationTests(unittest.TestCase):
pipe
=
OnnxStableDiffusionInpaintPipeline
.
from_pretrained
(
"runwayml/stable-diffusion-inpainting"
,
revision
=
"onnx"
,
safety_checker
=
None
,
feature_extractor
=
None
,
provider
=
self
.
gpu_provider
,
sess_options
=
self
.
gpu_options
,
)
...
...
@@ -104,6 +106,8 @@ class OnnxStableDiffusionInpaintPipelineIntegrationTests(unittest.TestCase):
"runwayml/stable-diffusion-inpainting"
,
revision
=
"onnx"
,
scheduler
=
lms_scheduler
,
safety_checker
=
None
,
feature_extractor
=
None
,
provider
=
self
.
gpu_provider
,
sess_options
=
self
.
gpu_options
,
)
...
...
@@ -117,7 +121,7 @@ class OnnxStableDiffusionInpaintPipelineIntegrationTests(unittest.TestCase):
image
=
init_image
,
mask_image
=
mask_image
,
guidance_scale
=
7.5
,
num_inference_steps
=
1
0
,
num_inference_steps
=
2
0
,
generator
=
generator
,
output_type
=
"np"
,
)
...
...
@@ -125,5 +129,5 @@ class OnnxStableDiffusionInpaintPipelineIntegrationTests(unittest.TestCase):
image_slice
=
images
[
0
,
255
:
258
,
255
:
258
,
-
1
]
assert
images
.
shape
==
(
1
,
512
,
512
,
3
)
expected_slice
=
np
.
array
([
0.
2520
,
0.2743
,
0.
264
3
,
0.
2641
,
0.
251
7
,
0.
2650
,
0.2498
,
0.2688
,
0.2529
])
expected_slice
=
np
.
array
([
0.
0086
,
0.0077
,
0.
008
3
,
0.
0093
,
0.
010
7
,
0.
0139
,
0.0094
,
0.0097
,
0.0125
])
assert
np
.
abs
(
image_slice
.
flatten
()
-
expected_slice
).
max
()
<
1e-3
tests/pipelines/stable_diffusion/test_onnx_stable_diffusion_inpaint_legacy.py
View file @
eb1abee6
...
...
@@ -70,6 +70,8 @@ class StableDiffusionOnnxInpaintLegacyPipelineIntegrationTests(unittest.TestCase
pipe
=
OnnxStableDiffusionInpaintPipelineLegacy
.
from_pretrained
(
"CompVis/stable-diffusion-v1-4"
,
revision
=
"onnx"
,
safety_checker
=
None
,
feature_extractor
=
None
,
provider
=
self
.
gpu_provider
,
sess_options
=
self
.
gpu_options
,
)
...
...
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