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. We start by importing all libraries, as follows:
import numpy as npimport cv2import matplotlib.pyplot as pltimport globfrom keras.layers import Input, merge, Conv2D, MaxPooling2D, UpSampling2D, Dropout, Cropping2D, mergefrom keras.optimizers import Adamfrom keras.callbacks import ModelCheckpoint, LearningRateSchedulerfrom keras import backend as Kfrom keras.models import Model
  1. Then, we need to store all the training filenames:
import osfilenames = []for path, subdirs, files in os.walk('Data/1obj'):    for name in files:        if 'src_color' in path:            filenames.append(os.path.join(path, name))            print('# Training images: {}'.format(len(filenames)))
  1. Let's plot some example training images and their masks:
n_examples = 3for i in range(n_examples): ...

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