Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UDOP dtype issue #34180

Merged
merged 11 commits into from
Oct 18, 2024
4 changes: 2 additions & 2 deletions src/transformers/image_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ def rescale(
if not isinstance(image, np.ndarray):
raise TypeError(f"Input image must be of type np.ndarray, got {type(image)}")

rescaled_image = image * scale
rescaled_image = image.astype(np.float64) * scale # Numpy type promotion has changed, so always upcast first
if data_format is not None:
rescaled_image = to_channel_dimension_format(rescaled_image, data_format, input_data_format)

rescaled_image = rescaled_image.astype(dtype)
rescaled_image = rescaled_image.astype(dtype) # Finally downcast to the desired dtype at the end

return rescaled_image

Expand Down
Loading