🌿 MobileNetV3 — Medicinal Leaf Classification
A fine-tuned MobileNetV3Large model that classifies images of medicinal plant leaves into 3 categories: Aloe Vera, Neem, and Tulsi.
Model Details
| Property | Value |
|---|
| Base Model | MobileNetV3Large (ImageNet weights) |
| Framework | TensorFlow / Keras |
| Input Size | 224 × 224 × 3 |
| Output Classes | 3 (Aloe Vera, Neem, Tulsi) |
| Format | .keras (Keras native) |
Classes
| Index | Class |
|---|
| 0 | Aloe Vera |
| 1 | Neem |
| 2 | Tulsi |
⚠️ Important: Class order is alphabetical — ['Aloe Vera', 'Neem', 'Tulsi']. Use this exact order when decoding predictions.
Performance (920 test images)
| Model Variant | Accuracy |
|---|
last_40_dense_batchnorm ⭐ | 99% |
last_100_layers_more_layers ⭐ | 99% |
last_20 | 88% |
last_40_d05 | 88% |
last_100_d05 | 86% |
last_40 | 85% |
Best model (last_40_dense_batchnorm) — classification report: | |
| Class | Precision |
| ------- | ----------- |
| Aloe Vera | 1.00 |
| Neem | 0.99 |
| Tulsi | 1.00 |
| Overall | 0.99 |
Usage
import tensorflow as tf
import numpy as np
from tensorflow.keras.preprocessing import image
# Load model
model = tf.keras.models.load_model("last_40_layers_dense_batchnorm.keras")
class_names = ['Aloe Vera', 'Neem', 'Tulsi'] # alphabetical order
def predict(img_path):
img = image.load_img(img_path, target_size=(224, 224))
img_array = image.img_to_array(img)
img_array = np.expand_dims(img_array, axis=0) # shape: (1, 224, 224, 3)
pred = model.predict(img_array)[0]
pred_class = class_names[np.argmax(pred)]
confidence = float(np.max(pred))
return pred_class, confidence
label, conf = predict("your_leaf_image.jpg")
print(f"Prediction: {label} ({conf:.2%} confidence)")
Training Details
- Fine-tuning strategy: Last 40 layers of MobileNetV3Large unfrozen
- Head:
GlobalAveragePooling2D → Dropout(0.2) → Dense(3, softmax) + BatchNorm variant
- Phase 1: Head-only training — 10 epochs, lr=0.001
- Phase 2: Fine-tuning — 15 epochs, lr=1e-5
- Loss: Categorical Cross-Entropy
- Batch size: 32
- Train/Val split: 80/20 (5904 train / 1476 val images)