A deep learning image classification project that distinguishes between cats and dogs using a MobileNetV2-based convolutional neural network with transfer learning.
- Overview
- Project Objective
- Technologies Used
- Model Architecture
- Dataset
- Project Structure
- Requirements
- Setup
- How to Run
- Model Performance
- Generated Outputs
- Learning Outcomes
- Future Improvements
- Author
- Internship Details
This project is part of the SkillCraft Technology Machine Learning Internship and focuses on binary image classification between cats and dogs.
Workflow:
- Loading and organizing the dataset
- Splitting data into training and validation sets
- Applying data augmentation
- Using MobileNetV2 pretrained on ImageNet
- Adding a custom binary classification head
- Training the model
- Evaluating performance on test data
- Generating classification report and confusion matrix
- Predicting the class of a single image
Build a CNN model capable of classifying whether an image contains a cat or a dog with high accuracy using transfer learning and image preprocessing.
- Python 3
- TensorFlow / Keras
- MobileNetV2
- NumPy
- Scikit-learn
- Matplotlib
- Seaborn
- Transfer Learning
The model uses MobileNetV2 as the feature extractor, with the pretrained base model frozen and a new binary classification layer added on top.
Input Image (160 x 160 x 3)
|
v
Data Augmentation
|
v
MobileNetV2 (ImageNet pretrained)
|
v
Global Average Pooling
|
v
Dropout (0.3)
|
v
Dense Layer (1 unit, Sigmoid)
|
v
CAT / DOG Prediction
The project uses the standard cats-vs-dogs dataset organized as follows:
dataset/
βββ train/
β βββ cats/
β βββ dogs/
βββ test/
β βββ cats/
β βββ dogs/
βββ README.md
Dataset Summary:
| Split | Cats | Dogs | Total |
|---|---|---|---|
| Training | 5,001 | 5,001 | 10,002 |
| Validation | 750* | 750* | 1,500 |
| Testing | 450 | 501 | 951 |
*Validation is created automatically from 15% of the training set during training.
SCT_ML_Task3/
βββ README.md
βββ requirements.txt
βββ dataset/
β βββ train/
β β βββ cats/
β β βββ dogs/
β βββ test/
β βββ cats/
β βββ dogs/
βββ models/
β βββ dogs_cats_mobilenetv2.keras
β βββ dogs_cats_mobilenetv2_final.keras
βββ results/
β βββ cnn_classification_report.txt
β βββ cnn_confusion_matrix.png
β βββ cnn_training_accuracy.png
β βββ cnn_training_loss.png
βββ src/
βββ train_cnn.py
βββ evaluate_cnn.py
βββ predict_cnn.py
Make sure Python 3.10+ is installed, then install dependencies:
pip install -r requirements.txtgit clone https://github.com/VigneshVarsha/SCT_ML-3.git
cd SCT_ML-3Windows PowerShell:
python -m venv .venv
.\.venv\Scripts\Activate.ps1Windows Command Prompt:
python -m venv .venv
.venv\Scripts\activate.batpip install -r requirements.txtpython src/train_cnn.pyThis script:
- Loads the dataset
- Creates the validation split
- Applies augmentation
- Builds the MobileNetV2 model
- Compiles the model
- Trains for 5 epochs
- Saves the trained model in
models/
python src/evaluate_cnn.pyThis generates:
results/cnn_confusion_matrix.pngresults/cnn_classification_report.txt
python src/predict_cnn.py "dataset/test/cats/cat_test_00010.jpg"Example output:
Prediction: CAT
Confidence: 84.93%
Another example:
python src/predict_cnn.py "dataset/test/dogs/dog_test_00019.jpg"The trained model achieved strong results on the test set.
| Metric | Value |
|---|---|
| Test Accuracy | 98.00% |
| Test Loss | 0.0674 |
precision recall f1-score support
cats 0.98 0.98 0.98 450
dogs 0.98 0.98 0.98 501
accuracy 0.98 951
macro avg 0.98 0.98 0.98 951
weighted avg 0.98 0.98 0.98 951
Predicted
Cat Dog
Actual Cat 440 10
Actual Dog 9 492
Interpretation:
- β 440 cats correctly classified as cats
- β 492 dogs correctly classified as dogs
- π 932 correct predictions out of 951 total images
The project creates visual and textual artifacts in the results/ folder:
| File | Description |
|---|---|
cnn_training_accuracy.png |
Training accuracy visualization |
cnn_training_loss.png |
Training loss visualization |
cnn_confusion_matrix.png |
Confusion matrix heatmap |
cnn_classification_report.txt |
Detailed classification metrics |
This project demonstrates:
- Image classification with deep learning
- CNN architecture design
- Transfer learning using MobileNetV2
- Data augmentation for image data
- Binary classification with sigmoid output
- Model evaluation using precision, recall, F1-score, and accuracy
- Prediction on unseen images
- Saving and loading TensorFlow/Keras models
- Fine-tuning deeper MobileNetV2 layers
- Trying additional pretrained architectures (EfficientNet, ResNet, etc.)
- Increasing image resolution
- Experimenting with more augmentation techniques
- Building a web or GUI-based prediction interface
- Deploying the model as an application (Flask/FastAPI/Streamlit)
Devarakonda Vignesh Varsha
| Detail | Information |
|---|---|
| Internship | SkillCraft Technology |
| Domain | Machine Learning |
| Task | Task 03 - Dogs vs Cats Image Classification |
| Final Test Accuracy | 98.00% |
Built with β€οΈ during SkillCraft Technology ML Internship