You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
VaeImageProcessor.denormalize() raises AttributeError for NumPy inputs #15011
VaeImageProcessor.denormalize() is documented to accept both NumPy arrays (np.ndarray) and PyTorch tensors (torch.Tensor). However, passing a NumPy array raises an AttributeError because the implementation uses the PyTorch-specific .clamp() method.
Root cause
In src/diffusers/image_processor.py, line 234:
return (images*0.5+0.5).clamp(0, 1)
NumPy arrays do not implement .clamp(), despite being included in the function's type annotations and documentation.
Expected behavior
The function should denormalize NumPy inputs to [0, 1], preserving the input type and existing PyTorch behavior.
Proposed direction
Use input-type-appropriate clipping, such as np.clip() for NumPy and .clamp() for PyTorch, or clarify the supported types if NumPy support is not intended.
I'd be happy to contribute a fix after discussing the preferred approach with maintainers.
I'd appreciate your feedback on the expected NumPy support and the preferred approach to resolving this issue. I'm happy to contribute a fix once the implementation approach is agreed upon.
Basically, VaeImageProcessor.denormalize() supports both NumPy arrays and PyTorch tensors according to its documentation, but internally uses .clamp(), which is only available for PyTorch tensors. As a result, NumPy inputs raise an AttributeError. I've reproduced this locally and verified the expected output against PyTorch.
Activity
SrijanRoy123-github commentedon Oct 12, 2026
Basically,
VaeImageProcessor.denormalize()supports both NumPy arrays and PyTorch tensors according to its documentation, but internally uses.clamp(), which is only available for PyTorch tensors. As a result, NumPy inputs raise anAttributeError. I've reproduced this locally and verified the expected output against PyTorch.