Unverified Commit c079cae3 authored by Iván de Prado's avatar Iván de Prado Committed by GitHub
Browse files

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
parent c7bfb8b2
...@@ -326,7 +326,7 @@ class VaeImageProcessor(ConfigMixin): ...@@ -326,7 +326,7 @@ class VaeImageProcessor(ConfigMixin):
# expected range [0,1], normalize to [-1,1] # expected range [0,1], normalize to [-1,1]
do_normalize = self.config.do_normalize do_normalize = self.config.do_normalize
if image.min() < 0 and do_normalize: if do_normalize and image.min() < 0:
warnings.warn( 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] " "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()}]", f"when passing as pytorch tensor or numpy Array. You passed `image` with value range [{image.min()},{image.max()}]",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment