https://github.com/ridwanullahi-code/leaf-buddy
https://github.com/ridwanullahi-code/leaf-buddy
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ridwanullahi-code/leaf-buddy
- Owner: Ridwanullahi-code
- Created: 2025-08-01T14:47:45.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-08-10T10:55:05.000Z (9 months ago)
- Last Synced: 2025-08-10T12:29:26.303Z (9 months ago)
- Language: TypeScript
- Size: 33.4 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tomato Disease Detection App
A full-stack application for detecting tomato plant diseases using machine learning. Built with React frontend and Python backend using TensorFlow Lite models.
## Features
- 📸 Camera capture and photo upload
- 🤖 AI-powered disease detection using TFLite models
- 🔬 Support for multiple models (MobileNetV2, ResNet50, VGG16)
- 💊 Treatment and prevention recommendations
- 🎨 Beautiful responsive UI with Tailwind CSS
## Quick Start
### 🚀 Quick Start
1. **First time setup:**
```bash
npm run setup
```
2. **Start both servers:**
```bash
npm start
```
This automatically starts:
- Frontend on http://localhost:5173
- Python backend on http://localhost:5000
**That's it!** The app will be ready at http://localhost:5173
### Manual Setup (if needed)
If you prefer to run servers separately:
1. **Setup dependencies:**
```bash
npm install
cd backend && pip install -r requirements.txt
```
2. **Start backend:**
```bash
cd backend && python start.py
```
3. **Start frontend (in new terminal):**
```bash
npm run dev
```
## Project Structure
```
├── src/ # React frontend
│ ├── components/ # UI components
│ ├── pages/ # Page components
│ ├── services/ # API services
│ └── types/ # TypeScript definitions
├── backend/ # Python backend
│ ├── app.py # Flask server
│ ├── requirements.txt # Python dependencies
│ └── start.py # Backend startup script
├── models/ # TensorFlow Lite models
│ ├── mobilenetv2_fine_tuned.tflite
│ ├── resnet50_fine_tuned.tflite
│ └── vgg16_fine_tuned.tflite
├── setup.js # Setup script
├── start.js # Start script
└── public/ # Static assets
```
## How It Works
1. **Image Capture**: Users can take photos or upload images of tomato leaves
2. **Preprocessing**: Images are processed using OpenCV (sharpening, contrast enhancement)
3. **AI Analysis**: TensorFlow Lite models analyze the preprocessed images
4. **Results**: Disease classification with confidence scores and treatment recommendations
## Models
The app supports three pre-trained models:
- **MobileNetV2**: Fast inference, good for mobile devices
- **ResNet50**: Higher accuracy, balanced performance
- **VGG16**: High accuracy, slower inference
## Disease Classes
The models can detect:
- Healthy leaves
- Bacterial spot
- Early blight
- Late blight
- Leaf mold
- Septoria leaf spot
- Spider mites
- Target spot
- Tomato mosaic virus
- Yellow leaf curl virus
## Development
### Available Scripts
- `node setup.js` - Install all dependencies (Node.js and Python)
- `node start.js` - Start both frontend and backend servers
- `npm run dev` - Start only the React frontend
- `cd backend && python start.py` - Start only the Python backend
### Adding New Models
1. Place your `.tflite` model file in the `models/` directory
2. Update the `DISEASE_CLASSES` array in `backend/app.py`
3. Add the model name to the frontend model selector
### API Endpoints
- `GET /health` - Health check
- `POST /analyze` - Disease detection
- `GET /models` - Available models list
## Technologies Used
### Frontend
- React 18 + TypeScript
- Vite build tool
- Tailwind CSS + shadcn/ui
- React Router
- React Query
### Backend
- Python Flask
- TensorFlow Lite
- OpenCV
- PIL (Pillow)
- NumPy
## Troubleshooting
### Common Issues
1. **Setup script fails:**
```bash
# Try manual installation
npm install --legacy-peer-deps
cd backend && pip install -r requirements.txt
```
2. **Python not found:**
- Install Python 3.8+ from python.org
- Try `python3` instead of `python`
3. **Backend won't start:**
```bash
cd backend
python -c "import flask; print('Flask available')"
```
4. **Models not found:**
- Ensure `.tflite` files are in the `models/` directory
- Check file permissions
5. **CORS errors:**
- Ensure both servers are running on correct ports
- Frontend: http://localhost:5173
- Backend: http://localhost:5000
## License
MIT License - feel free to use this project for your own applications!