Skip to content

Commit 2b1f4e1

Browse files
committed
Fix StableDiffusionInstructPix2PixPipelineSingleFileSlowTests
1 parent edb8c1b commit 2b1f4e1

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/diffusers/loaders/single_file_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@
186186
"inpainting": 512,
187187
"inpainting_v2": 512,
188188
"controlnet": 512,
189+
"instruct-pix2pix": 512,
189190
"v2": 768,
190191
"v1": 512,
191192
}

tests/single_file/single_file_testing_utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ def download_diffusers_config(repo_id, tmpdir):
4747

4848

4949
class SDSingleFileTesterMixin:
50+
single_file_kwargs = {}
51+
5052
def _compare_component_configs(self, pipe, single_file_pipe):
5153
for param_name, param_value in single_file_pipe.text_encoder.config.to_dict().items():
5254
if param_name in ["torch_dtype", "architectures", "_name_or_path"]:
@@ -154,7 +156,7 @@ def test_single_file_components_with_original_config_local_files_only(
154156
self._compare_component_configs(pipe, single_file_pipe)
155157

156158
def test_single_file_format_inference_is_same_as_pretrained(self, expected_max_diff=1e-4):
157-
sf_pipe = self.pipeline_class.from_single_file(self.ckpt_path, safety_checker=None)
159+
sf_pipe = self.pipeline_class.from_single_file(self.ckpt_path, safety_checker=None, **self.single_file_kwargs)
158160
sf_pipe.unet.set_attn_processor(AttnProcessor())
159161
sf_pipe.enable_model_cpu_offload(device=torch_device)
160162

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

171173
max_diff = numpy_cosine_similarity_distance(image.flatten(), image_single_file.flatten())
172174

173-
assert max_diff < expected_max_diff
175+
assert max_diff < expected_max_diff, f"{image.flatten()} != {image_single_file.flatten()}"
174176

175177
def test_single_file_components_with_diffusers_config(
176178
self,

tests/single_file/test_stable_diffusion_single_file.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ class StableDiffusionInstructPix2PixPipelineSingleFileSlowTests(unittest.TestCas
132132
"https://raw.githubusercontent.com/timothybrooks/instruct-pix2pix/refs/heads/main/configs/generate.yaml"
133133
)
134134
repo_id = "timbrooks/instruct-pix2pix"
135+
single_file_kwargs = {"extract_ema": True}
135136

136137
def setUp(self):
137138
super().setUp()

0 commit comments

Comments
 (0)