HorizontalFlip and VerticalFlip inconsistent with multilabel masks
See original GitHub issue🐛 Bug
Given a pair of image and its corresponding mask, the generated output for the augmented mask through augmentation is not the same as the image.(it is inconsistent) when HorizontalFlip() and VerticalFlip() are included in the augmentations.
To Reproduce
The following snippet is a small dataloader that i usually use. Can’t share code.
self.aug = Compose([
RandomBrightnessContrast(),
HueSaturationValue(),
RandomGamma(),
GaussNoise(),
GaussianBlur(),
# HorizontalFlip(),
# VerticalFlip(),
])
def __getitem__(self, patient_id):
image_path = os.path.join(self.df.iloc[patient_id, 0])
z = np.load(image_path)
image = z['patch']
gt_data = z['patch_gt']
# print("Pre : ", image.shape, gt_data.shape)
gt_data = gt_data.swapaxes(0, 2)
# print("Pre swapped: ", image.shape, gt_data.shape)
# gt_data = gt_data[:4, :, :]
if not self.valid:
augmented = self.aug(image=image, mask=gt_data)
image = augmented['image']
gt_data = augmented['mask']
image = (image/255).astype(np.float32)
# print("Post Augment :", image.shape, gt_data.shape)
image = image.swapaxes(0, 2)
gt_data = gt_data.swapaxes(0, 2)
# print("Post Augment Swapped: ", image.shape, gt_data.shape)
image = torch.FloatTensor(image)
gt_data = torch.FloatTensor(gt_data)
#mask.shape = (5, 256, 256)
#image.shape = (256, 256, 3)
return image, gt_data
Expected behavior
The augmentation over the images for horizontal and vertical flip should be working fine for both the mask and the image, but for some reason, there are errors in mask augmentations during horizontal and vertical flips.
Image shape : 256, 256, 3 Mask Shape : 5, 256, 256
Environment
- Albumentations version : 0.43.
- Python version : 3.6
- OS (e.g., Linux): Linux
- How you installed albumentations (
conda
,pip
, source): pip - Any other relevant information:
Additional context
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (1 by maintainers)
Top Results From Across the Web
Using Albumentations for a semantic segmentation task
Combinations of the transformations HorizontalFlip, VerticalFlip, Transpose, RandomRotate90 will be able to get the original image to all eight states.
Read more >UWMGI: Unet [Train] [PyTorch] - Kaggle
In this notebook I'll demonstrate how to train Unet model using PyTorch. For mask I'll be using pre-computed mask from here; As there...
Read more >How to Configure Image Data Augmentation in Keras
Horizontal and Vertical Flip Augmentation. An image flip means reversing the rows or columns of pixels in the case of a vertical or...
Read more >Keras U-Net multi-label segmentation with two input binary ...
I am working on a multi-label segmentation problem using U-Net with Keras backend. For every input image, I have two masks, belonging to...
Read more >How we solved multilabel classification and segmentation
How to do multilabel classification, multi-label semantic segmentation. ... So, only take segmentation mask for those classes which were ...
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 Free
Top 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
As @BloodAxe said, please, give a minimal example to reproduce the problem.
Problem with
swapaxes
usenp.transpose(gt_data, [1, 2, 0])