FarmGuard Nigeria is an AI-powered web application designed to help Nigerian farmers detect plant diseases and receive actionable treatment advice. The system combines Google Gemini Vision AI with a comprehensive Nigerian crop knowledge base to provide accurate, locally-relevant guidance.
# FarmGuard Nigeria
FarmGuard Nigeria is an AI-powered plant disease detection and crop recommendation system built for Nigerian farmers.
The project combines a FastAPI backend with a static frontend to deliver image-based disease diagnosis, a crop symptom checker, and season-aware crop recommendations.
## Features
- 🔬 AI Image Detection
- Upload a leaf photo (JPEG/PNG, max 8MB)
- Detect disease and plant type using Google Gemini Vision
- Returns diagnosis, symptoms, cause, treatment, urgency, and economic impact
- 🌿 Symptom Checker
- Select crop and symptoms for knowledge-based diagnosis
- Includes Nigerian crops like Cassava, Yam, Plantain/Banana, Maize, Tomato, Rice, Cowpea, Groundnut
- 🌾 Crop Recommendation
- Suggests crops based on state, soil type, and season
- 🕐 Diagnosis History
- Saves the last 10 analyses in browser local storage
- 📱 Frontend-ready UI
- Single-page static app using HTML, CSS, and JavaScript
## Supported Crops
### Image detection
- Maize
- Tomato
- Potato
- Pepper
- Orange
- Soybean
- (21 AI disease classes)
### Symptom checker
- Cassava
- Yam
- Plantain / Banana
- Rice
- Cowpea
- Groundnut
## Project Structure
```
farmguard/
├── backend/
│ ├── main.py
│ ├── requirements.txt
│ ├── app/
│ │ └── disease_config.json
│ └── models/
│ ├── plant_weights.weights.h5
│ └── README.txt
└── frontend/
└── index.html
```
## Requirements
- Python 3.11+ (recommended)
- `venv` for virtual environment
- `pip` for dependency installation
- Google Gemini API key for image analysis
## Setup
1. Open a terminal and go to the backend folder:
```bash
cd backend
```
2. Create and activate a virtual environment:
```powershell
python -m venv venv
venv\Scripts\activate
```
3. Install dependencies:
```powershell
pip install -r requirements.txt
```
4. Add a `.env` file in `backend/` with your Gemini key:
```text
GEMINI_API_KEY=your_gemini_api_key_here
```
5. Place your trained model weights file at:
```text
backend/models/plant …