From 926b34b40c602e6f26b257419ea5f400cffe2f62 Mon Sep 17 00:00:00 2001 From: Patrick von Platen Date: Sun, 22 Jan 2023 14:30:15 +0200 Subject: [PATCH] improve tests --- tests/pipelines/dit/test_dit.py | 4 ++-- .../test_stable_diffusion_instruction_pix2pix.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/pipelines/dit/test_dit.py b/tests/pipelines/dit/test_dit.py index a1052eee..ca2b183a 100644 --- a/tests/pipelines/dit/test_dit.py +++ b/tests/pipelines/dit/test_dit.py @@ -111,7 +111,7 @@ class DiTPipelineIntegrationTests(unittest.TestCase): expected_image = load_numpy( f"https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/dit/{word}.npy" ) - assert np.abs((expected_image - image).sum()) < 1e-3 + assert np.abs((expected_image - image).abs()) < 1e-3 def test_dit_512_fp16(self): generator = torch.manual_seed(0) @@ -130,4 +130,4 @@ class DiTPipelineIntegrationTests(unittest.TestCase): "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main" f"/dit/{word}_fp16.npy" ) - assert np.abs((expected_image - image).sum()) < 1e-3 + assert np.abs((expected_image - image).max()) < 1e-2 diff --git a/tests/pipelines/stable_diffusion/test_stable_diffusion_instruction_pix2pix.py b/tests/pipelines/stable_diffusion/test_stable_diffusion_instruction_pix2pix.py index 8f5efb86..ee9263cc 100644 --- a/tests/pipelines/stable_diffusion/test_stable_diffusion_instruction_pix2pix.py +++ b/tests/pipelines/stable_diffusion/test_stable_diffusion_instruction_pix2pix.py @@ -307,13 +307,13 @@ class StableDiffusionInstructPix2PixPipelineSlowTests(unittest.TestCase): assert latents.shape == (1, 4, 64, 64) latents_slice = latents[0, -3:, -3:, -1] expected_slice = np.array([-0.2388, -0.4673, -0.9775, 1.5127, 1.4414, 0.7778, 0.9907, 0.8472, 0.7788]) - assert np.abs(latents_slice.flatten() - expected_slice).max() < 1e-3 + assert np.abs(latents_slice.flatten() - expected_slice).max() < 1e-2 elif step == 2: latents = latents.detach().cpu().numpy() assert latents.shape == (1, 4, 64, 64) latents_slice = latents[0, -3:, -3:, -1] expected_slice = np.array([-0.2568, -0.4648, -0.9639, 1.5137, 1.4609, 0.7603, 0.9795, 0.8403, 0.7949]) - assert np.abs(latents_slice.flatten() - expected_slice).max() < 1e-3 + assert np.abs(latents_slice.flatten() - expected_slice).max() < 1e-2 callback_fn.has_been_called = False