This is a deep learning project developed from scratch to classify images of cats and dogs using a Convolutional Neural Network (CNN). The goal is to train a model that can take an image as input and accurately predict whether it's a cat or a dog.
- Built using TensorFlow and Keras
- Trained on a dataset of 10,000+ images
- Includes scripts for training and prediction
- Supports image input via OpenCV
- Model saved in HDF5 (.h5) format for reuse
- Visualization of test images and predictions using Matplotlib
- Dataset/
- train/
- test/
- dog_cat_model.h5
- cat-dog-classification.py
- train_model.py
This project was built and tested on an Ubuntu environment.
- tensorflow==2.19.0
- keras==3.9.2
- opencv-python==4.11.0.86
- matplotlib==3.10.1
- numpy==2.1.3
- h5py
- protobuf
- absl-py
- and more...
All required packages are listed in the requirements list in your environment.
- Train the model using the
train_model.py
script. - Save the trained model as
dog_cat_model.h5
. - Use
predict.py
to load the saved model and predict new images. - Ensure that test images are correctly placed and accessible.
The model returns either:
- "Cat" if the image is classified as a cat
- "Dog" if the image is classified as a dog
A visual output of the prediction image will also be displayed using Matplotlib.
- Make sure you deactivate your virtual environment using
deactivate
before pushing to GitHub (do not push the venv folder). - Ensure image paths are valid and images are readable before running prediction.