🌾 AgriScan – AI-Powered Crop Disease Detection
Inspiration
Agriculture is the backbone of our food supply, yet millions of farmers lose crops each year due to late detection of plant diseases. Many small-scale farmers lack access to agricultural experts, leaving them vulnerable to crop failures. We wanted to build a fast, accessible, and intelligent solution that could help farmers detect plant diseases early — all from a simple smartphone camera. Our inspiration came from seeing how AI in healthcare has revolutionized diagnostics, and we thought:
“Why not bring this power to the fields?”
What I Learned
- Model Training: We learned to train a custom CNN model using TensorFlow/Keras and transfer learning with MobileNetV2 for lightweight performance on web apps.
- Dataset Handling: We explored the PlantVillage dataset and preprocessed thousands of leaf images with data augmentation (rotation, brightness, flipping).
- Full-Stack AI Integration: We mastered connecting ML models with a backend API (Flask) and deploying them for real-time inference on the web.
- Explainability in AI: We implemented Grad-CAM heatmaps to visualize which part of the leaf image influenced the model’s decision.
How I Built It
- Data Collection & Preprocessing
- Used PlantVillage Dataset with 50,000+ leaf images across various crops.
- Preprocessed data using
OpenCVandimgaugfor image augmentation.
- Model Development
- Built a Convolutional Neural Network (CNN) using TensorFlow/Keras.
- Trained on Google Colab using GPU acceleration.
- Final model achieved 92% accuracy on the test set.
$\text{Accuracy} = \frac{\text{Correct Predictions}}{\text{Total Predictions}}$
- Backend (Flask API)
- Exposed a
/predictendpoint that takes an uploaded image and returns the detected disease with confidence score.
- Frontend (Web App)
- Developed a responsive interface using HTML, TailwindCSS, and JavaScript.
- Integrated real-time image upload & results visualization.
- Deployment
- Hosted backend on Render and static frontend on Vercel.
- Optionally deployed the model on Hugging Face Spaces (Gradio) for live demos.
Challenges I Faced
- Model Overfitting: Initial models overfit due to limited data variety, solved by heavy augmentation and dropout layers.
- Lightweight Deployment: Serving large ML models on the web was tricky — we optimized using quantization and MobileNetV2.
- Real-World Testing: Some images from farmers were noisy (blurred or bad lighting), so we added preprocessing filters before prediction.
- SPA Routing Issues: We fixed routing on deployment using a JSON rewrites rule:
{ "rewrites": [ { "source": "/(.*)", "destination": "/" } ] }
What’s Next for AgriScan?
- Adding offline mode (PWA) with TensorFlow.js for on-device inference.
- Expanding the model to detect nutrient deficiencies and pest infestations.
- Integrating multi-language support for rural farmers.
- Building a community dashboard to track crop disease trends globally.
Built With
- batchfile
- css
- html
- javascript
- phthon
- shell
Log in or sign up for Devpost to join the conversation.