Paperspace/DataAugmentationForObjectDetection

Numpy divide error in RandomRotate and RandomShear

pigubaoza opened this issue · 1 comments

Using RandomRotate, I get the following error:
TypeError: ufunc 'true_divide' output (typecode 'd') could not be coerced to provided output parameter
(typecode 'l') according to the casting rule ''same_kind''

I was able to fix the line:
new_bbox[:,:4] /= [scale_factor_x, scale_factor_y, scale_factor_x, scale_factor_y]
to
np.true_divide(new_bbox[:,:4], [scale_factor_x, scale_factor_y, scale_factor_x, scale_factor_y], out=new_bbox[:,:4], casting='unsafe')

The same problem occurs when using RandomShear, for both ufunc true_divide and ufunc add, however, I am unable to fix it by using np.add and np.true_divide. The resulting bounding boxes are incorrect.

If you are using Python 2.x, try it with Python 3.x . The resulting bounding boxes were incorrect with python 2.x but with python 3.x they are correct 😀