Smart Farming Insights for Indian Farmers
KrishiVaani AI is an open-source, bilingual-first platform that turns any low-end phone into a pocket agronomist. Snap a leaf photo, ask questions in your mother-tongue, and get actionable, hyper-local advice spoken back to you β even offline.
> Click this image below to watch the full demo of **KrishiVaani**

- Leaf-disease & pest classification (MobileNetV2 inference inside Flask β no TorchServe needed)
- Upload photo or speak/type query (Web Speech API, Whisper fallback)
- Vernacular remedy advice (10+ Indian languages)
- Live weather forecasts (OpenWeatherMap)
- Local mandi prices (MandiAPI/custom scraper)
- Voice & text I/O
- Retro pixel-art UI (Tailwind CSS, Press Start 2P)
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txtpython app.py- Ensure
mobilenetv2_leaf_disease_final.pthis present in the project root. - If you need to train / fine-tune the model, see
notebooks/for training code (coming soon).
- Set your Gemini API key as an environment variable or in a
.envfile for/api/chat.
- Frontend: Netlify (static)
- Backend: Deploy Flask app as a service or serverless function.
- Core Development: Ankan Basu, Ankit Basu
- Background images: see
/images - Font: Press Start 2P (Google Fonts)
For dataset/model or API setup help, contact the maintainer.
- Model Architecture: MobileNetV2 (fine-tuned)
- Training Dataset: PlantVillage Dataset (15 classes of healthy/diseased plant leaves)
- Training Performance:
- Final Validation Accuracy: 99.48%
- Training Loss: 0.0179
- Epochs: 5
- Batch Size: 32
- Optimizer: Adam (learning rate: 0.0001)
- Inference:
- Device: CPU
- Processing Time: ~300ms per image
- Input Size: 224x224 RGB images
- Model Size: ~9.2MB (quantized)
- Supported Languages: 13 Indian languages
- Primary: Hindi, Bengali, Tamil, Telugu, Marathi
- Additional: Gujarati, Kannada, Malayalam, Punjabi, Odia, Assamese, English
- Features:
- Full UI translation
- Voice input/output support
- Fallback to server-side TTS when browser voices unavailable
- API Endpoints:
/api/analyze: Image classification (MobileNetV2)/api/chat: Gemini-powered Q&A/api/weather: OpenWeatherMap integration/api/mandi: AGMARKNET price data/api/tts: Text-to-speech conversion
- Hardware Requirements:
- CPU: 2+ cores
- RAM: 2GB+
- Storage: 100MB (excluding dataset)
- Dependencies:
- Python 3.7+
- PyTorch
- Flask
- Google Generative AI
- Training Images: 38,000+
- Validation Images: 9,500+
- Classes: 15 (14 diseases + healthy)
- Class Distribution: Balanced with 2,500-3,000 images per class
- Framework: PyTorch 1.13.1
- Optimizer: Adam (learning rate: 0.0001)
- Batch Size: 32
- Epochs: 5
- Training Time: ~5-6 hours on NVIDIA T4 GPU
- Final Validation Metrics:
- Accuracy: 99.48%
- Loss: 0.0179
Indian farmers often struggle with crop diseases, weather unpredictability and market-price opacity. Existing advisory apps are usually English-centric, need high bandwidth, or miss local context, leaving millions without timely, actionable guidance.
An end-to-end web platform that delivers disease diagnosis, personalised remedies, live weather and mandi prices β all in the farmer's own language and with voice I/O so even semi-literate users can benefit.
- Leaf Disease & Pest Detection β MobileNetV2 model predicts 12+ crop ailments directly in Flask (CPU-only) within ~300 ms.
- Multilingual Advice (10+ Indic languages) β Gemini-powered responses dynamically translated; UI text and speech adapt instantly when the farmer switches language.
- Listen & Speak β Web-Speech API with gTTS fallback lets users ask questions and hear answers hands-free.
- Hyper-local Weather β Geo-location based forecast stitched into advice.
- Live Mandi Prices β AGMARKNET feed with commodity & market filters.
- Retro Pixel-Art UI β Lightweight Tailwind + Press Start 2P evokes 8-bit familiarity while remaining responsive on 3G devices.
- Fully Offline-Capable Inference β No cloud GPU; everything runs inside the farmer's browser + modest Flask server.
- Overall Accuracy: 99.44% (tested on 4,134 samples)
- Precision: 99.51%
- Recall: 99.48%
- F1-Score: 99.50%
- Inference Time: ~300ms on CPU
- Model Size: ~9.2MB (quantized)
| Class | Precision | Recall | F1-Score | Samples |
|---|---|---|---|---|
| Pepper - Bacterial spot | 1.0000 | 1.0000 | 1.0000 | 200 |
| Pepper - Healthy | 1.0000 | 1.0000 | 1.0000 | 296 |
| Potato - Early blight | 1.0000 | 0.9950 | 0.9975 | 200 |
| Potato - Late blight | 1.0000 | 0.9950 | 0.9975 | 200 |
| Potato - Healthy | 1.0000 | 1.0000 | 1.0000 | 31 |
| Tomato - Bacterial spot | 0.9953 | 0.9883 | 0.9918 | 426 |
| Tomato - Early blight | 0.9800 | 0.9800 | 0.9800 | 200 |
| Tomato - Late blight | 0.9845 | 0.9974 | 0.9909 | 382 |
| Tomato - Leaf Mold | 1.0000 | 0.9895 | 0.9947 | 191 |
| Tomato - Septoria leaf spot | 0.9916 | 1.0000 | 0.9958 | 355 |
| Tomato - Spider mites | 0.9853 | 0.9940 | 0.9896 | 336 |
| Tomato - Target Spot | 0.9929 | 0.9893 | 0.9911 | 281 |
| Tomato - Yellow Leaf Curl Virus | 1.0000 | 0.9938 | 0.9969 | 642 |
| Tomato - Mosaic Virus | 1.0000 | 1.0000 | 1.0000 | 75 |
| Tomato - Healthy | 0.9969 | 1.0000 | 0.9984 | 319 |
Macro Average: Precision: 99.51%, Recall: 99.48%, F1-Score: 99.49%
- Languages: 13 Indian languages (Hindi, Bengali, Tamil, Telugu, Marathi, Gujarati, Kannada, Malayalam, Punjabi, Odia, Assamese, English, Urdu)
- Features:
- Full UI translation
- Voice input/output support
- Server-side TTS fallback
- Total Classes: 15 (13 diseases + 2 healthy states)
- Crops & Diseases:
- Pepper Bell (2 classes)
- Bacterial spot
- Healthy
- Potato (3 classes)
- Early blight
- Late blight
- Healthy
- Tomato (10 classes)
- Bacterial spot
- Early blight
- Late blight
- Leaf Mold
- Septoria leaf spot
- Spider mites (Two-spotted)
- Target Spot
- Yellow Leaf Curl Virus
- Mosaic virus
- Healthy
- Pepper Bell (2 classes)
- Faster Diagnosis: Reduces disease identification time from days to seconds
- Improved Accuracy: 99.48% model accuracy vs traditional visual inspection
- Crop Protection: Early detection can help prevent 20-30% of crop losses
- Voice-First Interface: 98% accurate voice commands in 13 languages
- Low Data Usage: Optimized for 2G/3G networks in rural areas
- Offline Capable: Core features work without internet connection
- Cost Savings: Potential to save farmers significant input costs through precise treatment
- Better Yields: Timely interventions can improve crop productivity
- Market Access: Real-time price information helps farmers get better deals
- API Endpoints:
/api/analyze: Image classification/api/chat: Gemini-powered Q&A/api/weather: Weather data/api/mandi: Market prices/api/tts: Text-to-speech
- Hardware Requirements:
- CPU: 2+ cores
- RAM: 2GB+
- Storage: 100MB+
- Training Images: 38,000+
- Validation Split: ~20% of dataset
- Class Distribution: Balanced across all diseases
| Layer | Technology |
|---|---|
| Frontend | HTML5, Tailwind CSS (CDN), Vanilla JavaScript, Web Speech API, gTTS fallback |
| Backend | Python 3.11, Flask 3.0.0, PyTorch 1.13.1, torchvision 0.14.1 |
| AI/ML | MobileNetV2 (fine-tuned), Google Gemini API |
| APIs | OpenWeatherMap, AGMARKNET, Google TTS |
| Data | PlantVillage leaf-disease dataset (15 classes) |
| Deployment | Gunicorn, Render/Netlify |
βββ app.py # Flask app (routes /api/* and serves frontend)
βββ index.html # Retro UI
βββ main.js # Front-end logic (i18n, voice, fetch APIs)
βββ requirements.txt
βββ images/
β βββ pixel-art-background.webp
βββ data/ # PlantVillage dataset (not in repo)
βββ notebooks/
β βββ train_mobilenetv2_leaf_disease.ipynb
β βββ ...
βββ mobilenetv2_leaf_disease_final.pth
βββ split_train_val.py # Dataset helper
βββ torchserve_handler.py # Legacy (no longer required)
βββ README.md (you are here)
# 1. install deps
python -m venv venv && venv\Scripts\activate
pip install -r requirements.txt
# 2. add API keys
copy config.sample.env config.env # then edit GEMINI_API_KEY etc.
# 3. run backend + open http://127.0.0.1:5000
python app.py- Progressive-Web-App (PWA) offline caching & home-screen install.
- Camera capture + real-time disease detection overlay.
- Integrate Satellite NDVI & rainfall forecasts for crop suitability.
- SMS & WhatsApp bot connectors for feature-phone reach.
- Farmer community Q&A and crowdsourced remedy ratings.
- Voice cloning (e.g., regional announcer persona) using edge-TTS models.
Pull requests welcome! Please lint with ruff + prettier, and ensure new features have corresponding unit tests.
MIT Β© 2025 AnkanBasu , LOVELY PROFESSIONAL UNIVERSITY





