A web application that automatically detects and classifies weeds in agricultural field photos using deep learning.
Weeds are a farmer's silent enemy. They compete with crops for water, nutrients, and sunlight, and if left unchecked they can seriously reduce harvest yields. Spotting them early and accurately is critical — but it's also a hard task.
Traditionally, farmers inspect their fields by eye. This is slow, tiring, and easy to get wrong — especially when plants look similar, or when the field is large. Many farmers end up applying weed-killer across entire fields, which is wasteful for the environment and their wallet.
This project takes a smarter approach: instead of a human looking at a field, a deep learning model looks at it. You simply take a photo of the field, upload it to this web app, and the AI tells you whether weeds are present, what kind of weed it is, and how confident it is in that answer. Within seconds, a farmer gets the kind of on-the-ground knowledge that normally takes years of experience — helping them treat only the areas that need it.
So in short: we turn "go look at your field and guess" into "upload a photo and know."
The system is split into two halves that talk to each other:
- Frontend — the website you see and interact with. It lets you upload a field photo and pick which AI model should analyze it.
- Backend — the "brain" behind the scenes. It receives the photo, runs it through a deep learning model, and sends back the result.
A typical flow looks like this:
- You open the web app and upload a photo of a crop field.
- You choose a detection model (or just use the default).
- The frontend sends the photo to the backend API.
- The backend runs the image through the chosen AI model.
- The backend replies with a prediction (e.g. "Parthenium") and a confidence score.
- The frontend shows you the result.
Weed_Detection/
├── Weed_Detection_Frontend/ # The web interface (Next.js + React)
└── Weed_Detection_Backend/ # The AI API (FastAPI + TensorFlow/PyTorch)
Full details: Weed_Detection_Frontend/README.md
Tech stack: Next.js 15, React 19, TypeScript, Turbopack, Lucide React icons, ESLint.
What it does: This is the user-facing side of the project. It provides a clean, responsive interface where you can:
- Upload a field image by dragging & dropping it or browsing your files (JPG, JPEG, or PNG up to 10MB).
- Choose which deep learning model should analyze your image — cards for ResNet-50, U-Net, EfficientNet, and DeepLabV3.
- Run the prediction by sending the image to the backend at
http://localhost:8000/predict. - See the result, complete with loading spinners, error messages, and a confidence-based result display.
It's built with a modern design — custom gradients, smooth transitions, and selected-model highlighting — and works well on both desktop and mobile.
Full details: Weed_Detection_Backend/README.md
Tech stack: FastAPI, Uvicorn, TensorFlow, PyTorch, TorchVision, Pillow, NumPy, Pydantic.
What it does: This is the AI engine of the project. It is a REST API that powers the whole system, the main jobs being:
- Receiving images — validates uploads (file size, JPEG/PNG formats) and rejects anything invalid.
- Running multiple AI models — supports U-Net (image segmentation, i.e. which parts of the image are weed), ResNet50 and EfficientNetB0 (image classification, i.e. which weed species it is), and a custom TensorFlow model. Models are loaded on demand through a registry, so they're only loaded into memory when actually used.
- Returning results — sends back a structured response with the model used, the prediction label, and a confidence score.
The API exposes a few endpoints:
| Endpoint | What it does |
|---|---|
GET /health |
Health check — is the backend alive? |
GET /models |
Lists all available detection models |
POST /predict |
Uploads an image + model name, returns the prediction |
To try it yourself, run both halves:
# 1. Start the backend (from the Weed_Detection_Backend folder)
pip install -r requirements.txt
uvicorn app.main:app --reload # runs at http://127.0.0.1:8000
# 2. Start the frontend (from the Weed_Detection_Frontend folder)
npm install
npm run dev # runs at http://localhost:3000Then open http://localhost:3000, upload a field photo, and run a prediction.