1
0
mirror of https://github.com/huggingface/diffusers.git synced 2026-01-27 17:22:53 +03:00

Fix StableDiffusionInstructPix2PixPipelineSingleFileSlowTests (#10557)

This commit is contained in:
hlky
2025-01-13 13:47:10 +00:00
committed by GitHub
parent e1c7269720
commit 50c81df4e7
3 changed files with 6 additions and 2 deletions

View File

@@ -186,6 +186,7 @@ DIFFUSERS_TO_LDM_DEFAULT_IMAGE_SIZE_MAP = {
"inpainting": 512,
"inpainting_v2": 512,
"controlnet": 512,
"instruct-pix2pix": 512,
"v2": 768,
"v1": 512,
}

View File

@@ -47,6 +47,8 @@ def download_diffusers_config(repo_id, tmpdir):
class SDSingleFileTesterMixin:
single_file_kwargs = {}
def _compare_component_configs(self, pipe, single_file_pipe):
for param_name, param_value in single_file_pipe.text_encoder.config.to_dict().items():
if param_name in ["torch_dtype", "architectures", "_name_or_path"]:
@@ -154,7 +156,7 @@ class SDSingleFileTesterMixin:
self._compare_component_configs(pipe, single_file_pipe)
def test_single_file_format_inference_is_same_as_pretrained(self, expected_max_diff=1e-4):
sf_pipe = self.pipeline_class.from_single_file(self.ckpt_path, safety_checker=None)
sf_pipe = self.pipeline_class.from_single_file(self.ckpt_path, safety_checker=None, **self.single_file_kwargs)
sf_pipe.unet.set_attn_processor(AttnProcessor())
sf_pipe.enable_model_cpu_offload(device=torch_device)
@@ -170,7 +172,7 @@ class SDSingleFileTesterMixin:
max_diff = numpy_cosine_similarity_distance(image.flatten(), image_single_file.flatten())
assert max_diff < expected_max_diff
assert max_diff < expected_max_diff, f"{image.flatten()} != {image_single_file.flatten()}"
def test_single_file_components_with_diffusers_config(
self,

View File

@@ -132,6 +132,7 @@ class StableDiffusionInstructPix2PixPipelineSingleFileSlowTests(unittest.TestCas
"https://raw.githubusercontent.com/timothybrooks/instruct-pix2pix/refs/heads/main/configs/generate.yaml"
)
repo_id = "timbrooks/instruct-pix2pix"
single_file_kwargs = {"extract_ema": True}
def setUp(self):
super().setUp()