Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KisanDoc

KisanDoc — AI Crop Disease Diagnosis

Your Crop's Doctor — Offline-first diagnosis for Indian farmers


Flutter TensorFlow Lite Works Offline Android Languages License


Built for the 2.5 crore small farmers of Odisha — where internet is unreliable,
literacy rates are 60-65%, and one lost harvest can devastate a family.


Features · Architecture · Quick Start · Disease Database · ML Model · Contributing


🌾 The Problem We're Solving

Reality Impact
₹18,000 avg. annual income of an Odisha small farmer Zero margin for error
60-65% rural literacy rate Can't rely on text-heavy apps
Patchy or zero internet in rural areas Cloud AI won't work
Wrong pesticide = wasted money + crop damage Need reliable, expert-grade advice

KisanDoc puts a crop doctor in every farmer's pocket — AI that works without internet, speaks their language, and tells them exactly what to spray, how much, and at what cost.


✨ Features

🧠 On-Device AI Diagnosis

  • MobileNetV2 TFLite model — zero internet needed
  • 15 disease classes across 6 crops
  • Top-3 suggestions when confidence < 75%
  • < 200ms inference on mid-range Android

📊 Severity Estimation

  • HSV color segmentation on each image
  • Classifies: Mild / Moderate / Severe
  • Drives treatment dosage recommendations

💊 Treatment Plans

  • Severity-specific pesticide recommendations
  • Exact dosage + estimated cost in INR
  • Data sourced from ICAR & NIPHM guidelines

🔊 Voice Readout (TTS)

  • Full diagnosis read aloud in 3 languages
  • English, Hindi, Odia (ଓଡ଼ିଆ)
  • Designed for low-literacy users

📚 Diagnosis History

  • Local storage via Hive (no cloud sync)
  • Swipe-to-delete records
  • Fully offline & private

🗺️ Find Help Nearby

  • GPS + Google Maps for agri-input shops
  • Directory of all 32 KVK offices in Odisha
  • One-tap call to extension officers

🏗️ Architecture

📸 Farmer takes a photo
        │
        ├─────────────────────────────────────────┐
        │                                         │
        ▼                                         ▼
 🧠 ML Service (TFLite)               🎨 Severity Service (HSV)
 ─────────────────────                ─────────────────────────
 • Resize → 224×224                   • Resize → 128×128
 • Normalize to [0, 1]                • RGB → HSV per pixel
 • MobileNetV2 inference              • Mask: background / healthy / diseased
 • Top-1 (or Top-3 if < 75%)         • Ratio → Mild / Moderate / Severe
        │                                         │
        └────────────────┬────────────────────────┘
                         │
                         ▼
            📖 Disease Database Lookup
            (ICAR + NIPHM reviewed data)
                         │
                         ▼
            ✅ Diagnosis Result Screen
            ├── Disease name (EN / HI / OR)
            ├── Confidence score
            ├── Severity level
            ├── Pesticide + dosage + cost (INR)
            ├── 🔊 Voice readout
            └── 💾 Save to local history (Hive)

🚀 Quick Start

Prerequisites

Tool Version
Flutter & Dart 3.16+ / 3.0+
IDE Android Studio or VS Code + Flutter plugin
Python (for model) 3.9+
Device Android 8.0+, 2 GB RAM minimum

Step 1 — Clone the repository

git clone https://github.com/YOUR_USERNAME/kisandoc.git
cd kisandoc

Step 2 — Install Flutter dependencies

flutter pub get

Step 3 — Train and export the TFLite model

You have two options depending on your goal:

Option A — Synthetic demo model (fast, tests the pipeline)

pip install tensorflow tensorflow-hub pillow numpy
python scripts/model_conversion.py
# Output: assets/model/kisandoc.tflite (~14 MB)

Option B — Real PlantVillage model (recommended for production, ~92% accuracy)

# 1. Download the dataset from Kaggle:
#    https://www.kaggle.com/datasets/vipoooool/new-plant-diseases-dataset
# 2. Extract to: scripts/plantvillage/
# 3. Train:
python scripts/model_conversion.py --use-real-data --data-path scripts/plantvillage/

Why two options?
The synthetic model lets you verify the full Flutter pipeline (inference → UI → storage) instantly. The PlantVillage model gives real-world accuracy but requires the dataset download (~2 GB).

Step 4 — Verify assets

ls assets/model/    # ✅ kisandoc.tflite
ls assets/labels/   # ✅ labels.txt

Step 5 — Run the app

# List connected devices
flutter devices

# Run in debug mode (USB debugging must be enabled on your phone)
flutter run

# Build a release APK
flutter build apk --release
# → build/app/outputs/flutter-apk/app-release.apk

📊 Disease Database

15 diseases with complete, ICAR-reviewed treatment protocols.

Crop Disease Type
🌾 Rice Blast Fungal
🌾 Rice Brown Spot Fungal
🌾 Rice Bacterial Leaf Blight Bacterial
🌿 Wheat Stem Rust Fungal
🌿 Wheat Powdery Mildew Fungal
🍅 Tomato Early Blight Fungal
🍅 Tomato Late Blight Oomycete
🍅 Tomato Leaf Curl Virus Viral
🥔 Potato Late Blight Oomycete
🥔 Potato Black Scurf Fungal
🌽 Maize Leaf Spot Fungal
🌽 Maize Common Rust Fungal
🌱 Cotton Bollworm Insect Pest
🌱 Cotton Leaf Curl Virus Viral
✅ All Crops Healthy Leaf

Data sources: ICAR bulletins · NIPHM guidelines · CICR recommendations


🧠 ML Model Details

Property Value
Architecture MobileNetV2 (Transfer Learning + Fine-tuning)
Input 224 × 224 × 3 (normalized to [0, 1])
Output 15-class softmax
Model size ~14 MB
Inference time < 200 ms (mid-range Android)
Training data PlantVillage — 38,000 images
Top-1 accuracy ~90% (validation set)

Why MobileNetV2 and not a bigger model?

Our target is a ₹8,000–12,000 Android phone with 2 GB RAM. MobileNetV2 hits the sweet spot of accuracy, model size, and inference speed — and it ships inside the APK so there's no download required on first launch.


🎨 Severity Estimation Algorithm (HSV)

Image
  → Resize to 128×128
  → Per-pixel RGB → HSV conversion
  → Classify each pixel:
       • Background  : V > 0.95 AND S < 0.10  → Skip
       • Healthy     : H ∈ [60°, 140°] AND S > 0.15 → Healthy count
       • Diseased    : Everything else         → Diseased count
  → Ratio = Diseased / (Diseased + Healthy)
  → Severity:
       < 15%  → 🟡 Mild
       15–40% → 🟠 Moderate
       > 40%  → 🔴 Severe

📁 Project Structure

kisandoc/
├── lib/
│   ├── main.dart                        # App entry point, Hive initialization
│   ├── app.dart                         # Theme & routing
│   ├── core/
│   │   ├── constants/app_strings.dart   # All multilingual strings (EN/HI/OR)
│   │   ├── theme/app_theme.dart         # Design system & tokens
│   │   └── providers/app_provider.dart  # Language state management
│   ├── data/
│   │   ├── disease_database.dart        # 15 diseases, ICAR treatment data
│   │   ├── kvk_data.dart               # 32 KVK offices across Odisha
│   │   └── models/
│   │       └── diagnosis_record.dart    # Hive-adapted data model
│   ├── services/
│   │   ├── ml_service.dart             # TFLite inference engine
│   │   ├── severity_service.dart       # HSV color analysis
│   │   ├── tts_service.dart            # Text-to-speech (3 languages)
│   │   └── storage_service.dart        # Hive CRUD operations
│   └── screens/
│       ├── onboarding/                 # First-launch tutorial
│       ├── home/                       # Camera / gallery entry
│       ├── diagnosis/                  # Results + treatment plan
│       ├── history/                    # Swipe-to-delete past records
│       ├── shop_locator/               # GPS + KVK directory
│       └── settings/                   # Language selection
├── assets/
│   ├── model/kisandoc.tflite           # On-device ML model
│   └── labels/labels.txt              # Class labels
├── scripts/
│   ├── scraper.py                      # ICAR data collection
│   └── model_conversion.py            # Training + TFLite export
└── README.md

🌍 Language Support

Language Code TTS Notes
English en ✅ Full Default fallback
Hindi hi ✅ Full
Odia or ⚠️ Partial Requires Google TTS + Odia language pack (Android 9+); falls back to Hindi on older devices

🔒 Privacy — Zero Data Leaves Your Device

  • 📵 Photos never uploaded — all AI inference runs locally
  • 🔐 No accounts, no login, no tracking
  • 📍 Location used only to open Google Maps — never stored
  • 🗃️ Diagnosis history saved on-device only (Hive local DB)
  • 📊 No analytics, no telemetry, no crash reporting

📱 Device Requirements

Requirement Minimum
Android version 8.0 (API 26)
RAM 2 GB
Free storage 100 MB
Camera Optional — gallery works without it
Internet Optional — only needed for the Maps feature

⚠️ Known Limitations

  1. Odia TTS — Requires the Google TTS app with the Odia language pack installed
  2. Cotton diseases — Limited training data; accuracy may be lower than other crops
  3. Lighting conditions — Works best in natural daylight; avoid flash photography
  4. Similar diseases — Some diseases look alike (e.g. late blight vs. early blight); always cross-check symptom descriptions
  5. AI is decision-support — Not a replacement for a trained agronomist or KVK officer

🤝 Contributing

This is a community app built for the farmers of Odisha. All contributions are welcome:

  • 🌾 Better training data — Odisha-specific crop disease photos
  • 🗣️ Odia language improvements — translations, TTS testing
  • 🦠 New disease classes — expand beyond the current 15
  • 📋 Field testing reports — real-world accuracy feedback from farmers

Please open an issue before submitting a large PR so we can discuss the approach.


📄 License

This project is licensed under the MIT License — free to use, modify, and distribute.

Data credits: ICAR · NIPHM · CICR · PlantVillage (Penn State University)


⚠️ Disclaimer

KisanDoc is a decision-support tool based on publicly available agricultural guidelines. AI predictions are not 100% accurate. For critical crop disease management, always verify physical symptoms and consult your local KVK officer or state agriculture department before applying any chemical treatment.


Made with ❤️ for the farmers of Odisha

If this project helps even one farmer save their harvest, it was worth building.

About

Offline AI crop disease diagnosis app for Indian farmers - Flutter + TFLite

Topics

Resources

Stars

Watchers

Forks

Packages

Contributors

Languages