Skip to content

srimjam27/dog_vs_cat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

Dog vs Cat Image Classifier using Convolutional Neural Networks (CNN)

Introduction

This project implements a Convolutional Neural Network (CNN) to classify images of dogs and cats. The model is trained using TensorFlow and Keras, and it leverages the OpenCV (cv2) library for image preprocessing.

Requirements

  • Python 3.x
  • TensorFlow 2.x
  • Keras
  • OpenCV (cv2)

Dataset

The model is trained on a dataset consisting of labeled images of dogs and cats. The dataset was preprocessed using OpenCV to resize images to a uniform size (256x256 pixels) and normalize pixel values.

Model Architecture

The CNN model architecture used for this classification task is as follows:

  1. Convolutional Layers:

    • 3 convolutional layers with increasing filter sizes (32, 64, 128) and ReLU activation.
    • Each convolutional layer is followed by Batch Normalization and Max Pooling to extract features and reduce spatial dimensions.
  2. Flatten Layer:

    • Flattens the 3D output from the convolutional layers into a 1D vector to be fed into the dense layers.
  3. Dense Layers:

    • 2 fully connected dense layers with ReLU activation (128 units, 64 units) and dropout regularization (0.1).
    • Final output layer with 1 unit and sigmoid activation function for binary classification (dog or cat).
  4. Model Compilation:

    • Loss function: Binary Crossentropy
    • Optimizer: Adam
    • Metrics: Accuracy

Training

The model is trained on a GPU-enabled environment to expedite training due to the complexity of convolutional operations and the size of the dataset.

Evaluation

The performance of the model is evaluated using metrics such as accuracy, precision, recall, and F1-score on a separate test dataset.

Usage

  1. Data Preparation:

    • Ensure your images are organized into 'dog' and 'cat' folders or labeled accordingly.
  2. Model Training:

    • Use the provided script or Jupyter Notebook to train the model on your dataset.
  3. Model Evaluation:

    • Evaluate the trained model on a separate test dataset to assess its performance metrics.
  4. Inference:

    • Use the trained model to classify new images of dogs and cats.

Future Improvements

  • Fine-tuning hyperparameters (learning rate, batch size, etc.) for better performance.
  • Experimenting with different CNN architectures (e.g., VGG, ResNet) for improved accuracy.
  • Data augmentation techniques to enhance model generalization.

Author

  • Srijan Singh

References


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors