Challenge - 5 Problems
Albumentations Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of Albumentations transform on image tensor
Given the following Albumentations transform applied to an image tensor, what is the shape of the output image after the transform?
PyTorch
import albumentations as A import numpy as np transform = A.Compose([ A.HorizontalFlip(p=1.0), A.RandomBrightnessContrast(p=1.0) ]) image = np.random.randint(0, 256, (128, 128, 3), dtype=np.uint8) augmented = transform(image=image) output_image = augmented['image'] print(output_image.shape)
Attempts:
2 left
💡 Hint
Albumentations works with HWC format images by default.
✗ Incorrect
Albumentations expects images in height-width-channel format and returns the same shape after applying transforms that do not change size.
❓ Model Choice
intermediate2:00remaining
Choosing the correct way to integrate Albumentations with PyTorch DataLoader
Which option correctly integrates Albumentations transforms into a PyTorch Dataset's __getitem__ method for image augmentation?
PyTorch
import albumentations as A from torch.utils.data import Dataset import cv2 class CustomDataset(Dataset): def __init__(self, image_paths, transform=None): self.image_paths = image_paths self.transform = transform def __getitem__(self, idx): image = cv2.imread(self.image_paths[idx]) image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) if self.transform: augmented = self.transform(image=image) image = augmented['image'] return image def __len__(self): return len(self.image_paths)
Attempts:
2 left
💡 Hint
Albumentations expects numpy arrays, not tensors.
✗ Incorrect
Albumentations works with numpy arrays, so transform must be applied inside __getitem__ before converting to tensor.
❓ Hyperparameter
advanced1:30remaining
Effect of Albumentations 'p' parameter on augmentation frequency
In Albumentations, what does setting the parameter p=0.5 for a transform like HorizontalFlip mean?
Attempts:
2 left
💡 Hint
Think about probability of applying the transform per image.
✗ Incorrect
The 'p' parameter controls the chance the transform is applied to each image independently.
❓ Metrics
advanced1:30remaining
Impact of Albumentations on model training metrics
If you add Albumentations augmentations like RandomBrightnessContrast and HorizontalFlip during training, what is the most likely effect on validation accuracy and training loss?
Attempts:
2 left
💡 Hint
Augmentation adds variety to training data.
✗ Incorrect
Augmentation makes training harder initially, increasing loss, but helps model generalize better, improving validation accuracy.
🔧 Debug
expert2:30remaining
Debugging Albumentations transform causing runtime error
You have this Albumentations Compose transform:
transform = A.Compose([
A.RandomCrop(width=100, height=100),
A.HorizontalFlip(p=0.5),
A.Normalize()
])
When applying it to images of size (80, 80, 3), you get a runtime error. What is the cause?
Attempts:
2 left
💡 Hint
Check the sizes used in RandomCrop compared to input image.
✗ Incorrect
RandomCrop cannot crop a region larger than the input image, causing a runtime error.