diff --git a/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py b/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py index 2a1815cf6f..0c6fb0729e 100644 --- a/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py +++ b/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py @@ -585,7 +585,7 @@ class StableDiffusionInpaintPipeline( "Since strength < 1. initial latents are to be initialised as a combination of Image + Noise." "However, either the image or the noise timestep has not been provided." ) - + noise = randn_tensor(shape, generator=generator, device=device, dtype=dtype) if return_image_latents or (latents is None and not is_strength_max): @@ -768,9 +768,8 @@ class StableDiffusionInpaintPipeline( [`self.processor`](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py). force_unmasked_unchanged (`bool`, *optional*): Whether to force the unmasked areas of `image` to remain exactly the same after inpainting for a model - with 9 UNet channels. If the UNet has only 4 channels, then the unmasked areas will always be forced - to remain unchanged, and setting `force_unmasked_unchanged` to `False` in this case will raise an - error. + with 9 UNet channels. If the UNet has only 4 channels, then the unmasked areas will always be forced to + remain unchanged, and setting `force_unmasked_unchanged` to `False` in this case will raise an error. Examples: diff --git a/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py b/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py index 616471b2c4..e2ab32e9cf 100644 --- a/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py +++ b/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py @@ -266,7 +266,7 @@ class StableDiffusionInpaintPipelineFastTests( inputs["strength"] = 0.01 with self.assertRaises(ValueError): sd_pipe(**inputs).images - + def test_stable_diffusion_inpaint_force_unmasked_unchanged(self): device = "cpu" # ensure determinism for the device-dependent torch.Generator components = self.get_dummy_components() @@ -364,7 +364,7 @@ class StableDiffusionSimpleInpaintPipelineFastTests(StableDiffusionInpaintPipeli expected_slice = np.array([0.4925, 0.4967, 0.4100, 0.5234, 0.5322, 0.4532, 0.5805, 0.5877, 0.4151]) assert np.abs(image_slice.flatten() - expected_slice).max() < 1e-2 - + def test_stable_diffusion_inpaint_force_unmasked_unchanged_false(self): device = "cpu" # ensure determinism for the device-dependent torch.Generator components = self.get_dummy_components()