Skip to content

AKHIL-SAURABH/CropAI-Project

Repository files navigation

🌾 CropAI – AI-powered Agricultural Assistant

A Deep Learning + Machine Learning-based system for crop disease detection, crop recommendation, and fertilizer recommendation.

CropAI Banner


πŸš€ Project Overview

CropAI is a fully integrated, end-to-end AI system for farmers that can:

  1. Detect crop disease from an image
  2. Recommend the best crop based on soil & climate parameters
  3. Recommend the right fertilizer based on crop, soil type, nutrients

Includes:

  • ML + DL Models
  • FastAPI Backend
  • Streamlit Dashboard
  • Cloud Deployment
  • (Mobile app coming soon)

🏷️ Tech Stack Badges

Python TensorFlow FastAPI Streamlit Render Pandas NumPy EfficientNet

Machine Learning Deep Learning Computer Vision

Status


πŸ”₯ Features

🩻 1. Crop Disease Detection (Computer Vision)

  • Trained MobileNetV2 on the PlantVillage dataset
  • Input: leaf image
  • Output: disease label + confidence

API Endpoint: POST /predict-disease Example Response:

{
  "predicted_class_index": 14,
  "disease_label": "Tomato___Early_blight",
  "confidence": 0.83
}

🌱 2. Crop Recommendation System

Uses soil & climate parameters:

  • N, P, K
  • Temperature
  • Humidity
  • pH
  • Rainfall

API Endpoint: POST /recommend-crop Example Response:

{
  "recommended_crop": "rice"
}

🌾 3. Fertilizer Recommendation System

Based on:

  • Temperature, Humidity, Moisture
  • Soil Type, Crop Type
  • N, P, K

API Endpoint: POST /recommend-fertilizer Example Response:

{
  "recommended_fertilizer": "Urea"
}

🧱 Project Architecture

graph TD
    A["PlantVillage Image Dataset"] --> B["Crop Disease Model (MobileNetV2)"]
    C["Crop & Fertilizer Datasets"] --> D["Tabular ML Models"]

    B --> E["Saved Models Folder"]
    D --> E

    E --> F["FastAPI Backend"]

    F --> G["Streamlit Dashboard"]
    F --> H["Mobile App (Future)"]
    F --> I["Cloud Deployment (Render/AWS/Railway)"]
Loading

🌍 Live API (Render Deployment)

The backend is publicly deployed via Render.

  • Base URL: https://cropai-project.onrender.com/
  • Swagger Docs: https://cropai-project.onrender.com/docs

⚠️ Note: Render free tier sleeps when idle. First request may take 20–40 seconds.


πŸ“‘ API Reference (Quick)

GET /health

Check server status.

Response:

{ "status": "ok" }

POST /predict-disease

Predict disease from uploaded image.

Body: multipart form-data β†’ file

Response example:

{
  "predicted_class_index": 14,
  "disease_label": "Tomato___Early_blight",
  "confidence": 0.83
}

POST /recommend-crop

Body:

{
  "N": 90,
  "P": 42,
  "K": 43,
  "temperature": 22.0,
  "humidity": 80.0,
  "ph": 6.5,
  "rainfall": 200.0
}

Response:

{ "recommended_crop": "rice" }

POST /recommend-fertilizer

Body:

{
  "Temparature": 26.0,
  "Humidity": 52.0,
  "Moisture": 38.0,
  "Soil_Type": "Loamy",
  "Crop_Type": "Sugarcane",
  "Nitrogen": 50.0,
  "Potassium": 40.0,
  "Phosphorous": 40.0
}

Response:

{ "recommended_fertilizer": "Urea" }

πŸ–ΌοΈ Screenshots

All screenshots are stored in the /screenshots folder on GitHub.

Dashboard Homepage

Dashboard Homepage

Disease Prediction

Disease Prediction Disease Prediction

Crop Recommendation

Crop Recommendation

Fertilizer Recommendation

Fertilizer Recommendation


🧠 How to Run Locally

1️⃣ Create environment

conda create -n cropai python=3.10
conda activate cropai
pip install -r requirements.txt

2️⃣ Start the backend

cd backend
uvicorn main:app --reload --host 0.0.0.0 --port 8000

3️⃣ Run Streamlit dashboard

cd dashboard
streamlit run app.py

🎯 Future Improvements

  • Better disease classification accuracy
  • More crops & fertilizers
  • Full mobile app (Flutter)
  • Multi-language farmer UI
  • Deployment across scalable cloud infra
  • Improve accuracy with heavy fine-tuning
  • Deploy backend + dashboard to Render/Railway/AWS
  • Add real-time weather API integration
  • Build farmer login + recommendation history

πŸ“„ License

This project is licensed under the MIT License. Feel free to use it, modify it, and build upon it with proper attribution.


πŸ’Ό Why This Project Matters

This project demonstrates:

  • 🧠 Deep Learning (CV with MobileNetV2)
  • πŸ“Š Machine Learning (RandomForest, preprocessing)
  • βš™οΈ API engineering (FastAPI, Pydantic, CORS)
  • πŸ–₯️ Interactive dashboards (Streamlit)
  • 🧩 Full end-to-end design (data β†’ model β†’ API β†’ UI)
  • 🧱 Production-ready architecture

Perfect for:

  • Resume
  • LinkedIn posts
  • Interviews
  • Final-year projects
  • ML engineering portfolios

πŸ‘€ Author

Akhil Saurabh

About

CropAI is a full-stack AI system built for smart agriculture. It predicts crop diseases using a MobileNetV2 deep learning model, recommends optimal crops based on soil climate conditions, suggests the right fertilizers using ML models.The project includes an API backend (FastAPI),an interactive dashboard (Streamlit),and cloud deployment on Render.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors