A convolutional neural network (CNN)-based deep learning model that classifies images of dogs and cats using TensorFlow and Keras.
This project demonstrates a simple deep learning workflow using a Convolutional Neural Network (CNN) to distinguish between dog and cat images. It includes data preprocessing, model building, training, evaluation, and prediction on custom inputs.
- Python
- TensorFlow / Keras – For building and training the CNN
- OpenCV – For image loading and preprocessing
- NumPy / Matplotlib – For array handling and visualization
- Jupyter Notebook – For development and experimentation
-
Dog_vs_Cat_CNN.ipynb
Jupyter Notebook containing the full code for:- Loading and preprocessing image data
- Creating and training the CNN model
- Evaluating accuracy and loss
- Making predictions on test data
-
dataset/
Contains training and test images of dogs and cats, typically structured as:dataset/ └── train/ ├── cats/ └── dogs/ └── test/
-
Data Preparation
Images are resized and normalized. They are labeled automatically based on directory structure (cats/ordogs/). -
Model Architecture
A basic CNN with convolutional, max-pooling, and dense layers. Compiled withbinary_crossentropyloss for binary classification. -
Training
Model is trained over multiple epochs, with accuracy and loss visualized using plots. -
Prediction
Custom images can be passed through the model to predict if it's a dog or a cat.
-
Clone the repository:
git clone https://github.com/sjapanjots/Dog_Vs_Cat_Deep_Learning.git cd Dog_Vs_Cat_Deep_Learning -
Install required packages:
pip install tensorflow opencv-python matplotlib numpy jupyter
-
Launch the notebook:
jupyter notebook
-
Open
Dog_vs_Cat_CNN.ipynband run all cells.
-
Input: Random image of a dog
-
Output: Predicted: Dog
-
Input: Random image of a cat
-
Output: Predicted: Cat
Japanjot Singh
Data Scientist & ML Enthusiast
📬 sjapanjots@gmail.com