0% found this document useful (0 votes)
13 views2 pages

Deep Learning CNN

This document outlines a script for creating a Convolutional Neural Network (CNN) model to recognize faces using a database of images. It details the image pre-processing steps for both training and testing data, including data augmentation techniques to enhance model performance. The script also generates training and testing datasets from specified directories and prints the class labels for the faces.

Uploaded by

vishal.patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

Deep Learning CNN

This document outlines a script for creating a Convolutional Neural Network (CNN) model to recognize faces using a database of images. It details the image pre-processing steps for both training and testing data, including data augmentation techniques to enhance model performance. The script also generates training and testing datasets from specified directories and prints the class labels for the faces.

Uploaded by

vishal.patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

# Deep Learning CNN model to recognize face

'''This script uses a database of images and creates CNN model on top of it to test

if the given image is recognized correctly or not'''

'''####### IMAGE PRE-PROCESSING for TRAINING and TESTING data #######'''

# Specifying the folder where images are present

TrainingImagePath='/Users/farukh/Python Case Studies/Face Images/Final Training Images'

from keras.preprocessing.image import ImageDataGenerator

# Understand more about ImageDataGenerator at below link

# https://blog.keras.io/building-powerful-image-classification-models-using-very-little-data.html

# Defining pre-processing transformations on raw images of training data

# These hyper parameters helps to generate slightly twisted versions

# of the original image, which leads to a better model, since it learns

# on the good and bad mix of images

train_datagen = ImageDataGenerator(

shear_range=0.1,

zoom_range=0.1,

horizontal_flip=True)

# Defining pre-processing transformations on raw images of testing data

# No transformations are done on the testing images

test_datagen = ImageDataGenerator()
# Generating the Training Data

training_set = train_datagen.flow_from_directory(

TrainingImagePath,

target_size=(64, 64),

batch_size=32,

class_mode='categorical')

# Generating the Testing Data

test_set = test_datagen.flow_from_directory(

TrainingImagePath,

target_size=(64, 64),

batch_size=32,

class_mode='categorical')

# Printing class labels for each face

test_set.class_indices

You might also like