O'Reilly logo

Python Deep Learning Cookbook by Indra den Bakker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required