A machine learning application that uses deep learning to classify potato leaf diseases. The application consists of a FastAPI backend with a React frontend for easy image upload and disease prediction.
- Image Upload: Drag and drop or click to upload potato leaf images
- Real-time Prediction: Get instant disease classification results
- Confidence Scoring: See prediction confidence percentages
- Beautiful UI: Modern, responsive design with color-coded results
- Disease Information: Educational content about different potato diseases
- Early Blight: Fungal disease causing brown spots with concentric rings
- Late Blight: Serious disease causing rapid leaf death
- Healthy: No disease detected
potato-disease/
├── api/ # FastAPI backend
│ ├── main.py # Main API server
│ └── requirements.txt # Python dependencies
├── frontend/ # React frontend
│ ├── src/
│ │ ├── App.jsx # Main React component
│ │ └── App.css # Styles
│ └── package.json # Node.js dependencies
├── models/ # Trained ML models
│ └── 1.keras # Potato disease classification model
└── Training/ # Training notebooks and data
- Python 3.10+ (for TensorFlow compatibility)
- Node.js 16+ and npm
- Conda or virtual environment (recommended)
# Create and activate conda environment
conda create -n tfenv python=3.10
conda activate tfenv
# Install Python dependencies
pip install tensorflow==2.16.1 fastapi uvicorn pillow numpy python-multipart# Navigate to frontend directory
cd frontend
# Install Node.js dependencies
npm install# From project root
python start_app.pyTerminal 1 - Backend:
# Activate your conda environment
conda activate tfenv
# Start FastAPI server
cd api
python main.pyTerminal 2 - Frontend:
# Start React development server
cd frontend
npm run dev- Frontend: http://localhost:5173 (or URL shown by Vite)
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
- Upload Image: Click the upload area or drag and drop a potato leaf image
- Analyze: Click "Analyze Image" to process the image
- View Results: See the disease classification with confidence score
- Learn More: Read about different potato diseases in the info section
GET /ping- Health checkPOST /predict- Upload image and get disease prediction
{
"class": "Early Blight",
"confidence": 0.95
}If you see "Model failed to load" errors:
-
Check TensorFlow version compatibility
pip install tensorflow==2.16.1
-
Verify model file exists
ls models/1.keras
-
Check Python version
python --version # Should be 3.10+
If the frontend can't connect to the backend:
- Make sure the backend is running on port 8000
- Check that CORS middleware is enabled in
api/main.py - Verify the frontend is making requests to
http://localhost:8000
- Supported formats: JPG, PNG, GIF
- Maximum file size: 10MB (configurable)
- Ensure images are clear potato leaf photos
The FastAPI backend is located in api/main.py. Key features:
- CORS enabled for frontend communication
- Image preprocessing for model input
- Error handling and logging
- Model loading with fallback options
The React frontend uses:
- Vite for fast development
- Modern CSS with responsive design
- File upload with preview
- Real-time API communication
- Architecture: Convolutional Neural Network (CNN)
- Input: 256x256 RGB images
- Output: 3 classes (Early Blight, Late Blight, Healthy)
- Format: Keras model (.keras)
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is for educational and research purposes.
- PlantVillage dataset for training data
- TensorFlow/Keras for deep learning framework
- FastAPI for backend API
- React for frontend framework