An AI-powered web application for detecting plant diseases from leaf images using state-of-the-art vision models. Built with React, FastAPI, and multimodal LLMs.
- Real-time Analysis: Upload a leaf photo and get instant disease detection
- Multiple AI Providers: Choose between OpenAI GPT-4 Vision and Anthropic Claude 3 Opus
- Comprehensive Reports: Detailed diagnosis including disease name, severity, confidence, symptoms, treatment, and prevention
- Modern UI: Visually appealing, responsive interface with drag-and-drop upload
- RESTful API: FastAPI backend with automatic OpenAPI documentation
- React 18 with Vite
- Tailwind CSS for styling
- Axios for API communication
- FastAPI (Python 3.10+)
- Pydantic for data validation
- OpenAI Python SDK
- Anthropic Python SDK
- Pillow for image processing
- python-magic for file validation
- Python 3.10 or higher
- Node.js 18 or higher
- OpenAI API key (for GPT-4 Vision)
- Anthropic API key (for Claude 3 Opus)
cd backend
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env
# Edit .env with your API keyscd frontend
npm installCreate a .env file in the backend directory:
OPENAI_API_KEY=your_openai_api_key_here
ANTHROPIC_API_KEY=your_anthropic_api_key_here
DEFAULT_LLM_PROVIDER=openai
DEBUG=TrueStart the backend (Terminal 1):
cd backend
source venv/bin/activate
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000Start the frontend (Terminal 2):
cd frontend
npm run devAccess the application at http://localhost:5173
Build the frontend:
cd frontend
npm run buildThe built files will be in frontend/dist/
Once the backend is running, visit:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Detect plant disease from uploaded image.
Parameters:
file(multipart/form-data): Image file (JPEG, PNG, WebP, max 10MB)provider(form):openaioranthropic(default: openai)include_treatment(form): boolean (default: true)include_prevention(form): boolean (default: true)
Response:
{
"success": true,
"disease": {
"name": "Early Blight",
"scientific_name": "Alternaria solani",
"description": "A common fungal disease affecting tomatoes and potatoes...",
"severity": "moderate",
"confidence": 0.92,
"affected_area": "Lower leaves, progressing upward",
"symptoms": ["Dark brown spots with concentric rings", "Yellowing around spots"],
"treatment": "Apply fungicide containing chlorothalonil...",
"prevention": "Rotate crops, avoid overhead watering..."
},
"processing_time_ms": 2341.5
}Health check endpoint.
List available LLM providers.
plant-disease-detector/
├── backend/
│ ├── app/
│ │ ├── api/
│ │ │ └── routes.py # API endpoints
│ │ ├── core/
│ │ │ └── config.py # Configuration settings
│ │ ├── models/
│ │ │ └── schemas.py # Pydantic models
│ │ ├── services/
│ │ │ └── llm_vision.py # LLM vision integration
│ │ ├── utils/
│ │ └── main.py # FastAPI application
│ ├── tests/
│ ├── requirements.txt
│ └── .env.example
├── frontend/
│ ├── src/
│ │ ├── components/
│ │ │ ├── Header.jsx
│ │ │ ├── Footer.jsx
│ │ │ ├── UploadZone.jsx
│ │ │ └── ResultDisplay.jsx
│ │ ├── utils/
│ │ │ └── api.js
│ │ ├── styles/
│ │ │ └── index.css
│ │ ├── App.jsx
│ │ └── main.jsx
│ ├── index.html
│ ├── package.json
│ ├── vite.config.js
│ ├── tailwind.config.js
│ └── postcss.config.js
├── docs/
└── README.md
- JPEG (.jpg, .jpeg)
- PNG (.png)
- WebP (.webp)
Maximum file size: 10MB
The application can identify various plant diseases including but not limited to:
- Early Blight
- Late Blight
- Powdery Mildew
- Leaf Spot
- Rust
- Mosaic Virus
- Bacterial Spot
- And many more
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
MIT License - see LICENSE file for details.
Created by kv-creates
- OpenAI for GPT-4 Vision
- Anthropic for Claude 3 Opus
- PlantVillage dataset for reference
- All contributors and testers