Skip to content

Image Classification Project that makes use of a Convolutional Neural Network to identify if a person is happy or sad

Notifications You must be signed in to change notification settings

Vishan393/Happy-Or-Sad---CNN-Image-Classifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CNN Image Classification Project - Happy or Sad People

This project is an image classification project using Convolutional Neural Networks. The goal of the project is to identify whether a person is happy or sad. The project uses Tensorflow-GPU along side OpenCV and Matplotlib inside of a Conda environment. The whole project is written in Jupyter Notebooks.

This Image Classification project can be used for almost any image.

 

Background

Convolutional Neural Networks: Neural Networks specifically used for image recognition.

  • Tensorflow: Is used to create various machine learning models
  • OpenCV: Is an open computer vision module
  • MatplotLib: Is used for visualization

 

Setup

The first step is to install all the dependencies into an Anaconda Environment. We use Anaconda because it makes working with virtual environments easier, especially with Tensorflow.

Then we limit the GPU memory usage of TensorFlow. If the amount of GPUs available is blank, Tensorflow is not installed correctly and why I decided to use a Conda environment.

 

Data Cleaning

Once the setup is complete, we then import the data and clean it.

The data is downloaded from Google using the "Download All Images" extension. This will download all the images which we will clean through afterwords.

Once we have all the images in the data folder. We clean the images with OpenCV. We do this by creating a script that removes any image that does not have the desired extension. We also manually delete any images under 10 KB since these images are too small for our model.

 

Creating Data Pipeline

We load the data into a dataset using keras, creating the pipeline.

We determine the labels for the images by displaying a segment of a batch and crossreferencing the value.

 

Split Data

We Scale all the image between 0 to 1.

Then we split the dataset into batches and assign 70% to testing data, 20% to validation data, and 10% to testing data.

 

Building the Model

We create the CNN Model by using TensorFlow Keras Sequential models.

The neural network has 9 layers, 3 Conv2D layers, 3 MaxPooling2D layers, 1 Flattern layer, and 2 Dense layers. The neural network uses Relu and Sigmoid activation functions.

 

Training and Testing the Model

We train the model with the testing and validation data batches for 20 iterations.

We then plot the accuracy values and the loss values in a graph using Matplotlib for visualization. If the loss function is not decreasing while the accuracy function is increasing, this may be because of a few options:

  • The data is inadequate
  • The data is not accurate
  • The selected model is faulty

Finally, we test the model with the remaining testing batches and verify our results.

 

Saving the Model

The last step in the project is to save the model into the models folder so we can use this for future applications.

In the runModel Jupyter Notebook, we access this model and test it with data the model has never seen before.

 

Conclusion

Now we have a working Image Classification Program using a Convolutional Neural Network. This model can be edited to take in almost any image. In the future, I will be recreating this project by implementing the mathematics and algorithms from scratch. Thank you for your time and interest in this project!

About

Image Classification Project that makes use of a Convolutional Neural Network to identify if a person is happy or sad

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published