mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-31 02:02:21 +06:00
Fix UDOP dtype issue (#34180)
* Trigger UDOP tests * Try forcing dtype in LayoutLMV3 * Do checks to see where uint8 is getting in * Do checks to see where uint8 is getting in * Found it! * Add .astype(np.float32) * Remove forced check, make fixup * Checking where exactly the uint8 creeps in * More checking on the uint8 issues * Manually upcast in rescale() * Remove UDOP trigger
This commit is contained in:
parent
6604764007
commit
e46e3bc173
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user