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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.