Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e8d40b3d5d | |||
| d699d686c0 |
@@ -35,7 +35,6 @@ from diffusers.models.attention_processor import AttnProcessor, AttnProcessor2_0
|
|||||||
from diffusers.utils import load_image
|
from diffusers.utils import load_image
|
||||||
from diffusers.utils.testing_utils import (
|
from diffusers.utils.testing_utils import (
|
||||||
enable_full_determinism,
|
enable_full_determinism,
|
||||||
is_flaky,
|
|
||||||
numpy_cosine_similarity_distance,
|
numpy_cosine_similarity_distance,
|
||||||
require_torch_gpu,
|
require_torch_gpu,
|
||||||
slow,
|
slow,
|
||||||
@@ -260,7 +259,6 @@ class IPAdapterSDIntegrationTests(IPAdapterNightlyTestsMixin):
|
|||||||
]
|
]
|
||||||
assert processors == [True] * len(processors)
|
assert processors == [True] * len(processors)
|
||||||
|
|
||||||
@is_flaky
|
|
||||||
def test_multi(self):
|
def test_multi(self):
|
||||||
image_encoder = self.get_image_encoder(repo_id="h94/IP-Adapter", subfolder="models/image_encoder")
|
image_encoder = self.get_image_encoder(repo_id="h94/IP-Adapter", subfolder="models/image_encoder")
|
||||||
pipeline = StableDiffusionPipeline.from_pretrained(
|
pipeline = StableDiffusionPipeline.from_pretrained(
|
||||||
@@ -277,7 +275,7 @@ class IPAdapterSDIntegrationTests(IPAdapterNightlyTestsMixin):
|
|||||||
inputs["ip_adapter_image"] = [ip_adapter_image, [ip_adapter_image] * 2]
|
inputs["ip_adapter_image"] = [ip_adapter_image, [ip_adapter_image] * 2]
|
||||||
images = pipeline(**inputs).images
|
images = pipeline(**inputs).images
|
||||||
image_slice = images[0, :3, :3, -1].flatten()
|
image_slice = images[0, :3, :3, -1].flatten()
|
||||||
expected_slice = np.array([0.5234, 0.5352, 0.5625, 0.5713, 0.5947, 0.6206, 0.5786, 0.6187, 0.6494])
|
expected_slice = np.array([0.1704, 0.1296, 0.1272, 0.2212, 0.1514, 0.1479, 0.4172, 0.4263, 0.4360])
|
||||||
|
|
||||||
max_diff = numpy_cosine_similarity_distance(image_slice, expected_slice)
|
max_diff = numpy_cosine_similarity_distance(image_slice, expected_slice)
|
||||||
assert max_diff < 5e-4
|
assert max_diff < 5e-4
|
||||||
|
|||||||
@@ -27,7 +27,13 @@ from diffusers import (
|
|||||||
PixArtAlphaPipeline,
|
PixArtAlphaPipeline,
|
||||||
Transformer2DModel,
|
Transformer2DModel,
|
||||||
)
|
)
|
||||||
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device
|
from diffusers.utils.testing_utils import (
|
||||||
|
enable_full_determinism,
|
||||||
|
numpy_cosine_similarity_distance,
|
||||||
|
require_torch_gpu,
|
||||||
|
slow,
|
||||||
|
torch_device,
|
||||||
|
)
|
||||||
|
|
||||||
from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_IMAGE_PARAMS, TEXT_TO_IMAGE_PARAMS
|
from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_IMAGE_PARAMS, TEXT_TO_IMAGE_PARAMS
|
||||||
from ..test_pipelines_common import PipelineTesterMixin, to_np
|
from ..test_pipelines_common import PipelineTesterMixin, to_np
|
||||||
@@ -332,37 +338,35 @@ class PixArtAlphaPipelineIntegrationTests(unittest.TestCase):
|
|||||||
torch.cuda.empty_cache()
|
torch.cuda.empty_cache()
|
||||||
|
|
||||||
def test_pixart_1024(self):
|
def test_pixart_1024(self):
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.Generator("cpu").manual_seed(0)
|
||||||
|
|
||||||
pipe = PixArtAlphaPipeline.from_pretrained(self.ckpt_id_1024, torch_dtype=torch.float16)
|
pipe = PixArtAlphaPipeline.from_pretrained(self.ckpt_id_1024, torch_dtype=torch.float16)
|
||||||
pipe.enable_model_cpu_offload()
|
pipe.enable_model_cpu_offload()
|
||||||
prompt = self.prompt
|
prompt = self.prompt
|
||||||
|
|
||||||
image = pipe(prompt, generator=generator, output_type="np").images
|
image = pipe(prompt, generator=generator, num_inference_steps=2, output_type="np").images
|
||||||
|
|
||||||
image_slice = image[0, -3:, -3:, -1]
|
image_slice = image[0, -3:, -3:, -1]
|
||||||
|
expected_slice = np.array([0.0742, 0.0835, 0.2114, 0.0295, 0.0784, 0.2361, 0.1738, 0.2251, 0.3589])
|
||||||
|
|
||||||
expected_slice = np.array([0.1941, 0.2117, 0.2188, 0.1946, 0.218, 0.2124, 0.199, 0.2437, 0.2583])
|
max_diff = numpy_cosine_similarity_distance(image_slice.flatten(), expected_slice)
|
||||||
|
self.assertLessEqual(max_diff, 1e-4)
|
||||||
max_diff = np.abs(image_slice.flatten() - expected_slice).max()
|
|
||||||
self.assertLessEqual(max_diff, 1e-3)
|
|
||||||
|
|
||||||
def test_pixart_512(self):
|
def test_pixart_512(self):
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.Generator("cpu").manual_seed(0)
|
||||||
|
|
||||||
pipe = PixArtAlphaPipeline.from_pretrained(self.ckpt_id_512, torch_dtype=torch.float16)
|
pipe = PixArtAlphaPipeline.from_pretrained(self.ckpt_id_512, torch_dtype=torch.float16)
|
||||||
pipe.enable_model_cpu_offload()
|
pipe.enable_model_cpu_offload()
|
||||||
|
|
||||||
prompt = self.prompt
|
prompt = self.prompt
|
||||||
|
|
||||||
image = pipe(prompt, generator=generator, output_type="np").images
|
image = pipe(prompt, generator=generator, num_inference_steps=2, output_type="np").images
|
||||||
|
|
||||||
image_slice = image[0, -3:, -3:, -1]
|
image_slice = image[0, -3:, -3:, -1]
|
||||||
|
expected_slice = np.array([0.3477, 0.3882, 0.4541, 0.3413, 0.3821, 0.4463, 0.4001, 0.4409, 0.4958])
|
||||||
|
|
||||||
expected_slice = np.array([0.2637, 0.291, 0.2939, 0.207, 0.2512, 0.2783, 0.2168, 0.2324, 0.2817])
|
max_diff = numpy_cosine_similarity_distance(image_slice.flatten(), expected_slice)
|
||||||
|
self.assertLessEqual(max_diff, 1e-4)
|
||||||
max_diff = np.abs(image_slice.flatten() - expected_slice).max()
|
|
||||||
self.assertLessEqual(max_diff, 1e-3)
|
|
||||||
|
|
||||||
def test_pixart_1024_without_resolution_binning(self):
|
def test_pixart_1024_without_resolution_binning(self):
|
||||||
generator = torch.manual_seed(0)
|
generator = torch.manual_seed(0)
|
||||||
@@ -372,7 +376,7 @@ class PixArtAlphaPipelineIntegrationTests(unittest.TestCase):
|
|||||||
|
|
||||||
prompt = self.prompt
|
prompt = self.prompt
|
||||||
height, width = 1024, 768
|
height, width = 1024, 768
|
||||||
num_inference_steps = 10
|
num_inference_steps = 2
|
||||||
|
|
||||||
image = pipe(
|
image = pipe(
|
||||||
prompt,
|
prompt,
|
||||||
@@ -406,7 +410,7 @@ class PixArtAlphaPipelineIntegrationTests(unittest.TestCase):
|
|||||||
|
|
||||||
prompt = self.prompt
|
prompt = self.prompt
|
||||||
height, width = 512, 768
|
height, width = 512, 768
|
||||||
num_inference_steps = 10
|
num_inference_steps = 2
|
||||||
|
|
||||||
image = pipe(
|
image = pipe(
|
||||||
prompt,
|
prompt,
|
||||||
|
|||||||
Reference in New Issue
Block a user