From 98bd0575a6e410faebd06620c6cbcfb7701b8376 Mon Sep 17 00:00:00 2001 From: Lewington-pitsos Date: Tue, 25 Oct 2022 02:26:29 +0100 Subject: [PATCH 1/6] improve test precision get tests passing with greater precision using lewington images --- src/diffusers/utils/__init__.py | 1 + src/diffusers/utils/testing_utils.py | 19 +++++++++++- .../test_stable_diffusion_inpaint.py | 29 +++++++++---------- .../test_stable_diffusion_inpaint_legacy.py | 20 ++++++------- 4 files changed, 41 insertions(+), 28 deletions(-) diff --git a/src/diffusers/utils/__init__.py b/src/diffusers/utils/__init__.py index 12d731128385..de3f8b05d630 100644 --- a/src/diffusers/utils/__init__.py +++ b/src/diffusers/utils/__init__.py @@ -44,6 +44,7 @@ floats_tensor, load_image, load_numpy, + load_ndarray, parse_flag_from_env, require_torch_gpu, slow, diff --git a/src/diffusers/utils/testing_utils.py b/src/diffusers/utils/testing_utils.py index bd3b08d54a1c..23ac3b22f5d8 100644 --- a/src/diffusers/utils/testing_utils.py +++ b/src/diffusers/utils/testing_utils.py @@ -11,7 +11,6 @@ from typing import Union import numpy as np - import PIL.Image import PIL.ImageOps import requests @@ -138,6 +137,24 @@ def require_onnxruntime(test_case): """ return unittest.skipUnless(is_onnx_available(), "test requires onnxruntime")(test_case) +def load_ndarray(arry: Union[str, np.ndarray]) -> np.ndarray: + if isinstance(arry, str): + if arry.startswith("http://") or arry.startswith("https://"): + arry = np.load(BytesIO(requests.get(arry).content)) + elif os.path.isfile(arry): + arry = np.load(arry) + else: + raise ValueError( + f"Incorrect path or url, URLs must start with `http://` or `https://`, and {arry} is not a valid path" + ) + elif isinstance(arry, np.ndarray): + pass + else: + raise ValueError( + "Incorrect format used for numpy ndarray. Should be an url linking to an image, a local path, or a ndarray." + ) + + return arry def load_image(image: Union[str, PIL.Image.Image]) -> PIL.Image.Image: """ diff --git a/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py b/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py index b577436f4e5d..3d03821ac369 100644 --- a/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py +++ b/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py @@ -28,7 +28,7 @@ UNet2DModel, VQModel, ) -from diffusers.utils import floats_tensor, load_image, slow, torch_device +from diffusers.utils import floats_tensor, load_image, load_ndarray, slow, torch_device from diffusers.utils.testing_utils import require_torch_gpu from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer @@ -278,11 +278,10 @@ def test_stable_diffusion_inpaint_pipeline(self): "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main" "/in_paint/overture-creations-5sI6fQgYIuo_mask.png" ) - expected_image = load_image( - "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main" - "/in_paint/yellow_cat_sitting_on_a_park_bench.png" + expected_image = load_ndarray( + "https://huggingface.co/datasets/lewington/expected-images/resolve/main" + "/yellow_cat_sitting_on_a_park_bench.npy" ) - expected_image = np.array(expected_image, dtype=np.float32) / 255.0 model_id = "runwayml/stable-diffusion-inpainting" pipe = StableDiffusionInpaintPipeline.from_pretrained( @@ -307,7 +306,7 @@ def test_stable_diffusion_inpaint_pipeline(self): image = output.images[0] assert image.shape == (512, 512, 3) - assert np.abs(expected_image - image).max() < 1e-2 + assert np.abs(expected_image - image).max() < 1e-4 def test_stable_diffusion_inpaint_pipeline_fp16(self): init_image = load_image( @@ -318,11 +317,10 @@ def test_stable_diffusion_inpaint_pipeline_fp16(self): "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main" "/in_paint/overture-creations-5sI6fQgYIuo_mask.png" ) - expected_image = load_image( - "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main" - "/in_paint/yellow_cat_sitting_on_a_park_bench_fp16.png" + expected_image = load_ndarray( + "https://huggingface.co/datasets/lewington/expected-images/resolve/main" + "/yellow_cat_sitting_on_a_park_bench_fp16.npy" ) - expected_image = np.array(expected_image, dtype=np.float32) / 255.0 model_id = "runwayml/stable-diffusion-inpainting" pipe = StableDiffusionInpaintPipeline.from_pretrained( @@ -349,7 +347,7 @@ def test_stable_diffusion_inpaint_pipeline_fp16(self): image = output.images[0] assert image.shape == (512, 512, 3) - assert np.abs(expected_image - image).max() < 1e-2 + assert np.abs(expected_image - image).max() < 1e-4 def test_stable_diffusion_inpaint_pipeline_pndm(self): init_image = load_image( @@ -360,11 +358,10 @@ def test_stable_diffusion_inpaint_pipeline_pndm(self): "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main" "/in_paint/overture-creations-5sI6fQgYIuo_mask.png" ) - expected_image = load_image( - "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main" - "/in_paint/yellow_cat_sitting_on_a_park_bench_pndm.png" + expected_image = load_ndarray( + "https://huggingface.co/datasets/lewington/expected-images/resolve/main" + "/yellow_cat_sitting_on_a_park_bench_pndm.npy" ) - expected_image = np.array(expected_image, dtype=np.float32) / 255.0 pndm = PNDMScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", skip_prk_steps=True) model_id = "runwayml/stable-diffusion-inpainting" @@ -388,4 +385,4 @@ def test_stable_diffusion_inpaint_pipeline_pndm(self): image = output.images[0] assert image.shape == (512, 512, 3) - assert np.abs(expected_image - image).max() < 1e-2 + assert np.abs(expected_image - image).max() < 1e-4 diff --git a/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint_legacy.py b/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint_legacy.py index 90dbf3b63604..ce2e494a82fa 100644 --- a/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint_legacy.py +++ b/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint_legacy.py @@ -31,7 +31,7 @@ VQModel, ) from diffusers.utils import floats_tensor, load_image, slow, torch_device -from diffusers.utils.testing_utils import require_torch_gpu +from diffusers.utils.testing_utils import load_ndarray, require_torch_gpu from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer @@ -358,11 +358,10 @@ def test_stable_diffusion_inpaint_legacy_pipeline(self): "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main" "/in_paint/overture-creations-5sI6fQgYIuo_mask.png" ) - expected_image = load_image( - "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main" - "/in_paint/red_cat_sitting_on_a_park_bench.png" + expected_image = load_ndarray( + "https://huggingface.co/datasets/lewington/expected-images/resolve/main" + "/red_cat_sitting_on_a_park_bench.npy" ) - expected_image = np.array(expected_image, dtype=np.float32) / 255.0 model_id = "CompVis/stable-diffusion-v1-4" pipe = StableDiffusionInpaintPipeline.from_pretrained( @@ -389,7 +388,7 @@ def test_stable_diffusion_inpaint_legacy_pipeline(self): image = output.images[0] assert image.shape == (512, 512, 3) - assert np.abs(expected_image - image).max() < 1e-2 + assert np.abs(expected_image - image).max() < 1e-4 def test_stable_diffusion_inpaint_legacy_pipeline_k_lms(self): # TODO(Anton, Patrick) - I think we can remove this test soon @@ -401,11 +400,10 @@ def test_stable_diffusion_inpaint_legacy_pipeline_k_lms(self): "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main" "/in_paint/overture-creations-5sI6fQgYIuo_mask.png" ) - expected_image = load_image( - "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main" - "/in_paint/red_cat_sitting_on_a_park_bench_k_lms.png" + expected_image = load_ndarray( + "https://huggingface.co/datasets/lewington/expected-images/resolve/main" + "/red_cat_sitting_on_a_park_bench_k_lms.npy" ) - expected_image = np.array(expected_image, dtype=np.float32) / 255.0 lms = LMSDiscreteScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear") @@ -435,7 +433,7 @@ def test_stable_diffusion_inpaint_legacy_pipeline_k_lms(self): image = output.images[0] assert image.shape == (512, 512, 3) - assert np.abs(expected_image - image).max() < 1e-2 + assert np.abs(expected_image - image).max() < 1e-4 def test_stable_diffusion_inpaint_legacy_intermediate_state(self): number_of_steps = 0 From 50cc3b2a61aed1481761fac4a429108c09b379c8 Mon Sep 17 00:00:00 2001 From: Lewington-pitsos Date: Sat, 29 Oct 2022 09:03:13 +1100 Subject: [PATCH 2/6] make old numpy load function a wrapper around a more flexible numpy loading function --- src/diffusers/utils/__init__.py | 2 +- src/diffusers/utils/testing_utils.py | 15 ++++++--------- tests/models/test_models_unet_2d.py | 6 +++--- tests/models/test_models_vae.py | 4 ++-- .../test_stable_diffusion_inpaint.py | 8 ++++---- .../test_stable_diffusion_inpaint_legacy.py | 6 +++--- 6 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/diffusers/utils/__init__.py b/src/diffusers/utils/__init__.py index de3f8b05d630..0a6f7365d98f 100644 --- a/src/diffusers/utils/__init__.py +++ b/src/diffusers/utils/__init__.py @@ -43,8 +43,8 @@ from .testing_utils import ( floats_tensor, load_image, + load_hf_numpy, load_numpy, - load_ndarray, parse_flag_from_env, require_torch_gpu, slow, diff --git a/src/diffusers/utils/testing_utils.py b/src/diffusers/utils/testing_utils.py index 23ac3b22f5d8..f94d79a5f070 100644 --- a/src/diffusers/utils/testing_utils.py +++ b/src/diffusers/utils/testing_utils.py @@ -137,10 +137,12 @@ def require_onnxruntime(test_case): """ return unittest.skipUnless(is_onnx_available(), "test requires onnxruntime")(test_case) -def load_ndarray(arry: Union[str, np.ndarray]) -> np.ndarray: +def load_numpy(arry: Union[str, np.ndarray]) -> np.ndarray: if isinstance(arry, str): if arry.startswith("http://") or arry.startswith("https://"): - arry = np.load(BytesIO(requests.get(arry).content)) + response = requests.get(arry) + response.raise_for_status() + arry = np.load(BytesIO(response.content)) elif os.path.isfile(arry): arry = np.load(arry) else: @@ -184,18 +186,13 @@ def load_image(image: Union[str, PIL.Image.Image]) -> PIL.Image.Image: image = image.convert("RGB") return image - -def load_numpy(path) -> np.ndarray: +def load_hf_numpy(path) -> np.ndarray: if not path.startswith("http://") or path.startswith("https://"): path = os.path.join( "https://huggingface.co/datasets/fusing/diffusers-testing/resolve/main", urllib.parse.quote(path) ) - response = requests.get(path) - response.raise_for_status() - array = np.load(BytesIO(response.content)) - - return array + return load_numpy(path) # --- pytest conf functions --- # diff --git a/tests/models/test_models_unet_2d.py b/tests/models/test_models_unet_2d.py index 548588918c88..ba1dd60205a5 100644 --- a/tests/models/test_models_unet_2d.py +++ b/tests/models/test_models_unet_2d.py @@ -21,7 +21,7 @@ import torch from diffusers import UNet2DConditionModel, UNet2DModel -from diffusers.utils import floats_tensor, load_numpy, logging, require_torch_gpu, slow, torch_all_close, torch_device +from diffusers.utils import floats_tensor, load_hf_numpy, logging, require_torch_gpu, slow, torch_all_close, torch_device from parameterized import parameterized from ..test_modeling_common import ModelTesterMixin @@ -423,7 +423,7 @@ def tearDown(self): def get_latents(self, seed=0, shape=(4, 4, 64, 64), fp16=False): dtype = torch.float16 if fp16 else torch.float32 - image = torch.from_numpy(load_numpy(self.get_file_format(seed, shape))).to(torch_device).to(dtype) + image = torch.from_numpy(load_hf_numpy(self.get_file_format(seed, shape))).to(torch_device).to(dtype) return image def get_unet_model(self, fp16=False, model_id="CompVis/stable-diffusion-v1-4"): @@ -439,7 +439,7 @@ def get_unet_model(self, fp16=False, model_id="CompVis/stable-diffusion-v1-4"): def get_encoder_hidden_states(self, seed=0, shape=(4, 77, 768), fp16=False): dtype = torch.float16 if fp16 else torch.float32 - hidden_states = torch.from_numpy(load_numpy(self.get_file_format(seed, shape))).to(torch_device).to(dtype) + hidden_states = torch.from_numpy(load_hf_numpy(self.get_file_format(seed, shape))).to(torch_device).to(dtype) return hidden_states @parameterized.expand( diff --git a/tests/models/test_models_vae.py b/tests/models/test_models_vae.py index f6333d6cd906..3da7b50e34f3 100644 --- a/tests/models/test_models_vae.py +++ b/tests/models/test_models_vae.py @@ -20,7 +20,7 @@ from diffusers import AutoencoderKL from diffusers.modeling_utils import ModelMixin -from diffusers.utils import floats_tensor, load_numpy, require_torch_gpu, slow, torch_all_close, torch_device +from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device from parameterized import parameterized from ..test_modeling_common import ModelTesterMixin @@ -147,7 +147,7 @@ def tearDown(self): def get_sd_image(self, seed=0, shape=(4, 3, 512, 512), fp16=False): dtype = torch.float16 if fp16 else torch.float32 - image = torch.from_numpy(load_numpy(self.get_file_format(seed, shape))).to(torch_device).to(dtype) + image = torch.from_numpy(load_hf_numpy(self.get_file_format(seed, shape))).to(torch_device).to(dtype) return image def get_sd_vae_model(self, model_id="CompVis/stable-diffusion-v1-4", fp16=False): diff --git a/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py b/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py index 3d03821ac369..425a947ae7ac 100644 --- a/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py +++ b/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py @@ -28,7 +28,7 @@ UNet2DModel, VQModel, ) -from diffusers.utils import floats_tensor, load_image, load_ndarray, slow, torch_device +from diffusers.utils import floats_tensor, load_image, load_numpy, slow, torch_device from diffusers.utils.testing_utils import require_torch_gpu from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer @@ -278,7 +278,7 @@ def test_stable_diffusion_inpaint_pipeline(self): "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main" "/in_paint/overture-creations-5sI6fQgYIuo_mask.png" ) - expected_image = load_ndarray( + expected_image = load_numpy( "https://huggingface.co/datasets/lewington/expected-images/resolve/main" "/yellow_cat_sitting_on_a_park_bench.npy" ) @@ -317,7 +317,7 @@ def test_stable_diffusion_inpaint_pipeline_fp16(self): "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main" "/in_paint/overture-creations-5sI6fQgYIuo_mask.png" ) - expected_image = load_ndarray( + expected_image = load_numpy( "https://huggingface.co/datasets/lewington/expected-images/resolve/main" "/yellow_cat_sitting_on_a_park_bench_fp16.npy" ) @@ -358,7 +358,7 @@ def test_stable_diffusion_inpaint_pipeline_pndm(self): "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main" "/in_paint/overture-creations-5sI6fQgYIuo_mask.png" ) - expected_image = load_ndarray( + expected_image = load_numpy( "https://huggingface.co/datasets/lewington/expected-images/resolve/main" "/yellow_cat_sitting_on_a_park_bench_pndm.npy" ) diff --git a/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint_legacy.py b/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint_legacy.py index ce2e494a82fa..b6ee2778d387 100644 --- a/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint_legacy.py +++ b/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint_legacy.py @@ -31,7 +31,7 @@ VQModel, ) from diffusers.utils import floats_tensor, load_image, slow, torch_device -from diffusers.utils.testing_utils import load_ndarray, require_torch_gpu +from diffusers.utils.testing_utils import load_numpy, require_torch_gpu from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer @@ -358,7 +358,7 @@ def test_stable_diffusion_inpaint_legacy_pipeline(self): "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main" "/in_paint/overture-creations-5sI6fQgYIuo_mask.png" ) - expected_image = load_ndarray( + expected_image = load_numpy( "https://huggingface.co/datasets/lewington/expected-images/resolve/main" "/red_cat_sitting_on_a_park_bench.npy" ) @@ -400,7 +400,7 @@ def test_stable_diffusion_inpaint_legacy_pipeline_k_lms(self): "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main" "/in_paint/overture-creations-5sI6fQgYIuo_mask.png" ) - expected_image = load_ndarray( + expected_image = load_numpy( "https://huggingface.co/datasets/lewington/expected-images/resolve/main" "/red_cat_sitting_on_a_park_bench_k_lms.npy" ) From ea7feefd7b39cfce7d6933c1e10867e1eb9b6991 Mon Sep 17 00:00:00 2001 From: Lewington-pitsos Date: Sat, 29 Oct 2022 09:20:21 +1100 Subject: [PATCH 3/6] adhere to black formatting --- src/diffusers/utils/testing_utils.py | 4 ++++ tests/models/test_models_unet_2d.py | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/diffusers/utils/testing_utils.py b/src/diffusers/utils/testing_utils.py index f94d79a5f070..417fad27f54f 100644 --- a/src/diffusers/utils/testing_utils.py +++ b/src/diffusers/utils/testing_utils.py @@ -11,6 +11,7 @@ from typing import Union import numpy as np + import PIL.Image import PIL.ImageOps import requests @@ -137,6 +138,7 @@ def require_onnxruntime(test_case): """ return unittest.skipUnless(is_onnx_available(), "test requires onnxruntime")(test_case) + def load_numpy(arry: Union[str, np.ndarray]) -> np.ndarray: if isinstance(arry, str): if arry.startswith("http://") or arry.startswith("https://"): @@ -158,6 +160,7 @@ def load_numpy(arry: Union[str, np.ndarray]) -> np.ndarray: return arry + def load_image(image: Union[str, PIL.Image.Image]) -> PIL.Image.Image: """ Args: @@ -186,6 +189,7 @@ def load_image(image: Union[str, PIL.Image.Image]) -> PIL.Image.Image: image = image.convert("RGB") return image + def load_hf_numpy(path) -> np.ndarray: if not path.startswith("http://") or path.startswith("https://"): path = os.path.join( diff --git a/tests/models/test_models_unet_2d.py b/tests/models/test_models_unet_2d.py index ba1dd60205a5..20371708a4d8 100644 --- a/tests/models/test_models_unet_2d.py +++ b/tests/models/test_models_unet_2d.py @@ -21,7 +21,15 @@ import torch from diffusers import UNet2DConditionModel, UNet2DModel -from diffusers.utils import floats_tensor, load_hf_numpy, logging, require_torch_gpu, slow, torch_all_close, torch_device +from diffusers.utils import ( + floats_tensor, + load_hf_numpy, + logging, + require_torch_gpu, + slow, + torch_all_close, + torch_device, +) from parameterized import parameterized from ..test_modeling_common import ModelTesterMixin From 8ffe1bb39f3a2c2b4493254a235a8aaca1b40b0b Mon Sep 17 00:00:00 2001 From: Lewington-pitsos Date: Sat, 29 Oct 2022 09:49:08 +1100 Subject: [PATCH 4/6] add more black formatting --- src/diffusers/utils/testing_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/diffusers/utils/testing_utils.py b/src/diffusers/utils/testing_utils.py index 417fad27f54f..bf398e5b6fe5 100644 --- a/src/diffusers/utils/testing_utils.py +++ b/src/diffusers/utils/testing_utils.py @@ -155,7 +155,8 @@ def load_numpy(arry: Union[str, np.ndarray]) -> np.ndarray: pass else: raise ValueError( - "Incorrect format used for numpy ndarray. Should be an url linking to an image, a local path, or a ndarray." + "Incorrect format used for numpy ndarray. Should be an url linking to an image, a local path, or a" + " ndarray." ) return arry From 5e749a9524a0212da914d905009c26d928a216b3 Mon Sep 17 00:00:00 2001 From: Lewington-pitsos Date: Sat, 29 Oct 2022 09:52:55 +1100 Subject: [PATCH 5/6] adhere to isort --- src/diffusers/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/diffusers/utils/__init__.py b/src/diffusers/utils/__init__.py index 0a6f7365d98f..7395f4edfa26 100644 --- a/src/diffusers/utils/__init__.py +++ b/src/diffusers/utils/__init__.py @@ -42,8 +42,8 @@ if is_torch_available(): from .testing_utils import ( floats_tensor, - load_image, load_hf_numpy, + load_image, load_numpy, parse_flag_from_env, require_torch_gpu, From ed2216211bb22ff9e70456605817199316ebe62c Mon Sep 17 00:00:00 2001 From: Patrick von Platen Date: Wed, 2 Nov 2022 10:43:54 +0000 Subject: [PATCH 6/6] loosen precision and replace path --- .../stable_diffusion/test_stable_diffusion_inpaint.py | 10 +++++----- .../test_stable_diffusion_inpaint_legacy.py | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py b/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py index 5994b2197fe7..f5a8b3cf9ecc 100644 --- a/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py +++ b/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py @@ -279,7 +279,7 @@ def test_stable_diffusion_inpaint_pipeline(self): "/in_paint/overture-creations-5sI6fQgYIuo_mask.png" ) expected_image = load_numpy( - "https://huggingface.co/datasets/lewington/expected-images/resolve/main" + "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/in_paint" "/yellow_cat_sitting_on_a_park_bench.npy" ) @@ -306,7 +306,7 @@ def test_stable_diffusion_inpaint_pipeline(self): image = output.images[0] assert image.shape == (512, 512, 3) - assert np.abs(expected_image - image).max() < 1e-4 + assert np.abs(expected_image - image).max() < 1e-3 def test_stable_diffusion_inpaint_pipeline_fp16(self): init_image = load_image( @@ -318,7 +318,7 @@ def test_stable_diffusion_inpaint_pipeline_fp16(self): "/in_paint/overture-creations-5sI6fQgYIuo_mask.png" ) expected_image = load_numpy( - "https://huggingface.co/datasets/lewington/expected-images/resolve/main" + "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/in_paint" "/yellow_cat_sitting_on_a_park_bench_fp16.npy" ) @@ -359,7 +359,7 @@ def test_stable_diffusion_inpaint_pipeline_pndm(self): "/in_paint/overture-creations-5sI6fQgYIuo_mask.png" ) expected_image = load_numpy( - "https://huggingface.co/datasets/lewington/expected-images/resolve/main" + "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/in_paint" "/yellow_cat_sitting_on_a_park_bench_pndm.npy" ) @@ -385,4 +385,4 @@ def test_stable_diffusion_inpaint_pipeline_pndm(self): image = output.images[0] assert image.shape == (512, 512, 3) - assert np.abs(expected_image - image).max() < 1e-4 + assert np.abs(expected_image - image).max() < 1e-3 diff --git a/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint_legacy.py b/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint_legacy.py index 7b47c83e0d9d..81deba67f274 100644 --- a/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint_legacy.py +++ b/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint_legacy.py @@ -359,7 +359,7 @@ def test_stable_diffusion_inpaint_legacy_pipeline(self): "/in_paint/overture-creations-5sI6fQgYIuo_mask.png" ) expected_image = load_numpy( - "https://huggingface.co/datasets/lewington/expected-images/resolve/main" + "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/in_paint" "/red_cat_sitting_on_a_park_bench.npy" ) @@ -388,7 +388,7 @@ def test_stable_diffusion_inpaint_legacy_pipeline(self): image = output.images[0] assert image.shape == (512, 512, 3) - assert np.abs(expected_image - image).max() < 1e-4 + assert np.abs(expected_image - image).max() < 1e-3 def test_stable_diffusion_inpaint_legacy_pipeline_k_lms(self): # TODO(Anton, Patrick) - I think we can remove this test soon @@ -401,7 +401,7 @@ def test_stable_diffusion_inpaint_legacy_pipeline_k_lms(self): "/in_paint/overture-creations-5sI6fQgYIuo_mask.png" ) expected_image = load_numpy( - "https://huggingface.co/datasets/lewington/expected-images/resolve/main" + "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/in_paint" "/red_cat_sitting_on_a_park_bench_k_lms.npy" ) @@ -432,7 +432,7 @@ def test_stable_diffusion_inpaint_legacy_pipeline_k_lms(self): image = output.images[0] assert image.shape == (512, 512, 3) - assert np.abs(expected_image - image).max() < 1e-4 + assert np.abs(expected_image - image).max() < 1e-3 def test_stable_diffusion_inpaint_legacy_intermediate_state(self): number_of_steps = 0