Repository: transformers
Issue: `transformers.image_transforms.resize` doesnot work for negative values
Labels: WIP,bug,Vision,Processing

### System Info

- `transformers` version: 4.47.0.dev0
- Platform: Linux-6.8.0-48-generic-x86_64-with-glibc2.39
- Python version: 3.12.5
- Huggingface_hub version: 0.25.0
- Safetensors version: 0.4.5
- Accelerate version: 1.0.0
- Accelerate config:    not found
- PyTorch version (GPU?): 2.4.1+cu121 (False)
- Tensorflow version (GPU?): 2.17.0 (False)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using distributed or parallel set-up in script?: <fill in>

### Who can help?

@qubvel @amyeroberts 

### Information

- [ ] The official example scripts
- [X] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

If you try to resize an image using `transformers.image_transforms.resize` after normalization has been applied using `transformers.image_transforms.normalize`, it raises error

This was the origin of this problem: https://github.com/huggingface/transformers/pull/34583#issuecomment-2497099400

**Reproduce**

code
```py
import numpy as np
from transformers.image_transforms import resize, normalize, to_pil_image
import torch

# scaled image between 0 and 1
x = np.random.random((3, 64, 64))

x = normalize(x, mean=0.5, std=0.5)

# the raises an error 
x = resize(x, size=(400, 400))

# this would work without any error
# x = torch.nn.functional.interpolate(
# 	torch.from_numpy(x).unsqueeze(0),
# 	(400, 400), mode='bilinear'
# )
```
error
```
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
---> 11 x = resize(x, size=(400, 400))

File transformers/image_transforms.py:337, in resize(image, size, resample, reducing_gap, data_format, return_numpy, input_data_format)
    336 if not isinstance(image, PIL.Image.Image):
--> 337     do_rescale = _rescale_for_pil_conversion(image)

File transformers/image_transforms.py:158, in _rescale_for_pil_conversion(image)
--> 158     raise ValueError(
ValueError: The image to be converted to a PIL image contains values outside the range [0, 1], got [-0.9999031475386853, 0.9996538887265269] which cannot be converted to uint8.
```

**Explanation**

1. in this specific normalization, resultant array gets negative values
2. during `resize` internally it tries to convert the array to `PIL` image
3. before converting, this function is called `transformers.image_transforms._rescale_for_pil_conversion` which expects the input to be non-negative and hence raises the exception
4. why does it require the image to be non-negative?

**Possible Solution**

I can think of a few possible solutions
- use `torch` instead of `PIL` or use both and create condition that selects the option depending on the data or put this as an option for user
- use scipy interpolations or custom functions for interpolations
- scale this image for range [0, 255] but we donot know can't scale safely without knowing the original mean and std that were used to normalize the image
- keep this function as it is and create another function that can interpolate negative values as well, based on one of the above methods


### Expected behavior

resize works with normalized data that may contain negative values, as interpolation is possible with negative values