Skip to content

Dattaraj009/Crop-Diseases-ChatBot-Advice

Repository files navigation

Intelligent Crop Health Advisor

AI system to identify crop type, diagnose plant diseases from images, and deliver multilingual text/voice advice with offline-first deployment.

Highlights

  • Crop and disease identification via separate CNNs for precision and speed.
  • Actionable advice from a local, fine-tuned LLM with safety filters.
  • Multilingual chatbot with STT/TTS for low-connectivity, accent-robust use.
  • Sustainability focus: targeted treatments to reduce pesticide overuse.

Tech Stack

  • DL: PyTorch/TensorFlow, OpenCV, PIL, NumPy, Pandas
  • LLM/Runtime: Transformers, Optimum, ONNX Runtime, TensorRT
  • Backend: FastAPI or Node.js, PostgreSQL
  • Voice: Whisper (STT), VITS (TTS)

Datasets

  • PlantVillage (~54k images)
  • PlantDoc (~2.6k images)
  • Custom regional crop/disease images
  • Common Voice (selected languages)

Models

  • Crop ID: MobileNetV2 (transfer learning)
  • Disease: ResNet50/EfficientNet (class-balanced)
  • Advice: Gemma 3 (via Ollama)
  • Chatbot: Whisper + VITS

Performance Targets

  • Crop ID: ≥90% accuracy, ≤1s inference
  • Disease: ≥85% F1, high early-stage recall
  • Advice: ≤2s response, safe/relevant outputs
  • Chatbot: ≥85% intent accuracy, tracked WER

Quickstart

Prerequisites

  • Python 3.10+
  • CUDA (recommended for faster inference)
  • ffmpeg (for voice features)
  • PostgreSQL (for data storage)
  • Ollama (for running LLM locally)

Setup

  1. Clone the repository and install requirements:

    git clone <repository-url>
    cd Crop-Diseases-ChatBot-Advice
    python -m venv venv
    source venv/Scripts/activate 
    pip install -r requirements.txt
  2. Install Ollama:

    • Download and install from Ollama's official website
    • Or use the following command:
      curl -fsSL https://ollama.com/install.sh | sh
  3. Pull the required LLM model:

    ollama pull gemma3
  4. Start the Ollama server (if not running automatically):

    ollama serve
  5. Start the application:

    python app.py

    The application will be available at http://127.0.0.1:7860

Usage

  1. Upload a crop image for analysis
  2. View the diagnosis and care advice
  3. Ask follow-up questions in the chat interface

For development with the API:

  • POST image to /predict/crop for crop identification
  • POST to /predict/disease for disease diagnosis
  • Request advice via /advice
  • Chat via /chat (supports text/audio)

API (minimal)

  • POST /predict/crop → {crop, top_k, confidence}
  • POST /predict/disease → {disease, severity, notes}
  • POST /advice → {treatment, prevention, followup}
  • POST /chat → {text_out, audio_out?}

Project Structure

  • models/ (cnn/, llm/, stt_tts/)
  • api/ (routes/, schemas/)
  • data/ (raw/, processed/)
  • scripts/ (train_, export_, serve_*)
  • configs/ (.env, model/config.yaml)

Roadmap

  • Expand regional datasets and balance rare diseases
  • Improve early-stage recall and edge latency
  • Broaden language/accent coverage
  • Add offline bundles and edge profiles

License

Choose a permissive OSS license; respect dataset licenses.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors