Debugging an augmentation pipeline with ReplayCompose¶
An augmentation pipeline has a lot of randomness inside it. It applies augmentations with some probabilities, and it samples parameters for those augmentations (such as a rotation angle or a level of changing brightness) from a random distribution.
It could be very useful for debugging purposes to see which augmentations were applied to the image and look at the parameters of those augmentations.
ReplayCompose tracks augmentation parameters. You can inspect those parameters or reapply them to another image.
Import the required libraries¶
import random import cv2 import matplotlib.pyplot as plt import albumentations as A
Define the visualization function¶
def visualize(image): plt.figure(figsize=(10, 10)) plt.axis('off') plt.imshow(image)
Load an image from the disk¶
image = cv2.imread('images/parrot.jpg') image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) visualize(image)