Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: index 0 is out of bounds for axis 0 with size 0 #25

Open
jishuanxu opened this issue Jul 11, 2020 · 2 comments
Open

IndexError: index 0 is out of bounds for axis 0 with size 0 #25

jishuanxu opened this issue Jul 11, 2020 · 2 comments

Comments

@jishuanxu
Copy link

jishuanxu commented Jul 11, 2020

I get this error when setting RandomScale to a large number like 0.5、0.8
transforms = Sequence([RandomHorizontalFlip(1), RandomScale((0.8,0.9), diff = True), RandomRotate(10)])

IndexError Traceback (most recent call last)
in
34 transforms = Sequence([RandomHorizontalFlip(1), RandomScale((0.8,0.9), diff = True), RandomRotate(10)])
35
---> 36 img, bboxes = transforms(img, bboxes)
37 cv2.imwrite(os.path.join('JPEGImages2',file), img)
38 plt.imshow(draw_rect(img, bboxes))

~/card/DataAugmentationForObjectDetection/data_aug/data_aug.py in call(self, images, bboxes)
853
854 if random.random() < prob:
--> 855 images, bboxes = augmentation(images, bboxes)
856 return images, bboxes

~/card/DataAugmentationForObjectDetection/data_aug/data_aug.py in call(self, img, bboxes)
456
457
--> 458 corners[:,:8] = rotate_box(corners[:,:8], angle, cx, cy, h, w)
459
460 new_bbox = get_enclosing_box(corners)

~/card/DataAugmentationForObjectDetection/data_aug/bbox_util.py in rotate_box(corners, angle, cx, cy, h, w)
214
215 corners = corners.reshape(-1,2)
--> 216 corners = np.hstack((corners, np.ones((corners.shape[0],1), dtype = type(corners[0][0]))))
217
218 M = cv2.getRotationMatrix2D((cx, cy), angle, 1.0)

IndexError: index 0 is out of bounds for axis 0 with size 0

@konradkostrzewa
Copy link

Have the same issue. Anyone managed to solve?

@pangsu0613
Copy link

Sequence([RandomHorizontalFlip(1), RandomScale((0.8,0.9), diff = True), RandomRotate(10)]) will do these three augmentation transformations one by one, so after RandomScale, maybe some of the bounding boxes have already been outside of the image, then for the input of RandomeRotate, the input box would be empty (or say size 0), then you will get this error. I suggest doing these augmentation transformations one by one, and check the output boxes after each transformation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants