- Import all necessary libraries as follows:
import globimport numpy as npimport cv2from matplotlib import pyplot as pltfrom sklearn.model_selection import train_test_splitfrom keras.utils import np_utilsfrom keras import utils, losses, optimizersfrom keras.models import Sequentialfrom keras.layers.core import Dense, Dropout, Activation, Flatten, Lambdafrom keras.callbacks import EarlyStopping, ModelCheckpointfrom keras.layers import Conv2D, MaxPooling2DSEED = 2017
- Let's start with loading the filenames and outputting the training set sizes:
# Specify data directory and extract all file names for both classesDATA_DIR = 'Data/PetImages/'cats = glob.glob(DATA_DIR + "Cat/*.jpg")dogs = glob.glob(DATA_DIR + "Dog/*.jpg")print('#Cats: ...