VGG16 Transfer Learning — 7-class image classifier (flowers + gender detection) with FastAPI backend & React UI. 86% accuracy trained on T4 GPU
| Category | Details |
|---|---|
| Architecture | VGG16 (Transfer Learning from ImageNet) |
| Framework | TensorFlow / Keras |
| Training | Google Colab T4 GPU |
| Epochs | 20 (EarlyStopping + ReduceLROnPlateau) |
| Accuracy | 86.27% validation accuracy |
| Dataset | 6,300+ images across 7 classes |
| Class | Type | Count |
|---|---|---|
| 🌼 Daisy | Flower | ~764 |
| 🌱 Dandelion | Flower | ~1052 |
| 🌹 Rose | Flower | ~784 |
| 🌻 Sunflower | Flower | ~733 |
| 🌷 Tulip | Flower | ~984 |
| 👨 Male | Gender | ~1000 |
| 👩 Female | Gender | ~1000 |
- 📸 Real-time image classification — upload any image and get instant predictions
- 📊 Confidence scores — probability breakdown for all 7 classes
- 🎨 Modern React UI — dark navy theme with animated progress bars
- ⚡ FastAPI backend — high-performance REST API with image validation
- 🧠 Transfer Learning — VGG16 pretrained on ImageNet, fine-tuned for custom classes
- 🔄 Data Augmentation — rotation, zoom, flip for better generalization
- 🖱️ Drag & Drop — drag and drop image upload support
ML & Backend
Frontend
vgg16-classifier/
├── backend/
│ ├── api/
│ │ └── routes.py # FastAPI endpoints
│ ├── core/
│ │ └── config.py # App configuration
│ ├── ml/
│ │ ├── inference/
│ │ │ └── predictor.py # Model inference
│ │ ├── model/
│ │ │ └── vgg16_model.py # Model architecture
│ │ └── preprocessing/
│ │ └── preprocess.py # Image preprocessing
│ └── main.py # FastAPI app entry point
├── frontend/
│ └── src/
│ └── App.jsx # React frontend
├── models/
│ └── saved/ # Trained model files (not tracked)
├── data/
│ └── raw/ # Dataset (not tracked)
├── logs/ # Training plots
├── notebooks/ # Jupyter notebooks
└── requirements.txt
- Python 3.10+
- Node.js 18+
- TensorFlow 2.17+
git clone https://github.com/Hamzah1507/Image-Classification-using-VGG16.git
cd Image-Classification-using-VGG16python -m venv venv
venv\Scripts\activate # Windows
pip install -r requirements.txtDownload trained model and place in models/saved/:
vgg16_final.kerasclass_names.json
python -m backend.main
# API running at http://localhost:8000
# Swagger docs at http://localhost:8000/docscd frontend
npm install
npm run dev
# UI running at http://localhost:5173| Method | Endpoint | Description |
|---|---|---|
GET |
/api/ |
Health check |
POST |
/api/predict |
Upload image → get prediction |
curl -X POST "http://localhost:8000/api/predict" \
-H "accept: application/json" \
-F "file=@sunflower.jpg"{
"predicted_class": "sunflower",
"confidence": 99.2,
"all_predictions": {
"daisy": 0.12,
"dandelion": 0.28,
"rose": 0.0,
"sunflower": 99.2,
"tulip": 0.4,
"male": 0.0,
"female": 0.0
}
}Training was done on Google Colab T4 GPU using ImageDataGenerator for memory-efficient batch loading.
Train/Val Split : 80% / 20%
Batch Size : 32
Image Size : 224 × 224
Optimizer : Adam (lr=0.0001)
Loss : Sparse Categorical Crossentropy
Callbacks : ModelCheckpoint, EarlyStopping (patience=5), ReduceLROnPlateau
Training Results:
Best Epoch : 18/20
Val Accuracy : 86.27%
Train Accuracy : 92.20%
This project is licensed under the MIT License — see the LICENSE file for details.