Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix StableDiffusionInstructPix2PixPipelineSingleFileSlowTests #10557

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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