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
An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
My own task or dataset (give details below)
Reproduction
from transformers.image_transforms import center_crop
import numpy as np
small_even = np.ones((3,4,4))
small_odd = np.ones((3,3,3))
big_even = np.ones((3,10,10))
big_odd = np.ones((3,11,11))
print([center_crop(x, (8,8)).shape for x in [small_even, big_even, big_odd, small_odd]])
Result:
[(3, 8, 8), (3, 8, 8), (3, 8, 8), (3, 7, 7)]
Expected behavior
All arrays should be cropped to the requested size of (8,8). However, odd-numbered dimensions that are smaller than the crop size and require padding result in an unexpected off-by-one output size.
The text was updated successfully, but these errors were encountered:
I believe the issue is more accurately caused by odd-numbered difference between original size and new size. Rounding up rather than down when calculating the padding fixes the above test cases.
System Info
transformers 4.40.1, python 3.12
Who can help?
@amyeroberts
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
Result:
Expected behavior
All arrays should be cropped to the requested size of (8,8). However, odd-numbered dimensions that are smaller than the crop size and require padding result in an unexpected off-by-one output size.
The text was updated successfully, but these errors were encountered: