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): ...

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.