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
OpenDAS
diffusers
Commits
a9dd8602
Unverified
Commit
a9dd8602
authored
Apr 22, 2024
by
Dhruv Nair
Committed by
GitHub
Apr 22, 2024
Browse files
Fix Kandinksy V22 tests (#7699)
update
parent
91006524
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
22 deletions
+32
-22
tests/pipelines/kandinsky/test_kandinsky.py
tests/pipelines/kandinsky/test_kandinsky.py
+1
-1
tests/pipelines/kandinsky2_2/test_kandinsky.py
tests/pipelines/kandinsky2_2/test_kandinsky.py
+7
-7
tests/pipelines/kandinsky2_2/test_kandinsky_controlnet.py
tests/pipelines/kandinsky2_2/test_kandinsky_controlnet.py
+7
-5
tests/pipelines/kandinsky2_2/test_kandinsky_controlnet_img2img.py
...pelines/kandinsky2_2/test_kandinsky_controlnet_img2img.py
+6
-3
tests/pipelines/kandinsky2_2/test_kandinsky_img2img.py
tests/pipelines/kandinsky2_2/test_kandinsky_img2img.py
+6
-4
tests/pipelines/kandinsky2_2/test_kandinsky_inpaint.py
tests/pipelines/kandinsky2_2/test_kandinsky_inpaint.py
+5
-2
No files found.
tests/pipelines/kandinsky/test_kandinsky.py
View file @
a9dd8602
...
@@ -299,7 +299,7 @@ class KandinskyPipelineIntegrationTests(unittest.TestCase):
...
@@ -299,7 +299,7 @@ class KandinskyPipelineIntegrationTests(unittest.TestCase):
pipe_prior
.
to
(
torch_device
)
pipe_prior
.
to
(
torch_device
)
pipeline
=
KandinskyPipeline
.
from_pretrained
(
"kandinsky-community/kandinsky-2-1"
,
torch_dtype
=
torch
.
float16
)
pipeline
=
KandinskyPipeline
.
from_pretrained
(
"kandinsky-community/kandinsky-2-1"
,
torch_dtype
=
torch
.
float16
)
pipeline
=
pipeline
.
to
(
torch_device
)
pipeline
.
to
(
torch_device
)
pipeline
.
set_progress_bar_config
(
disable
=
None
)
pipeline
.
set_progress_bar_config
(
disable
=
None
)
prompt
=
"red cat, 4k photo"
prompt
=
"red cat, 4k photo"
...
...
tests/pipelines/kandinsky2_2/test_kandinsky.py
View file @
a9dd8602
...
@@ -25,11 +25,12 @@ from diffusers.utils.testing_utils import (
...
@@ -25,11 +25,12 @@ from diffusers.utils.testing_utils import (
enable_full_determinism
,
enable_full_determinism
,
floats_tensor
,
floats_tensor
,
load_numpy
,
load_numpy
,
numpy_cosine_similarity_distance
,
require_torch_gpu
,
require_torch_gpu
,
slow
,
slow
,
)
)
from
..test_pipelines_common
import
PipelineTesterMixin
,
assert_mean_pixel_difference
from
..test_pipelines_common
import
PipelineTesterMixin
enable_full_determinism
()
enable_full_determinism
()
...
@@ -248,12 +249,12 @@ class KandinskyV22PipelineIntegrationTests(unittest.TestCase):
...
@@ -248,12 +249,12 @@ class KandinskyV22PipelineIntegrationTests(unittest.TestCase):
pipeline
=
KandinskyV22Pipeline
.
from_pretrained
(
pipeline
=
KandinskyV22Pipeline
.
from_pretrained
(
"kandinsky-community/kandinsky-2-2-decoder"
,
torch_dtype
=
torch
.
float16
"kandinsky-community/kandinsky-2-2-decoder"
,
torch_dtype
=
torch
.
float16
)
)
pipeline
=
pipeline
.
enable_model_cpu_offload
()
pipeline
.
enable_model_cpu_offload
()
pipeline
.
set_progress_bar_config
(
disable
=
None
)
pipeline
.
set_progress_bar_config
(
disable
=
None
)
prompt
=
"red cat, 4k photo"
prompt
=
"red cat, 4k photo"
generator
=
torch
.
Generator
(
device
=
"cu
da
"
).
manual_seed
(
0
)
generator
=
torch
.
Generator
(
device
=
"c
p
u"
).
manual_seed
(
0
)
image_emb
,
zero_image_emb
=
pipe_prior
(
image_emb
,
zero_image_emb
=
pipe_prior
(
prompt
,
prompt
,
generator
=
generator
,
generator
=
generator
,
...
@@ -261,7 +262,7 @@ class KandinskyV22PipelineIntegrationTests(unittest.TestCase):
...
@@ -261,7 +262,7 @@ class KandinskyV22PipelineIntegrationTests(unittest.TestCase):
negative_prompt
=
""
,
negative_prompt
=
""
,
).
to_tuple
()
).
to_tuple
()
generator
=
torch
.
Generator
(
device
=
"cu
da
"
).
manual_seed
(
0
)
generator
=
torch
.
Generator
(
device
=
"c
p
u"
).
manual_seed
(
0
)
output
=
pipeline
(
output
=
pipeline
(
image_embeds
=
image_emb
,
image_embeds
=
image_emb
,
negative_image_embeds
=
zero_image_emb
,
negative_image_embeds
=
zero_image_emb
,
...
@@ -269,9 +270,8 @@ class KandinskyV22PipelineIntegrationTests(unittest.TestCase):
...
@@ -269,9 +270,8 @@ class KandinskyV22PipelineIntegrationTests(unittest.TestCase):
num_inference_steps
=
3
,
num_inference_steps
=
3
,
output_type
=
"np"
,
output_type
=
"np"
,
)
)
image
=
output
.
images
[
0
]
image
=
output
.
images
[
0
]
assert
image
.
shape
==
(
512
,
512
,
3
)
assert
image
.
shape
==
(
512
,
512
,
3
)
assert_mean_pixel_difference
(
image
,
expected_image
)
max_diff
=
numpy_cosine_similarity_distance
(
expected_image
.
flatten
(),
image
.
flatten
())
assert
max_diff
<
1e-4
tests/pipelines/kandinsky2_2/test_kandinsky_controlnet.py
View file @
a9dd8602
...
@@ -33,10 +33,11 @@ from diffusers.utils.testing_utils import (
...
@@ -33,10 +33,11 @@ from diffusers.utils.testing_utils import (
load_image
,
load_image
,
load_numpy
,
load_numpy
,
nightly
,
nightly
,
numpy_cosine_similarity_distance
,
require_torch_gpu
,
require_torch_gpu
,
)
)
from
..test_pipelines_common
import
PipelineTesterMixin
,
assert_mean_pixel_difference
from
..test_pipelines_common
import
PipelineTesterMixin
enable_full_determinism
()
enable_full_determinism
()
...
@@ -260,12 +261,12 @@ class KandinskyV22ControlnetPipelineIntegrationTests(unittest.TestCase):
...
@@ -260,12 +261,12 @@ class KandinskyV22ControlnetPipelineIntegrationTests(unittest.TestCase):
pipeline
=
KandinskyV22ControlnetPipeline
.
from_pretrained
(
pipeline
=
KandinskyV22ControlnetPipeline
.
from_pretrained
(
"kandinsky-community/kandinsky-2-2-controlnet-depth"
,
torch_dtype
=
torch
.
float16
"kandinsky-community/kandinsky-2-2-controlnet-depth"
,
torch_dtype
=
torch
.
float16
)
)
pipeline
=
pipeline
.
enable_model_cpu_offload
()
pipeline
.
enable_model_cpu_offload
()
pipeline
.
set_progress_bar_config
(
disable
=
None
)
pipeline
.
set_progress_bar_config
(
disable
=
None
)
prompt
=
"A robot, 4k photo"
prompt
=
"A robot, 4k photo"
generator
=
torch
.
Generator
(
device
=
"cu
da
"
).
manual_seed
(
0
)
generator
=
torch
.
Generator
(
device
=
"c
p
u"
).
manual_seed
(
0
)
image_emb
,
zero_image_emb
=
pipe_prior
(
image_emb
,
zero_image_emb
=
pipe_prior
(
prompt
,
prompt
,
generator
=
generator
,
generator
=
generator
,
...
@@ -273,7 +274,7 @@ class KandinskyV22ControlnetPipelineIntegrationTests(unittest.TestCase):
...
@@ -273,7 +274,7 @@ class KandinskyV22ControlnetPipelineIntegrationTests(unittest.TestCase):
negative_prompt
=
""
,
negative_prompt
=
""
,
).
to_tuple
()
).
to_tuple
()
generator
=
torch
.
Generator
(
device
=
"cu
da
"
).
manual_seed
(
0
)
generator
=
torch
.
Generator
(
device
=
"c
p
u"
).
manual_seed
(
0
)
output
=
pipeline
(
output
=
pipeline
(
image_embeds
=
image_emb
,
image_embeds
=
image_emb
,
negative_image_embeds
=
zero_image_emb
,
negative_image_embeds
=
zero_image_emb
,
...
@@ -287,4 +288,5 @@ class KandinskyV22ControlnetPipelineIntegrationTests(unittest.TestCase):
...
@@ -287,4 +288,5 @@ class KandinskyV22ControlnetPipelineIntegrationTests(unittest.TestCase):
assert
image
.
shape
==
(
512
,
512
,
3
)
assert
image
.
shape
==
(
512
,
512
,
3
)
assert_mean_pixel_difference
(
image
,
expected_image
)
max_diff
=
numpy_cosine_similarity_distance
(
expected_image
.
flatten
(),
image
.
flatten
())
assert
max_diff
<
1e-4
tests/pipelines/kandinsky2_2/test_kandinsky_controlnet_img2img.py
View file @
a9dd8602
...
@@ -34,10 +34,11 @@ from diffusers.utils.testing_utils import (
...
@@ -34,10 +34,11 @@ from diffusers.utils.testing_utils import (
load_image
,
load_image
,
load_numpy
,
load_numpy
,
nightly
,
nightly
,
numpy_cosine_similarity_distance
,
require_torch_gpu
,
require_torch_gpu
,
)
)
from
..test_pipelines_common
import
PipelineTesterMixin
,
assert_mean_pixel_difference
from
..test_pipelines_common
import
PipelineTesterMixin
enable_full_determinism
()
enable_full_determinism
()
...
@@ -274,7 +275,7 @@ class KandinskyV22ControlnetImg2ImgPipelineIntegrationTests(unittest.TestCase):
...
@@ -274,7 +275,7 @@ class KandinskyV22ControlnetImg2ImgPipelineIntegrationTests(unittest.TestCase):
pipeline
=
KandinskyV22ControlnetImg2ImgPipeline
.
from_pretrained
(
pipeline
=
KandinskyV22ControlnetImg2ImgPipeline
.
from_pretrained
(
"kandinsky-community/kandinsky-2-2-controlnet-depth"
,
torch_dtype
=
torch
.
float16
"kandinsky-community/kandinsky-2-2-controlnet-depth"
,
torch_dtype
=
torch
.
float16
)
)
pipeline
=
pipeline
.
enable_model_cpu_offload
()
pipeline
.
enable_model_cpu_offload
()
pipeline
.
set_progress_bar_config
(
disable
=
None
)
pipeline
.
set_progress_bar_config
(
disable
=
None
)
...
@@ -289,6 +290,7 @@ class KandinskyV22ControlnetImg2ImgPipelineIntegrationTests(unittest.TestCase):
...
@@ -289,6 +290,7 @@ class KandinskyV22ControlnetImg2ImgPipelineIntegrationTests(unittest.TestCase):
num_inference_steps
=
5
,
num_inference_steps
=
5
,
).
to_tuple
()
).
to_tuple
()
generator
=
torch
.
Generator
(
device
=
"cpu"
).
manual_seed
(
0
)
output
=
pipeline
(
output
=
pipeline
(
image
=
init_image
,
image
=
init_image
,
image_embeds
=
image_emb
,
image_embeds
=
image_emb
,
...
@@ -306,4 +308,5 @@ class KandinskyV22ControlnetImg2ImgPipelineIntegrationTests(unittest.TestCase):
...
@@ -306,4 +308,5 @@ class KandinskyV22ControlnetImg2ImgPipelineIntegrationTests(unittest.TestCase):
assert
image
.
shape
==
(
512
,
512
,
3
)
assert
image
.
shape
==
(
512
,
512
,
3
)
assert_mean_pixel_difference
(
image
,
expected_image
)
max_diff
=
numpy_cosine_similarity_distance
(
expected_image
.
flatten
(),
image
.
flatten
())
assert
max_diff
<
1e-4
tests/pipelines/kandinsky2_2/test_kandinsky_img2img.py
View file @
a9dd8602
...
@@ -33,11 +33,12 @@ from diffusers.utils.testing_utils import (
...
@@ -33,11 +33,12 @@ from diffusers.utils.testing_utils import (
floats_tensor
,
floats_tensor
,
load_image
,
load_image
,
load_numpy
,
load_numpy
,
numpy_cosine_similarity_distance
,
require_torch_gpu
,
require_torch_gpu
,
slow
,
slow
,
)
)
from
..test_pipelines_common
import
PipelineTesterMixin
,
assert_mean_pixel_difference
from
..test_pipelines_common
import
PipelineTesterMixin
enable_full_determinism
()
enable_full_determinism
()
...
@@ -270,8 +271,7 @@ class KandinskyV22Img2ImgPipelineIntegrationTests(unittest.TestCase):
...
@@ -270,8 +271,7 @@ class KandinskyV22Img2ImgPipelineIntegrationTests(unittest.TestCase):
pipeline
=
KandinskyV22Img2ImgPipeline
.
from_pretrained
(
pipeline
=
KandinskyV22Img2ImgPipeline
.
from_pretrained
(
"kandinsky-community/kandinsky-2-2-decoder"
,
torch_dtype
=
torch
.
float16
"kandinsky-community/kandinsky-2-2-decoder"
,
torch_dtype
=
torch
.
float16
)
)
pipeline
=
pipeline
.
enable_model_cpu_offload
()
pipeline
.
enable_model_cpu_offload
()
pipeline
.
set_progress_bar_config
(
disable
=
None
)
pipeline
.
set_progress_bar_config
(
disable
=
None
)
generator
=
torch
.
Generator
(
device
=
"cpu"
).
manual_seed
(
0
)
generator
=
torch
.
Generator
(
device
=
"cpu"
).
manual_seed
(
0
)
...
@@ -282,6 +282,7 @@ class KandinskyV22Img2ImgPipelineIntegrationTests(unittest.TestCase):
...
@@ -282,6 +282,7 @@ class KandinskyV22Img2ImgPipelineIntegrationTests(unittest.TestCase):
negative_prompt
=
""
,
negative_prompt
=
""
,
).
to_tuple
()
).
to_tuple
()
generator
=
torch
.
Generator
(
device
=
"cpu"
).
manual_seed
(
0
)
output
=
pipeline
(
output
=
pipeline
(
image
=
init_image
,
image
=
init_image
,
image_embeds
=
image_emb
,
image_embeds
=
image_emb
,
...
@@ -298,4 +299,5 @@ class KandinskyV22Img2ImgPipelineIntegrationTests(unittest.TestCase):
...
@@ -298,4 +299,5 @@ class KandinskyV22Img2ImgPipelineIntegrationTests(unittest.TestCase):
assert
image
.
shape
==
(
768
,
768
,
3
)
assert
image
.
shape
==
(
768
,
768
,
3
)
assert_mean_pixel_difference
(
image
,
expected_image
)
max_diff
=
numpy_cosine_similarity_distance
(
expected_image
.
flatten
(),
image
.
flatten
())
assert
max_diff
<
1e-4
tests/pipelines/kandinsky2_2/test_kandinsky_inpaint.py
View file @
a9dd8602
...
@@ -34,12 +34,13 @@ from diffusers.utils.testing_utils import (
...
@@ -34,12 +34,13 @@ from diffusers.utils.testing_utils import (
is_flaky
,
is_flaky
,
load_image
,
load_image
,
load_numpy
,
load_numpy
,
numpy_cosine_similarity_distance
,
require_torch_gpu
,
require_torch_gpu
,
slow
,
slow
,
torch_device
,
torch_device
,
)
)
from
..test_pipelines_common
import
PipelineTesterMixin
,
assert_mean_pixel_difference
from
..test_pipelines_common
import
PipelineTesterMixin
enable_full_determinism
()
enable_full_determinism
()
...
@@ -338,6 +339,7 @@ class KandinskyV22InpaintPipelineIntegrationTests(unittest.TestCase):
...
@@ -338,6 +339,7 @@ class KandinskyV22InpaintPipelineIntegrationTests(unittest.TestCase):
negative_prompt
=
""
,
negative_prompt
=
""
,
).
to_tuple
()
).
to_tuple
()
generator
=
torch
.
Generator
(
device
=
"cpu"
).
manual_seed
(
0
)
output
=
pipeline
(
output
=
pipeline
(
image
=
init_image
,
image
=
init_image
,
mask_image
=
mask
,
mask_image
=
mask
,
...
@@ -354,4 +356,5 @@ class KandinskyV22InpaintPipelineIntegrationTests(unittest.TestCase):
...
@@ -354,4 +356,5 @@ class KandinskyV22InpaintPipelineIntegrationTests(unittest.TestCase):
assert
image
.
shape
==
(
768
,
768
,
3
)
assert
image
.
shape
==
(
768
,
768
,
3
)
assert_mean_pixel_difference
(
image
,
expected_image
)
max_diff
=
numpy_cosine_similarity_distance
(
expected_image
.
flatten
(),
image
.
flatten
())
assert
max_diff
<
1e-4
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