Skip to content

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.

Notifications You must be signed in to change notification settings

ankan123basu/KrishiVaaniAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

48 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

KrishiVaani

License: MIT

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.

πŸŽ₯ Demo YouTube Video of my Project

> Click this image below to watch the full demo of **KrishiVaani** KrishiVaani Demo Video

πŸ“Έ Screenshots

Screenshot 2025-06-25 200033

Screenshot 2025-06-27 203627

image image

image

image

image

image

Screenshot 2025-06-25 195112 Screenshot 2025-06-25 195001

Features

  • 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)

Getting Started

1. Install dependencies

python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt

2. Run Flask backend

python app.py

3. Open index.html in your browser


Model Setup (for /api/analyze)

  • Ensure mobilenetv2_leaf_disease_final.pth is present in the project root.
  • If you need to train / fine-tune the model, see notebooks/ for training code (coming soon).

Environment Variables

  • Set your Gemini API key as an environment variable or in a .env file for /api/chat.

Deployment

  • Frontend: Netlify (static)
  • Backend: Deploy Flask app as a service or serverless function.

Credits

  • 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 Performance & Technical Specifications

Disease Detection Model

  • 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)

Language Support

  • 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

System Performance

  • 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

Dataset Statistics

  • Training Images: 38,000+
  • Validation Images: 9,500+
  • Classes: 15 (14 diseases + healthy)
  • Class Distribution: Balanced with 2,500-3,000 images per class

Model Training

  • 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

πŸ“œ Problem Statement

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.

πŸ’‘ Solution – KrishiVaani AI

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.

✨ Unique Features

  • 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.

πŸš€ Project Impact & Metrics

Verified Metrics

Model Performance

  • 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)

Detailed Classification Metrics (F1-Scores)

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%

Language Support

  • 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

Disease Coverage

  • 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

Potential Impact

Agricultural Benefits

  • 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

User Experience

  • 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

Economic Impact

  • 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

System Performance

  • 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+

Dataset Statistics

  • Training Images: 38,000+
  • Validation Split: ~20% of dataset
  • Class Distribution: Balanced across all diseases

πŸ› οΈ Tech Stack

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

πŸ“‚ Directory Structure

β”œβ”€β”€ 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)

πŸš€ Quick Start

# 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

πŸ›£οΈ Roadmap / Future Enhancements

  • 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.

🀝 Contributing

Pull requests welcome! Please lint with ruff + prettier, and ensure new features have corresponding unit tests.

πŸ“„ License

MIT Β© 2025 AnkanBasu , LOVELY PROFESSIONAL UNIVERSITY

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •