End-to-end image classification project using TensorFlow and MobileNetV2.
This project demonstrates a complete deep learning workflow: data ingestion, preprocessing, baseline modeling, transfer learning, evaluation, model export, and inference.
Objective:
Build an accurate image classifier using a pretrained convolutional neural network and evaluate its performance on unseen data.
Key Techniques:
- Convolutional Neural Networks (CNNs)
- Transfer Learning with MobileNetV2 (ImageNet weights)
tf.datapipelines for efficient input processing- Model evaluation with accuracy, confusion matrix, and classification report
- Exporting models for reuse and inference
Dataset:
CIFAR-10 (10 image classes, loaded via tensorflow_datasets)
image-classifier-tensorflow/
│
├── notebooks/
│ └── 01_image_classifier_end_to_end.ipynb
│
├── src/
│ └── inference.py
│
├── models/
│ ├── keras/ # exported .keras models (ignored by git)
│ └── class_names.json
│
├── reports/
│ ├── figures/ # confusion matrix, training curves, prediction grids
│ └── metrics/ # classification report + metrics JSON
│
├── requirements.txt
├── .gitignore
└── README.md
- CIFAR-10 loaded using
tensorflow_datasets - Train / validation / test splits created
- Resize images to model input size
- Normalize pixel values to
[0, 1] - Build efficient
tf.datapipelines
- Lightweight CNN trained from scratch
- Used as a performance reference
- MobileNetV2 pretrained on ImageNet
- Backbone frozen, custom classification head trained
- Callbacks for early stopping and learning-rate scheduling
- Accuracy on validation and test sets
- Confusion matrix
- Precision / recall / F1-score per class
- Model exported in
.kerasformat - CLI inference script for predictions on new images
Transfer Learning – MobileNetV2 (Frozen Backbone)
- Validation Accuracy: high 80s / low 90s (varies by run)
- Test Accuracy: comparable to validation
-
Confusion Matrix:
reports/figures/confusion_matrix_mobilenetv2_frozen.png -
Training Curves:
reports/figures/mobilenetv2_frozen_accuracy.pngreports/figures/mobilenetv2_frozen_loss.png
-
Classification Report:
reports/metrics/classification_report_mobilenetv2_frozen.txt
python -m venv .venv
.venv\Scripts\activate # Windows
pip install -r requirements.txt
Open and run:
notebooks/01_image_classifier_end_to_end.ipynb
This notebook:
-
trains the baseline and transfer learning models
-
evaluates performance
-
exports the trained model
-
saves all figures and metrics
Use the exported .keras model to run predictions from the command line.
python src/inference.py \
--model models/keras/<your_model>.keras \
--num 9 \
--save-grid reports/figures/pred_grid.png-
loads the trained model
-
runs inference on CIFAR-10 test images
-
prints predictions + confidence scores
-
saves a grid of predicted images (optional)
-
Python
-
TensorFlow / Keras
-
TensorFlow Datasets
-
NumPy
-
Matplotlib
-
scikit-learn
-
Fine-tune upper MobileNetV2 layers for additional accuracy gains
-
Add custom dataset support for real-world images
-
Package inference as a lightweight API or web demo
-
Experiment with alternative pretrained backbones (EfficientNet, ResNet)
Juante Wilson Aspiring Applied Data Scientist / Machine Learning Engineer Focused on end-to-end ML projects and AWS-centric workflows