mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-31 02:02:21 +06:00
Move rescale dtype recasting to match torchvision ToTensor (#25229)
Move dtype recasting to match torchvision ToTensor
This commit is contained in:
parent
3170af71e1
commit
d27e4c18fe
@ -110,11 +110,12 @@ def rescale(
|
||||
if not isinstance(image, np.ndarray):
|
||||
raise ValueError(f"Input image must be of type np.ndarray, got {type(image)}")
|
||||
|
||||
image = image.astype(dtype)
|
||||
|
||||
rescaled_image = image * scale
|
||||
if data_format is not None:
|
||||
rescaled_image = to_channel_dimension_format(rescaled_image, data_format)
|
||||
|
||||
rescaled_image = rescaled_image.astype(dtype)
|
||||
|
||||
return rescaled_image
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user