Recognizing faces
In the previous recipe, we how to detect facial keypoints with a neural network. In the following recipe, we will show how to recognize faces using a deep neural network. By training a classifier from scratch, we get a lot of flexibility.
How to do it...
- As usual, let's start with importing the libraries and setting the seed:
import glob import re import matplotlib.pyplot as plt import numpy as np import cv2 from sklearn.preprocessing import LabelBinarizer from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score from keras.models import Model from keras.layers import Flatten, Dense, Input, GlobalAveragePooling2D, GlobalMaxPooling2D, Activation from keras.layers import Convolution2D, MaxPooling2D from keras import optimizers from keras import backend as K seed = 2017
- In the following step, we will load the data and output some example images to get an idea of the data:
DATA_DIR = 'Data/lfw/' images = glob.glob(DATA_DIR + '*/*.jpg') ...