This application is a full-stack AI pest management tool that detects common agricultural pests from images and recommends natural, non-harmful pesticides.
It combines a TensorFlow MobileNetV2 model for classification, a Flask REST API backend, and a Flutter mobile frontend for an end-to-end pest detection workflow.
The system accepts pest images, classifies them into one of 12 categories, fetches natural pesticide recommendations from a curated dataset, and displays results instantly in a mobile app.
📸 App Screenshots
------ 🦋 Pest Image Classification: Detects pests such as ant, bee, beetle, caterpillar, earthworm, earwig, grasshopper, moth, slug, snail, wasp, and weevil.
- 🌱 Natural Pesticide Recommendation: Suggests eco-friendly, non-chemical pesticides from a local dataset.
- 📱 Mobile Frontend: Flutter-based UI for easy image uploads and instant results.
- ⚡ REST API Backend: Flask API processes uploaded images and returns pest classification + pesticide suggestion in JSON format.
- 📦 Offline Support: TFLite model version available for offline mobile predictions.
- Image Capture/Upload: User takes or selects a pest image in the Flutter app.
- API Request: Image is sent to the Flask backend via POST request.
- Preprocessing: The image is resized to 224×224 and normalized using MobileNetV2’s preprocess function.
- Prediction: The TensorFlow model outputs class probabilities; the highest probability is chosen as the detected pest.
- Recommendation: The pest name is matched in a CSV dataset to retrieve the recommended natural pesticide.
- Response: Backend sends a JSON response with the pest name and recommended pesticide, displayed in the app.
- Backend: Python, Flask, TensorFlow, Pandas, Pillow
- Frontend: Flutter, Dart
- Model: MobileNetV2 (fine-tuned)
- Data Storage: CSV for pesticide mapping
- Deployment: Local or cloud-hosted Flask API
- Python 3.9+
- Flutter SDK installed
- pip for Python dependencies
git clone <repository-url>
cd <repository-directory>cd backend
pip install -r requirements.txt
python app.pycd frontend_flutter
flutter pub get
flutter runBackend API Endpoint:
POST /predict
Form Data:
image— pest image file
Example:
curl -X POST -F "image=@ant.jpg" http://localhost:5000/predictResponse:
{
"pest": "ant",
"recommended_pesticide": "Neem Oil"
}project/
├── backend/
│ ├── app.py # Flask API
│ ├── data/ # CSV pesticide dataset
│ ├── model/ # Trained .h5 model
│ ├── uploads/ # Uploaded images
│ └── requirements.txt
│
├── frontend_flutter/ # Flutter app
│ ├── lib/ # Dart code
│ ├── assets/
│ ├── android/ ios/ web/ etc.
│
├── ML/
│ ├── agriculture pests image dataset/
│ └── notebook/ # Jupyter notebook & models
│
├── image_test/ # Test images
├── demo/ # App screenshots
└── README.md

