An AI-powered web application built with Django that detects crop diseases from leaf images using deep learning. Designed to assist farmers and agricultural professionals with quick and accurate disease identification and recommendations.
- 🌿 Upload leaf images and detect plant diseases with high accuracy.
- 🤖 Integrated trained ML model (TensorFlow/TensorFlow Lite).
- 🗂️ Stores prediction records in PostgreSQL with advanced search & filtering (Elasticsearch-ready).
- ☁️ AWS S3 integration for scalable image storage.
- 🔐 User authentication and role-based access control (OAuth support included).
- ⚙️ Background ML inference with Celery (future enhancement).
- 📊 Admin dashboard for managing data.(Currently working on it)
- 📦 Dockerized for easy deployment.
- 🧪 Unit-tested with high coverage.
| Category | Tools / Technologies |
|---|---|
| Backend | Django, Django REST Framework |
| Machine Learning | TensorFlow / TensorFlow Lite, OpenCV |
| Database | PostgreSQL |
| Cloud Storage | AWS S3 |
| DevOps | Docker, Git, GitHub Actions (CI/CD) |
| Authentication | Django Allauth / OAuth2 (Google/Facebook) |
| Future Upgrades | Celery + Redis (async tasks), Elasticsearch |
Try it live: https://smartcrop.example.com (if deployed)
smart_crop/ │ ├── detection/ # App for leaf image handling & prediction │ ├── models.py # LeafImage model │ ├── views.py # Upload & prediction logic │ └── ml/ # Model files (TFLite or H5) │ ├── templates/ # HTML templates (Bootstrap + custom) ├── static/ # Static files (CSS/JS) ├── media/ # Uploaded images (S3 synced) ├── core/ # Project settings and URLs │ ├── settings.py │ ├── settings_local.py # Secrets (gitignored) │ ├── Dockerfile ├── docker-compose.yml ├── requirements.txt └── README.md
- Upload a crop/leaf image via the web interface.
- The backend sends the image to a pre-trained ML model.
- The model classifies the disease and returns a prediction.
- The result is stored in PostgreSQL and optionally searchable via Elasticsearch.
| Image | Prediction | Confidence |
|---|---|---|
| tomato_leaf_01.jpg | Tomato Early Blight | 92.3% |
| potato_leaf_02.jpg | Potato Late Blight | 89.7% |
- Python 3.10+
- PostgreSQL
- AWS S3 bucket (configured)
- Docker (optional but recommended)
git clone https://github.com/yourusername/smart_crop.git
cd smart_croppip install -r requirements.txtCreate settings_local.py for sensitive data (DB, AWS, Secret Keys):
# settings_local.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'smart_crop_db',
'USER': 'postgres',
'PASSWORD': 'yourpassword',
'HOST': 'localhost',
'PORT': '5432',
}
}
AWS_ACCESS_KEY_ID = 'your-access-key'
AWS_SECRET_ACCESS_KEY = 'your-secret-key'
AWS_STORAGE_BUCKET_NAME = 'your-bucket-name'python manage.py makemigrations
python manage.py migratepython manage.py createsuperuserpython manage.py test📦 Docker Support
docker-compose up --build✨ Future Enhancements ✅ Integrate Celery for background model inference.
✅ Add Elasticsearch for full-text search on prediction records.
✅ Advanced filtering (by crop type, confidence, date).
✅ Model retraining from admin panel.
✅ Multilingual support (Hindi, etc.).
🤝 Contributing Contributions are welcome! Please fork the repo and submit a pull request.
📜 License MIT License © HARSH GANGWAR
📧 Contact Author: HARSH GANGWAR
Email: hgangwar07@gmail.com
LinkedIn: www.linkedin.com/in/harshgangwar07