Skip to content

The Smart Crop Disease Detection System is a Django web app that uses machine learning to identify crop diseases from leaf images. It helps farmers detect diseases quickly and take action to protect their crops. The system features AWS S3 image storage, TensorFlow Lite integration, and a responsive front-end for easy use.

Notifications You must be signed in to change notification settings

HarshGangwar07/smart_crop

Repository files navigation

🌾 Smart Crop Disease Detection System

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.


🚀 Features

  • 🌿 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.

🛠️ Tech Stack

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

🖼️ Demo

(SOON WILL POST HERE) App Screenshot

Try it live: https://smartcrop.example.com (if deployed)


📂 Project Structure

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


🧠 How It Works

  1. Upload a crop/leaf image via the web interface.
  2. The backend sends the image to a pre-trained ML model.
  3. The model classifies the disease and returns a prediction.
  4. The result is stored in PostgreSQL and optionally searchable via Elasticsearch.

📸 Sample Predictions

Image Prediction Confidence
tomato_leaf_01.jpg Tomato Early Blight 92.3%
potato_leaf_02.jpg Potato Late Blight 89.7%

⚙️ Setup Instructions

Prerequisites

  • Python 3.10+
  • PostgreSQL
  • AWS S3 bucket (configured)
  • Docker (optional but recommended)

1. Clone the Repository

git clone https://github.com/yourusername/smart_crop.git
cd smart_crop

2. Install Dependencies

pip install -r requirements.txt

3. Configure Environment

Create 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'

4. Run Migrations

python manage.py makemigrations
python manage.py migrate

5. Create Superuser

python manage.py createsuperuser

6. Run the Server

python 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

About

The Smart Crop Disease Detection System is a Django web app that uses machine learning to identify crop diseases from leaf images. It helps farmers detect diseases quickly and take action to protect their crops. The system features AWS S3 image storage, TensorFlow Lite integration, and a responsive front-end for easy use.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •