mirror of
https://github.com/huggingface/diffusers.git
synced 2025-12-11 06:54:32 +08:00
Compare commits
1 Commits
group-offl
...
kandinsky-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f319e27318 |
@@ -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"
|
||||||
|
|||||||
@@ -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):
|
|||||||
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="cuda").manual_seed(0)
|
generator = torch.Generator(device="cpu").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):
|
|||||||
negative_prompt="",
|
negative_prompt="",
|
||||||
).to_tuple()
|
).to_tuple()
|
||||||
|
|
||||||
generator = torch.Generator(device="cuda").manual_seed(0)
|
generator = torch.Generator(device="cpu").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):
|
|||||||
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
|
||||||
|
|||||||
@@ -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):
|
|||||||
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="cuda").manual_seed(0)
|
generator = torch.Generator(device="cpu").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):
|
|||||||
negative_prompt="",
|
negative_prompt="",
|
||||||
).to_tuple()
|
).to_tuple()
|
||||||
|
|
||||||
generator = torch.Generator(device="cuda").manual_seed(0)
|
generator = torch.Generator(device="cpu").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):
|
|||||||
|
|
||||||
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
|
||||||
|
|||||||
@@ -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):
|
|||||||
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):
|
|||||||
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):
|
|||||||
|
|
||||||
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
|
||||||
|
|||||||
@@ -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):
|
|||||||
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):
|
|||||||
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):
|
|||||||
|
|
||||||
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
|
||||||
|
|||||||
@@ -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):
|
|||||||
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):
|
|||||||
|
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user