From c079cae3d4792fb4099dd8082407cec71bf695d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20de=20Prado?= Date: Mon, 27 Nov 2023 12:46:26 +0100 Subject: [PATCH] Avoid computing min() that is expensive when do_normalize is False in the image processor (#5896) Avoid computing min() that is expensive when do_normalize is False Avoid extra computing when do_normalize is False --- src/diffusers/image_processor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/diffusers/image_processor.py b/src/diffusers/image_processor.py index de60c46eb2..3da5f70141 100644 --- a/src/diffusers/image_processor.py +++ b/src/diffusers/image_processor.py @@ -326,7 +326,7 @@ class VaeImageProcessor(ConfigMixin): # expected range [0,1], normalize to [-1,1] do_normalize = self.config.do_normalize - if image.min() < 0 and do_normalize: + if do_normalize and image.min() < 0: warnings.warn( "Passing `image` as torch tensor with value range in [-1,1] is deprecated. The expected value range for image tensor is [0,1] " f"when passing as pytorch tensor or numpy Array. You passed `image` with value range [{image.min()},{image.max()}]",