A complete end-to-end Modular Deep Learning project that performs binary image classification (Cat vs Dog) using multiple CNN architectures.
The project compares custom-built and pre-trained models, selects the best-performing model, and based on classification accuracy, and provides an interactive Streamlit-based user interface for model inference.
🏆 Best Model: ResNet-18
📈 Test Accuracy: 99%
🧠 Models Used: LeNet-5 (from scratch), AlexNet, ResNet-18
- Why This Project Exists
- Project Highlights
- Models Used
- Workflow
- Technologies Used
- Project Structure
- Setup Instructions
- Deployment
Most beginner-level Cat vs Dog projects:
- Use only one pre-trained model
- Treat CNNs as a black box
- Lack modular code structure
This project was built to go beyond that.
- Understand CNN architectures deeply by implementing LeNet-5 from scratch
- Compare multiple CNN models fairly under the same training conditions
- Apply software engineering best practices (modularity, reusability)
📌 Focus: Learning-oriented, scalable, and resume-ready Deep Learning project.
- Implemented LeNet-5 CNN architecture from scratch
- Used AlexNet and ResNet-18 for comparison
- All models trained for 2 epochs only to ensure fair comparison
- Best model selected based on validation accuracy
- ResNet-18 achieved 99% accuracy
- Automatically selected as the final inference model
- Separate modules for:
- Model definitions
- Training logic
- Evaluation
- Inference
- Clean, readable, and scalable structure
- Interactive UI for image upload
- Real-time prediction (Cat or Dog)
- Lightweight and user-friendly interface
- Fully implemented CNN architecture
- Custom convolutional, pooling, and fully connected layers
- Built for learning and architectural understanding
- Deeper CNN with higher representational capacity
- Used for performance comparison
- Residual connections to solve vanishing gradient problem
- Achieved 99% accuracy
- Selected as final production model
-
Data Loading
- Images loaded from train/test directories
- Standard preprocessing applied
-
Model Training
- Train LeNet-5, AlexNet, and ResNet-18
- Fixed training epochs (2) for fair comparison
-
Evaluation
- Accuracy calculated for each model
- Best model selected automatically
-
Inference
- Saved best model weights
- Used for real-time prediction in Streamlit app
-
Deployment
- Streamlit UI deployed on Streamlit Cloud
- Python
- PyTorch
- Torchvision
- NumPy
- LeNet-5 (Custom implementation)
- AlexNet
- ResNet-18
- Streamlit – UI development
- Streamlit Cloud – Deployment platform
- Jupyter Notebook – Experiments & training
- Git & GitHub – Version control
CAT VS DOG CLASSIFIER/
│
├── configs/
│
├── models/
│ ├── init.py
│ ├── lenet5.py
│ └── model_factory.py ← Factory of models (LeNet, alexnet, ResNet)
│
├── NoteBook/
│ ├── Cat_vs_Dog_Classifier.ipynb
│
├── training/
│ ├── init.py
│ ├── evaluate.py
│ ├── train_all_models.py
│ └── train_utils.py
│
│
├── .gitignore
├── app.py ← Application entry point
├── inference.py
├── README.md
└── requirements.txt
To run this project locally, ensure you have the following installed:
- Python 3.8+
- Git
- Virtual environemnt (recommended)
-
Clone the Repository:
git clone https://github.com/Umer2900/Cat-vs-Dog-Classifier cd Cat-vs-Dog-Classifier -
Install Dependencies:
python -m venv venv venv\Scripts\activate # Windows
-
Install Streamlit App:
pip install -r requirements.txt
-
Run the Application:
streamlit run app.py
The app will be available at 🌐
http://localhost:8501.
