Project
Crop Cure — Grape Disease Detection via WhatsApp
A WhatsApp bot that classifies grape-leaf diseases from photos and replies with multilingual treatment guidance.
Status
This project is not under active maintenance right now. The core workflow and deployment setup are documented here, but some parts of the implementation may need cleanup before production use.
Problem
Farmers often need disease guidance from the device they already use most: WhatsApp. Crop Cure was built as a lightweight diagnosis flow where a farmer can send a grape-leaf image, get a prediction, and receive treatment guidance in a familiar chat interface.
What the Bot Does
- Accepts a grape-leaf image over WhatsApp
- Classifies the image with a custom ResNet9 hybrid model
- Returns the disease label, symptoms, and treatment options
- Supports English, Marathi, and Hindi
- Can attach product recommendations through WhatsApp buttons
System Flow
User (WhatsApp) | vWhatsApp Cloud API | vFastAPI backend |- pywa_async for message handling |- googletrans for translation |- src/model.py for inference `- src/dict.py for disease and treatment contentSupported Classes
| Disease | Class name |
|---|---|
| Black Rot | Grape__Black_rot |
| Esca (Black Measles) | Grape__Esca_(Black_Measles) |
| Leaf Blight (Isariopsis Leaf Spot) | Grape__Leaf_blight_(Isariopsis_Leaf_Spot) |
| Healthy leaf | Grape__healthy |
User Flow
- The user sends a greeting on WhatsApp.
- The bot asks for a language choice.
- The user uploads a grape-leaf photo.
- The backend runs model inference and returns:
- predicted class
- short disease explanation
- symptoms
- treatment suggestions
- optional product link
Demo
Local Development
Requirements
- Python 3.11+
ngrokfor local webhook development- WhatsApp Business API credentials
Setup
git clone https://github.com/VedantAndhale/Crop_Cure_Bot.gitcd Crop_Cure_Botcp .env.example .envpip install -r requirements.txtEnvironment variables
PHONE_NUMBER_ID=your_phone_number_idACCESS_TOKEN_LTM=your_long_term_access_tokenCALLBACK_URL=https://your-domain.ngrok-free.appVERIFY_TOKEN=your_webhook_verify_tokenAPP_ID=your_facebook_app_idAPP_SECRET=your_facebook_app_secretRun locally
In one terminal:
ngrok http --url=your-custom-url.ngrok-free.app 8080In another:
fastapi dev main.py --port 8080Deployment
Docker
docker build -t crop-cure .docker run -p 8080:8080 --env-file .env crop-cureCloud Run
export PROJECT_ID=your-gcp-project-idexport REGION=us-central1bash deploy.shAfter deployment, the WhatsApp webhook URL should be updated to:
<SERVICE_URL>/webhookModel Notes
- Architecture: ResNet9 hybrid with ECA + spatial attention
- Classes: 4
- Confidence threshold: 98%
- Weights file:
best_resnet9_hybrid_model.pth - Input size:
224x224RGB image
Project Structure
Crop_Cure_Bot/|- main.py|- src/| |- model.py| `- dict.py|- best_resnet9_hybrid_model.pth|- requirements.txt|- Dockerfile|- deploy.sh|- app.yaml|- .env.example`- start.shTech Stack
| Layer | Technology |
|---|---|
| Backend | FastAPI |
| Model inference | PyTorch |
| Messaging | WhatsApp Cloud API + pywa |
| Translation | googletrans |
| Containerization | Docker |
| Deployment | Google Cloud Run |
Outcome
Crop Cure shows how a computer-vision model can be wrapped in a practical messaging workflow instead of a separate dashboard. The value here is less about raw model novelty and more about delivering the prediction through a channel that fits the user.