Random horizontal and vertical flips doesn't work with bbox
See original GitHub issue🐛 Bug
Random{Horizontal/Vertical}Flip for Transform2D and Transform3D doesn’t work. See image attached.
EDIT: RandomRotation always shows the same behavior. RandomCrop, CenterCrop, RandomResizedCrop, RandomErasing and RandomPerspective are fine (checked 2D version).
To Reproduce
!wget https://tinypng.com/images/social/website.jpg -O panda.jpg
from kornia import augmentation as K
tfm= K.AugmentationSequential(
K.RandomVerticalFlip(p=1.)
data_keys=["input", "bbox"]),
return_transform=False,
same_on_batch=False
)
img = cv2.imread("panda.jpg", cv2.IMREAD_COLOR)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
h, w = img.shape[:2]
image= image_to_tensor(img).float() / 255.
bbox = torch.tensor([[[355,10],[660,10],[660,250],[355,250]]])
tfm(image, bbox.float())
Original image:
Transformed image:
Original box (in xyxy): tensor([[355., 10., 660., 250.]]) Transformed box (in xyxy): tensor([[ 355., -246., 660., -6.]])
Expected behavior
Correct transformed box (in xyxy): tensor([[355., 260., 660., 500.]])
Environment
pytorch 1.8.1 Kornia 0.5.6
Addition comments
Shortly, I’ll make a PR
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
bbox vertical flip is not handled correctly when aug test #2805
If I set random vertical flip, bbox transform in mmdet/core/bbox/transforms.py handle the vertical flip via horizontal flip.
Read more >Data Augmentation For Bounding Boxes: Flipping
For example, an augmentation which horizontally flips the image for classification tasks will like look the one above.
Read more >Augmentations, Data Cleaning and Bounding Boxes - Kaggle
p=0.5 means that with a probability of 50%, the transform will flip the image horizontally, and with a probability of 50%, the transform...
Read more >class albumentations.augmentations.transforms. Blur
Blur the input image using a random-sized kernel. ... -1 for both vertical and horizontal flipping (which is also could be seen as...
Read more >Geometric transforms (augmentations.geometric.transforms)
Rotation happens around the center of the image, not the top left corner as in ... Flip the input either horizontally, vertically or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@hal-314 please, make sure to add some tests in PR that fixes the issue
@shijianjian