Paperspace / DataAugmentationForObjectDetection

Data Augmentation For Object Detection
https://blog.paperspace.com/data-augmentation-for-bounding-boxes/
MIT License
1.13k stars 318 forks source link

Numpy divide error in RandomRotate and RandomShear #6

Open pigubaoza opened 5 years ago

pigubaoza commented 5 years ago

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.

vbsilva commented 5 years ago

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 😀