CropGuard is a Flask-based crop disease detection and advisory platform. It combines computer vision and machine learning to analyze plant images and provides insights like severity, recommendations, and optional integrations (weather, pest alerts, voice).
- Image upload and disease classification using TensorFlow/Keras and OpenCV
- Severity analysis and recommendation modules
- Optional integrations: weather insights, pest alerts, voice interface, Gemini validation
- Admin and auth flows for managing access
- Health check endpoint at
/health
- Python, Flask, SQLAlchemy
- TensorFlow/Keras, OpenCV, Pillow
- SQLite (dev) or MySQL (prod)
- Requests/HTTPX for external services
python -m venv .venv
. .venv/Scripts/activate
pip install -r requirements.txtCreate a .env file in the project root (optional for development):
FLASK_ENV=development
FLASK_DEBUG=1
FLASK_SECRET_KEY=change-me
ALLOWED_ORIGINS=http://localhost:5000
# Optional services
GEMINI_API_KEY=
WEATHER_API_KEY=
# Optional database override
# DATABASE_URL=sqlite:///instance/crop_disease_web.db
Model artifacts are excluded from Git. Place your model in models/ or set MODEL_PATH to a custom location. The app looks for common filenames like best_phase2.keras or plant_disease_model.keras.
python src/api/app.pyOpen http://127.0.0.1:5000 in your browser.
pytestconfig.py
requirements.txt
models/
class_mapping.json
src/
api/
ml/
modules/
static/
templates/
- Production requires
FLASK_SECRET_KEYand a MySQL database configuration (DATABASE_URLorDB_*). - Optional integrations are enabled only if their API keys are set.