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

Error while using sequence #7

Open aymenmir94 opened 5 years ago

aymenmir94 commented 5 years ago

I am using a sequence of transforms - randomHSV, randomscale, randomsheer, randomrotate and at the end I get a strange error

I am not sure what the problem is corners = np.hstack((corners, np.ones((corners.shape[0],1), dtype = type(corners[0][0])))) IndexError: index 0 is out of bounds for axis 0 with size 0

vavassoriluca commented 5 years ago

I think the error is due to the fact that previous transformations have produced an image that as no bounding boxes in it (the object is now out of the image or truncated at the point the bbox has been deleted). So the get_corners function returns an empty array and in the rotate_box function there is no check for an empty set of bboxes.

A solution I found avoiding to edit the code is to put RandomRotate as the first transformation in the sequence.