A deep learning system to detect and classify tomato diseases from leaf spot images using a Convolutional Neural Network (CNN) model. The model achieves 93% accuracy and is deployed via FastAPI and accessible through web and mobile apps.
- Classifies common tomato diseases via visible leaf spots.
- CNN trained on annotated tomato leaf image dataset.
- Supports both web and mobile interfaces (React / React Native).
- Fast inference using TensorFlow Lite.
- API hosted via FastAPI + Docker + ECS.
- Images are preprocessed and fed through a deployed model which returns prediction and confidence score.
| Architecture | Type | Accuracy |
|---|---|---|
| CNN | Custom | 93% |
- Input: Tomato leaf images.
- Output: Predicted disease class and confidence score.
- Optimized for lightweight deployment (TFLite).
- Backend: FastAPI, TensorFlow, TensorFlow Lite
- Frontend: React, React Native
- DevOps: Docker, Amazon ECS, GCP Cloud Storage
- Libraries: NumPy, PIL, Uvicorn
| Route | Method | Description |
|---|---|---|
/ping |
GET | Health check |
/predict |
POST | Upload an image and get prediction |
POST /predict
Body: multipart/form-data with an image file
{
"class": "Tomato___Late_blight",
"confidence": 0.9321
}- Tomato___Early_blight
- Tomato___Late_blight
- Tomato___healthy
-
Clone Repository
git clone https://github.com/SteveParadox/Agric_ai.git cd Agric_ai/Api -
Install Dependencies
pip install -r requirements.txt
-
Run FastAPI App
uvicorn api:app --reload
-
Access API
- Visit
http://localhost:8000/docsto use Swagger UI
- Visit
- React Web App: Upload tomato leaf images from browser.
- React Native App: Capture image via phone camera and send to API.
- Designed to support farmers with easy, quick disease identification.
docker build -t tomato-disease-api .
docker run -p 8000:8000 tomato-disease-api- Model Hosting: TensorFlow Serving on GCP
- API Server: Docker container on Amazon ECS
├── Api/
│ ├── api.py
│ ├── model_tf_serving.py
│ ├── requirements.txt
├── models/
│ ├── model.h5
│ └── model.tflite
├── Training/
│ └── Tomato_Disease_Prediction.ipynb
├── README.md
- Add support for more crop types.
- Integrate pest detection.
- Add local language support for UI.
- SMS or WhatsApp bot support for farmers without smartphones.
MIT License © SteveParadox