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

Rotation scaling difference #27

Open umerhasan17 opened 3 years ago

umerhasan17 commented 3 years ago

I came across this useful library however, I noticed some unexpected behaviour when I applied the examples to my images. Unfortunately, in the example below, it seems that not only is the image being rotated it is also being scaled down. It also seems the bounding box doesn't get scaled-down alongside the image.

The problem seems to be particularly prevalent with rotations.

Here is the code for generating both images:

bboxes = np.array([list(details[image_name]['bbox'][0].values())[1:]], dtype=float)
print(bboxes)
img = cv2.imread(data_dir + "images/" + image_name + ".jpg")
plotted_img = draw_rect(img, bboxes)
plt.imshow(plotted_img)
plt.show()

img1, bboxes1 = RandomRotate(180)(img.copy(), bboxes.copy())
plotted_img = draw_rect(img1, bboxes1)
plt.imshow(plotted_img)
plt.show()

Here are the images: Imgur

Wondering if one of the authors could offer some explanation (intended effect or bug and why) and/ or a function to modify to fix this.

HansLau commented 3 years ago

Hi did u manage to solve this issue?