Skip to content

HarshaBeth/Cats-and-Dogs-CNN-model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Cats vs Dogs Prediction CNN Model

Download dataset from: https://www.kaggle.com/datasets/karakaggle/kaggle-cat-vs-dog-dataset
Make sure to use only the folder "PetImages".


I've built a CNN model that is able to distinguish between cats and dogs with an 81% accuracy. Furthermore, with 10 epochs I managed to reduce the loss and validation loss significantly while preventing overfitting. Now, the CNN model can successfully predict a dog and a cat from the knowledge it has. Our dataset consists of approximately 25k images equally split among the 2 classes.

Imported modules:

  • Pandas
  • Numpy
  • os
  • Tensorflow
  • Matplotlib

  • Firstly, I converted our dataset into a DataFrame using pandas, with 2 columns: Images and Labels. I had to store the images as their relative paths and gave them their respective Label (0=cat, 1=dog). The next step was to split the dataset into training and testing with an 80:20 split. After splitting our data, I performed augmentation and pre-processing using ImageDataGenerator from the TensorFlow library.

    Time to build our model! The model consists of 3 2D Convolution layers, 3 2D Max Pooling layers, Flatten Layer, and Dense layers. Moving forward, we define our optimizer as 'adam', loss, and metrics. This way we bring our model to completion.

    Evaluation

    The following graphs show the accuracy and loss throughout the 10 epochs. image image

    Prediction

    Given such great results it was time to test our model, I chose a random image from our dataset and let the model predict. Below is an example!

    image

    About

    A binary CNN model built to distinguish between a cat and a dog. With the help of this model, we can comprehend the basics and build a foundation towards deep learning.

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

     
     
     

    Contributors