An AI-powered conversational chatbot for diagnosing plant diseases using computer vision (CNN) and natural language processing (BERT).
- 🤖 Conversational AI: Interactive chatbot that asks clarifying questions
- 📸 Image Diagnosis: Upload leaf photos for CNN-based disease detection
- 💬 Text Diagnosis: Describe symptoms for BERT-based analysis
- 🎯 Pattern-Based Detection: Recognizes characteristic disease patterns (e.g., Early Blight's target spots)
- 💊 Treatment Recommendations: Detailed treatment and prevention advice for 35+ diseases
- 🌍 Multi-Crop Support: Covers tomatoes, potatoes, apples, grapes, corn, peppers, and more
- Python 3.8+
- pip
- Clone the repository:
git clone <your-repo-url>
cd final- Create virtual environment:
python -m venv .venv
.venv\Scripts\activate # Windows
# or
source .venv/bin/activate # Linux/Mac- Install dependencies:
pip install -r requirements.txt-
Download model files (not included in Git due to size):
bert_plant_chatbot_model.pt(438 MB)cnn_model_final.h5orfinal_saved_model/(27-574 MB)class_names.pkllabel_mapping.json
Note: Contact the repository owner for model files or train your own using
Training_code.ipynb -
Run the app:
streamlit run app.py- Open in browser: http://localhost:8501
final/
├── app.py # Main Streamlit application
├── chatbot/ # Chatbot package
│ ├── chatbot_manager.py # Conversational AI logic
│ ├── conversation_templates.py # Response templates
│ └── followup_templates.py # Follow-up templates
├── knowledge_base/ # Knowledge base package
│ ├── disease_patterns.py # Pattern-based disease detection
│ ├── treatments.py # Treatment database (35 diseases)
│ └── detailed_treatments.py # Detailed disease info
├── resources/ # Static resources
│ ├── class_names.pkl # CNN labels (not in Git)
│ └── label_mapping.json # BERT labels (not in Git)
├── models/ # Model files
│ ├── bert_plant_chatbot_model.pt # BERT model (not in Git)
│ └── final_saved_model/ # CNN model (not in Git)
├── requirements.txt # Python dependencies
├── README.md # This file
└── .gitignore # Git ignore rules
- Upload a clear photo of affected plant leaves
- Get instant CNN-based disease prediction
- View confidence score and treatment recommendations
- Describe symptoms in natural language
- Get BERT-based analysis with top 3 predictions
- See detailed treatment plans
- Start a conversation with the AI assistant
- Answer clarifying questions about symptoms
- Receive accurate diagnosis with high confidence
- Get personalized treatment recommendations
Example Conversation:
🤖 Bot: Hello! Describe the symptoms you're seeing.
👤 User: My tomato plant has brown spots with rings on the leaves
🤖 Bot: Are the spots circular with concentric rings, like a target?
👤 User: Yes, exactly like a target pattern
🤖 Bot: I'm 70% confident this is Tomato Early Blight.
Treatment: Remove infected leaves, apply fungicides...
-
Pattern-Based Detection (Primary):
- Recognizes characteristic symptom patterns
- High confidence (70-95%) for specific diseases
- Examples: Early Blight (target spots), Powdery Mildew (white powder)
-
BERT Model (Fallback):
- Natural language understanding
- Analyzes accumulated symptom descriptions
- Works for diseases without specific patterns
Crops: Tomato (12 conditions), Potato (3), Apple (3), Corn (3), Grape (2), Pepper (3), and more
Disease Types: Fungal, bacterial, viral, pest-related, and healthy baselines
- Frontend: Streamlit
- ML Models:
- TensorFlow/Keras (CNN for images)
- PyTorch + Transformers (BERT for text)
- Image Processing: PIL
- Data: NumPy, Pickle, JSON
Due to GitHub file size limits, the following large files are not included in this repository:
bert_plant_chatbot_model.pt(438 MB)final_saved_model/orcnn_model_final.h5(27-574 MB)newmodel.h5(574 MB)
To get the models:
- Contact the repository owner
- Or train your own using
Training_code.ipynb - Or use Git LFS for large files
This tool provides general guidance and is not a replacement for professional diagnosis. For critical plant health issues, consult certified agricultural professionals.
- Pattern Detection: 70-95% confidence for characteristic diseases
- BERT Model: 10-20% confidence (requires improvement)
- CNN Model: Varies by disease
- Inference Speed: 1-3 seconds on CPU
- Improve BERT model training
- Add more disease patterns
- Mobile app version
- Multi-language support
- User accounts and history
- Geographic disease tracking
- Integration with weather data
Contributions are welcome! Please feel free to submit pull requests or open issues.
[Add your license here]
[Add your name/team here]
- PlantDoc and PlantVillage datasets
- BERT model from Hugging Face
- Streamlit for the amazing framework
Built with ❤️ for healthier plants 🌱