salesforce / ALBEF

Code for ALBEF: a new vision-language pre-training method
BSD 3-Clause "New" or "Revised" License
1.45k stars 193 forks source link

Overflow in `autocontrast_func` #134

Open MagnusOstertag opened 5 months ago

MagnusOstertag commented 5 months ago

I was getting a RuntimeWarning: overflow encountered in scalar negative for offset = -low * scale in dataset/randaugment.py:32:.

The reason is that low is of class 'numpy.uint8', offset assumes this datatype, leading to problems in cases where scale is a floating point number, e.g. scale=1.0805084745762712, low=2. This leads to a wrong offset calculation because of the overflow, e.g. with offset: 274.4491525423729.

The bug could be easily fixed with casting the type of low as in offset = -np.float64(low) * scale.