2828 UNet2DModel ,
2929 VQModel ,
3030)
31- from diffusers .utils import floats_tensor , load_image , slow , torch_device
31+ from diffusers .utils import floats_tensor , load_image , load_numpy , slow , torch_device
3232from diffusers .utils .testing_utils import require_torch_gpu
3333from PIL import Image
3434from transformers import CLIPTextConfig , CLIPTextModel , CLIPTokenizer
@@ -278,11 +278,10 @@ def test_stable_diffusion_inpaint_pipeline(self):
278278 "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
279279 "/in_paint/overture-creations-5sI6fQgYIuo_mask.png"
280280 )
281- expected_image = load_image (
282- "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
283- "/in_paint/ yellow_cat_sitting_on_a_park_bench.png "
281+ expected_image = load_numpy (
282+ "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/in_paint "
283+ "/yellow_cat_sitting_on_a_park_bench.npy "
284284 )
285- expected_image = np .array (expected_image , dtype = np .float32 ) / 255.0
286285
287286 model_id = "runwayml/stable-diffusion-inpainting"
288287 pipe = StableDiffusionInpaintPipeline .from_pretrained (
@@ -307,7 +306,7 @@ def test_stable_diffusion_inpaint_pipeline(self):
307306 image = output .images [0 ]
308307
309308 assert image .shape == (512 , 512 , 3 )
310- assert np .abs (expected_image - image ).max () < 1e-2
309+ assert np .abs (expected_image - image ).max () < 1e-3
311310
312311 def test_stable_diffusion_inpaint_pipeline_fp16 (self ):
313312 init_image = load_image (
@@ -318,11 +317,10 @@ def test_stable_diffusion_inpaint_pipeline_fp16(self):
318317 "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
319318 "/in_paint/overture-creations-5sI6fQgYIuo_mask.png"
320319 )
321- expected_image = load_image (
322- "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
323- "/in_paint/ yellow_cat_sitting_on_a_park_bench_fp16.png "
320+ expected_image = load_numpy (
321+ "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/in_paint "
322+ "/yellow_cat_sitting_on_a_park_bench_fp16.npy "
324323 )
325- expected_image = np .array (expected_image , dtype = np .float32 ) / 255.0
326324
327325 model_id = "runwayml/stable-diffusion-inpainting"
328326 pipe = StableDiffusionInpaintPipeline .from_pretrained (
@@ -360,11 +358,10 @@ def test_stable_diffusion_inpaint_pipeline_pndm(self):
360358 "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
361359 "/in_paint/overture-creations-5sI6fQgYIuo_mask.png"
362360 )
363- expected_image = load_image (
364- "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
365- "/in_paint/ yellow_cat_sitting_on_a_park_bench_pndm.png "
361+ expected_image = load_numpy (
362+ "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/in_paint "
363+ "/yellow_cat_sitting_on_a_park_bench_pndm.npy "
366364 )
367- expected_image = np .array (expected_image , dtype = np .float32 ) / 255.0
368365
369366 model_id = "runwayml/stable-diffusion-inpainting"
370367 pndm = PNDMScheduler .from_config (model_id , subfolder = "scheduler" )
@@ -388,4 +385,4 @@ def test_stable_diffusion_inpaint_pipeline_pndm(self):
388385 image = output .images [0 ]
389386
390387 assert image .shape == (512 , 512 , 3 )
391- assert np .abs (expected_image - image ).max () < 1e-2
388+ assert np .abs (expected_image - image ).max () < 1e-3
0 commit comments