Skip to content

Commit

Permalink
Fix StableDiffusionInstructPix2PixPipelineSingleFileSlowTests (#10557)
Browse files Browse the repository at this point in the history
  • Loading branch information
hlky authored Jan 13, 2025
1 parent e1c7269 commit 50c81df
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/diffusers/loaders/single_file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
"inpainting": 512,
"inpainting_v2": 512,
"controlnet": 512,
"instruct-pix2pix": 512,
"v2": 768,
"v1": 512,
}
Expand Down
6 changes: 4 additions & 2 deletions tests/single_file/single_file_testing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand Down Expand Up @@ -154,7 +156,7 @@ def test_single_file_components_with_original_config_local_files_only(
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)

Expand All @@ -170,7 +172,7 @@ def test_single_file_format_inference_is_same_as_pretrained(self, expected_max_d

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,
Expand Down
1 change: 1 addition & 0 deletions tests/single_file/test_stable_diffusion_single_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 50c81df

Please sign in to comment.