CASE STUDY
BANANA LEAF DETECTOR
A premium Flask web application featuring active learning and computer vision to detect banana leaf diseases. Achieves 95% model accuracy with instant local model retraining.
The Problem
The Problem
Traditional ML crop diagnostic tools rely on heavy Deep Learning models that are expensive to run and slow on low-bandwidth rural connections. Additionally, farmers had no way to correct the model when it was wrong, meaning false positives would persist indefinitely.
The Decision
The Decision
Lightweight Feature Engineering
Lightweight Feature Engineering
To bypass the need for a CNN, I built a custom pipeline using OpenCV and Scikit-Image to extract 59 unique color, texture, and structural features from leaf photos. These dense vectors are passed to a lightweight K-Nearest Neighbors (k=5) classifier. To fix the feedback issue, I engineered a closed-loop retraining thread where user corrections instantly append to Firestore and retrain the local KNN model in under 200ms.
Core Tech Stack
Core Tech Stack
scikit-learn (KNN)
OpenCV & scikit-image
Flask (Python)
Firestore (NoSQL)
The Outcome
The Outcome
Impact & Performance
Impact & Performance
The engineered 59-dimensional feature matrix allowed the KNN model to achieve 95% model accuracy in testing. By avoiding heavy deep learning dependencies, the active learning pipeline runs flawlessly on lightweight edge servers. Corrected predictions converge into the live model in less than 200ms, creating a constantly improving diagnostic tool without manual developer intervention.
Model Metrics
Model Metrics
Performance Statistics
Performance Statistics
Test Accuracy: 91.13% (across 451 test samples)
Training Samples: 1802 (after class balancing)
Healthy Leaf Precision: 0.91, Recall: 0.95
Unhealthy Leaf Precision: 0.88, Recall: 0.90
Hyperparameters: K=5, distance weighting
What do these metrics mean in practice? The 91.13% Test Accuracy indicates that out of 451 unseen images, the model correctly identified over 9 out of 10. The high Recall scores (0.95 for Healthy, 0.90 for Unhealthy) are crucial for farming diagnostics—it means the system successfully detects 90% of actual diseased leaves without missing them (low false negatives). By using Distance Weighting (K=5), the classifier looks at the 5 most mathematically similar leaf patterns in the database, prioritizing the closest matches to ensure robust predictions against visual outliers.
Confusion Matrix
Confusion Matrix

Features
Features
Active Learning Real-time Loop
Active Learning Real-time Loop
Integrates a closed-loop active learning system where classifier errors are immediately corrected by the user. The corrected sample's 59-dimensional feature matrix is dynamically appended to the training set and triggers background scikit-learn KNN (k=5) model retraining in under 200ms with live model weights updates in-process, allowing continuous classifier improvements.
Multi-Dimensional CV Feature Pipeline
Multi-Dimensional CV Feature Pipeline
Extracts 59 unique color, texture, and structural features from uploaded crop images on-the-fly. Leverages Grey-Level Co-occurrence Matrices (GLCM) with 64 levels at a pixel distance of 5 for texture, Local Binary Patterns (LBP) with P=8 and R=1 for disease-spot boundaries, and HSV/LAB color Moments alongside a 16-bin Hue histogram for rapid chlorosis screening.
Performance
Performance
Predictive Latency: < 80ms for complete OpenCV feature extraction and KNN classification on local hosts.
In-Process Retraining Convergence: < 200ms background scikit-learn KNN fit cycle following user correction events.
Edge Friendly Footprint: Bypasses heavy deep learning dependencies, allowing the entire application and active learning pipeline to run smoothly on extremely lightweight compute servers.
Analytical Load Times: Highly-optimized NoSQL database schema enables instant aggregation of thousands of historical scan entries for Chart.js canvas elements.