How to do it...

  1. Let's first load all the necessary libraries:
import numpy as npimport cv2import matplotlib.pyplot as pltimport glob
  1. Next, we load some sample images that we will use and plot them:
DATA_DIR = 'Data/augmentation/'images = glob.glob(DATA_DIR + '*')plt.figure(figsize=(10, 10))i = 1for image in images:    img = cv2.imread(image)    img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)    plt.subplot(3, 3, i)    plt.imshow(img)    i += 1    plt.show()
Figure 7.1: Example images that we will be using for augmentation
  1. We start by defining a function to easily plot examples of our augmentations:
def plot_images(image, function, *args): plt.figure(figsize=(10, ...

Get Python Deep Learning Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.