An intelligent plant disease detection platform that leverages deep learning to identify plant diseases from leaf images. Built with a modern two-backend architecture for scalability and maintainability.
- Overview
- System Architecture
- Features
- Technology Stack
- Dataset Information
- Installation
- Usage
- API Documentation
- Project Structure
- Model Performance
- Contributing
- License
- Acknowledgments
Pestector is a cutting-edge plant disease detection system designed to help farmers, agricultural professionals, and gardening enthusiasts identify plant diseases quickly and accurately. By simply uploading an image of a plant leaf, users receive instant diagnosis powered by state-of-the-art deep learning models.
- Real-time Disease Detection: Instant analysis of plant leaf images
- 38 Disease Classes: Covers a wide range of crop diseases
- 87,000+ Training Images: Trained on a comprehensive dataset
- Two-Backend Architecture: Separation of concerns for better scalability
- User-Friendly Interface: Clean, responsive web interface
Pestector implements a Two-Backend Architecture to separate AI processing from application logic, enhancing scalability and maintainability.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Frontend Layer โ
โ (Vanilla JS + HTML + Tailwind CSS) โ
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Node.js Backend Server โ
โ (Application Logic & API Management) โ
โ โข User Authentication & Authorization โ
โ โข Request Routing โ
โ โข Database Management โ
โ โข Static File Serving (from public/) โ
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Python AI Backend Server โ
โ (Deep Learning & Image Processing) โ
โ โข Image Preprocessing โ
โ โข Deep Learning Model Inference โ
โ โข Disease Classification โ
โ โข Prediction Results Generation โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- User uploads plant leaf image via web interface
- Frontend sends image to Node.js backend
- Node.js backend forwards image to Python AI backend
- Python AI backend processes image and runs ML model
- Classification results return to Node.js backend
- Node.js backend stores results in database
- Results displayed to user in real-time
- Python AI Backend: github.com/Abdelrahman968/aibackend-pestector
- Node.js Backend: github.com/Abdelrahman968/pestector-nodeJS
- โ Image Upload: Support for common image formats (JPG, PNG, JPEG)
- โ Real-time Analysis: Instant disease detection and classification
- โ 38 Disease Categories: Comprehensive coverage of plant diseases
- โ Confidence Scores: Prediction confidence for each classification
- โ User Management: Secure authentication and user profiles
- โ History Tracking: View past disease detections
- โ Responsive Design: Works on desktop, tablet, and mobile
- ๐ Secure Authentication: JWT-based user authentication
- ๐ Dashboard: User analytics and detection history
- ๐จ Modern UI: Clean interface built with Tailwind CSS
- ๐ RESTful API: Well-documented API endpoints
- ๐ฑ Mobile Responsive: Optimized for all screen sizes
- JavaScript: Vanilla JS for lightweight performance
- HTML5: Semantic markup
- Tailwind CSS: Utility-first CSS framework
- Fetch API: For HTTP requests
- Runtime: Node.js 14+
- Framework: Express.js
- Database: MongoDB / PostgreSQL
- Authentication: JWT (JSON Web Tokens)
- File Upload: Multer
- HTTP Client: Axios
- Language: Python 3.8+
- Deep Learning: TensorFlow / Keras / PyTorch
- Image Processing: OpenCV, PIL
- Web Framework: Flask / FastAPI
- Data Processing: NumPy, Pandas
- Version Control: Git & GitHub
- Containerization: Docker (optional)
- API Testing: Postman
The AI model is trained on the New Plant Diseases Dataset from Kaggle.
- Source: New Plant Diseases Dataset
- Total Images: ~87,000 RGB images
- Image Categories: 38 different classes
- Image Types: Healthy and diseased crop leaves
- Augmentation: Offline data augmentation applied
Training Set : 80% (~70,000 images)
Validation Set : 20% (~17,000 images)
Test Set : 33 images (separate test folder)
The dataset covers various crops including:
- ๐ Apple (4 classes: healthy, apple scab, black rot, cedar rust)
- ๐ฝ Corn (4 classes: healthy, cercospora, common rust, northern leaf blight)
- ๐ Grape (4 classes: healthy, black rot, esca, leaf blight)
- ๐ Peach (2 classes: healthy, bacterial spot)
- ๐ถ๏ธ Pepper (2 classes: healthy, bacterial spot)
- ๐ฅ Potato (3 classes: healthy, early blight, late blight)
- ๐ Strawberry (2 classes: healthy, leaf scorch)
- ๐ Tomato (10 classes: healthy, various diseases)
- And more...
- Node.js 14+ and npm
- Python 3.8+
- MongoDB or PostgreSQL
- Git
# Clone Node.js Backend
git clone https://github.com/Abdelrahman968/pestector-nodeJS.git
cd pestector-nodeJS
# Clone Python AI Backend
git clone https://github.com/Abdelrahman968/aibackend-pestector.git
cd aibackend-pestectorcd pestector-nodeJS
# Install dependencies
npm install
# Create .env file
cp .env.example .env
# Configure environment variables
# Edit .env with your database credentials, JWT secret, etc.
# Start the server
npm startcd aibackend-pestector
# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Download the trained model (if not included)
# Place model file in /models directory
# Start the server
python app.pyPORT=3000
MONGODB_URI=mongodb://localhost:27017/pestector
JWT_SECRET=your_secret_key_here
AI_BACKEND_URL=http://localhost:5000PORT = 5000
MODEL_PATH = './models/plant_disease_model.h5'
IMAGE_SIZE = (224, 224)
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg'}-
Start Python AI Backend (Terminal 1):
cd aibackend-pestector python app.py -
Start Node.js Backend (Terminal 2):
cd pestector-nodeJS npm start -
Access the Application: Open your browser and navigate to
http://localhost:3000
- Register/Login: Create an account or log in
- Upload Image: Click "Upload" and select a plant leaf image
- View Results: See the disease prediction with confidence score
- Check History: View past detections in your dashboard
POST /api/auth/register
POST /api/auth/login
POST /api/auth/logout
GET /api/auth/mePOST /api/detect
GET /api/detections
GET /api/detections/:id
DELETE /api/detections/:idGET /api/users/profile
PUT /api/users/profile
GET /api/users/historyPOST /predictRequest Body (multipart/form-data):
{
"file": "<image_file>"
}Response:
{
"success": true,
"prediction": {
"class": "Tomato___Late_blight",
"confidence": 0.95,
"disease_name": "Late Blight",
"plant_type": "Tomato"
},
"timestamp": "2026-02-04T10:30:00Z"
}GET /healthResponse:
{
"status": "healthy",
"model_loaded": true,
"version": "1.0.0"
}โโโ ๐ config
โ โโโ ๐ config.js
โ โโโ ๐ index.js
โโโ ๐ controllers
โ โโโ ๐ index.js
โ โโโ ๐ recommendationController.js
โโโ ๐ middleware
โ โโโ ๐ auth.js
โ โโโ ๐ guest.js
โ โโโ ๐ index.js
โ โโโ ๐ isAdmin.js
โโโ ๐ models
โ โโโ ๐ Analytics.js
โ โโโ ๐ AuditLog.js
โ โโโ ๐ Chat.js
โ โโโ ๐ Comment.js
โ โโโ ๐ Contact.js
โ โโโ ๐ GuestUser.js
โ โโโ ๐ History.js
โ โโโ ๐ ModelFeedback.js
โ โโโ ๐ Notification.js
โ โโโ ๐ Plant.js
โ โโโ ๐ Post.js
โ โโโ ๐ Recommendation.js
โ โโโ ๐ Reminder.js
โ โโโ ๐ Subscription.js
โ โโโ ๐ TreatmentPlan.js
โ โโโ ๐ TwoFactorCode.js
โ โโโ ๐ User.js
โ โโโ ๐ index.js
โโโ ๐ public
โ โโโ ๐ css
โ โโโ ๐ img
โ โ โโโ ๐ articles
โ โ โ โโโ ๐ผ๏ธ artic1.webp
โ โ โ โโโ ๐ผ๏ธ artic2.jpg
โ โ โ โโโ ๐ผ๏ธ artic3.webp
โ โ โโโ ๐ new
โ โ โ โโโ ๐ผ๏ธ Early-Blight-Disease-Treatment-Control-2048x1152.webp
โ โ โ โโโ ๐ผ๏ธ test.png
โ โ โโโ ๐ผ๏ธ appstore.png
โ โ โโโ ๐ผ๏ธ goolgeplay.png
โ โ โโโ ๐ผ๏ธ image.png
โ โ โโโ ๐ผ๏ธ plant-background.jpg
โ โ โโโ ๐ผ๏ธ plant.png
โ โ โโโ ๐ผ๏ธ step1.png
โ โ โโโ ๐ผ๏ธ step2.png
โ โ โโโ ๐ผ๏ธ step3.png
โ โ โโโ ๐ผ๏ธ step4.png
โ โ โโโ ๐ผ๏ธ user-profile.png
โ โ โโโ ๐ผ๏ธ user1.png
โ โ โโโ ๐ผ๏ธ user2.png
โ โ โโโ ๐ผ๏ธ user3.png
โ โโโ ๐ not-now
โ โ โโโ ๐ admin-new.html
โ โ โโโ ๐ admin.html
โ โ โโโ ๐ adminSub.html
โ โ โโโ ๐ doc.html
โ โ โโโ ๐ research-papers.html
โ โโโ ๐ plants
โ โ โโโ ๐ Blueberry
โ โ โ โโโ ๐ผ๏ธ Blueberryhealthy.JPG
โ โ โโโ ๐ Cherry
โ โ โ โโโ ๐ผ๏ธ CherryPowderymildew.JPG
โ โ โ โโโ ๐ผ๏ธ Cherryhealthy.JPG
โ โ โโโ ๐ Corn
โ โ โ โโโ ๐ผ๏ธ CornCommonRust1.JPG
โ โ โ โโโ ๐ผ๏ธ Corn_(maize)Cercospora_leaf_spot Gray_leaf_spot.JPG
โ โ โ โโโ ๐ผ๏ธ Corn_(maize)___Northern_Leaf_Blight.JPG
โ โ โ โโโ ๐ผ๏ธ Corn_(maize)___healthy.jpg
โ โ โโโ ๐ Grape
โ โ โ โโโ ๐ผ๏ธ Grape___Black_rot.JPG
โ โ โ โโโ ๐ผ๏ธ Grape___Esca_(Black_Measles).JPG
โ โ โ โโโ ๐ผ๏ธ Grape___Leaf_blight_(Isariopsis_Leaf_Spot).JPG
โ โ โ โโโ ๐ผ๏ธ Grape___healthy.JPG
โ โ โโโ ๐ Orange
โ โ โ โโโ ๐ผ๏ธ Orange___Haunglongbing_(Citrus_greening).JPG
โ โ โโโ ๐ Peach
โ โ โ โโโ ๐ผ๏ธ Peach___Bacterial_spot.JPG
โ โ โ โโโ ๐ผ๏ธ Peach___healthy.JPG
โ โ โโโ ๐ Pepper
โ โ โ โโโ ๐ผ๏ธ Pepper,_bell___Bacterial_spot.JPG
โ โ โ โโโ ๐ผ๏ธ Pepper,_bell___healthy.JPG
โ โ โ โโโ ๐ผ๏ธ Potato___Early_blight.JPG
โ โ โโโ ๐ Potato
โ โ โ โโโ ๐ผ๏ธ Potato___Early_blight.JPG
โ โ โ โโโ ๐ผ๏ธ Potato___Late_blight.JPG
โ โ โ โโโ ๐ผ๏ธ Potato___healthy.JPG
โ โ โโโ ๐ Raspberry
โ โ โ โโโ ๐ผ๏ธ Raspberry___healthy.JPG
โ โ โโโ ๐ Soybean
โ โ โ โโโ ๐ผ๏ธ Soybean___healthy.JPG
โ โ โโโ ๐ Squash
โ โ โ โโโ ๐ผ๏ธ Squash___Powdery_mildew.JPG
โ โ โโโ ๐ Strawberry
โ โ โ โโโ ๐ผ๏ธ Strawberry___Leaf_scorch.JPG
โ โ โ โโโ ๐ผ๏ธ Strawberry___healthy.JPG
โ โ โโโ ๐ Tomato
โ โ โ โโโ ๐ผ๏ธ Tomato___Bacterial_spot.JPG
โ โ โ โโโ ๐ผ๏ธ Tomato___Early_blight.JPG
โ โ โ โโโ ๐ผ๏ธ Tomato___Late_blight.JPG
โ โ โ โโโ ๐ผ๏ธ Tomato___Leaf_Mold.JPG
โ โ โ โโโ ๐ผ๏ธ Tomato___Septoria_leaf_spot.JPG
โ โ โ โโโ ๐ผ๏ธ Tomato___Spider_mites Two-spotted_spider_mite.JPG
โ โ โ โโโ ๐ผ๏ธ Tomato___Target_Spot.JPG
โ โ โ โโโ ๐ผ๏ธ Tomato___Tomato_Yellow_Leaf_Curl_Virus.JPG
โ โ โ โโโ ๐ผ๏ธ Tomato___Tomato_mosaic_virus.JPG
โ โ โ โโโ ๐ผ๏ธ Tomato___healthy.JPG
โ โ โโโ ๐ apple
โ โ โโโ ๐ผ๏ธ AppleBlackrot.JPG
โ โ โโโ ๐ผ๏ธ AppleCedarRust1.JPG
โ โ โโโ ๐ผ๏ธ AppleScab1.JPG
โ โ โโโ ๐ผ๏ธ Applehealthy.JPG
โ โโโ ๐ scripts
โ โ โโโ ๐ admin.js
โ โ โโโ ๐ contact.js
โ โ โโโ ๐ dashboard.js
โ โ โโโ ๐ forgot-password.js
โ โ โโโ ๐ header.js
โ โ โโโ ๐ history.js
โ โ โโโ ๐ library.js
โ โ โโโ ๐ login.js
โ โ โโโ ๐ plant.js
โ โ โโโ ๐ profile.js
โ โ โโโ ๐ recommendations.js
โ โ โโโ ๐ reminders.js
โ โ โโโ ๐ reset-password.js
โ โ โโโ ๐ scan.js
โ โ โโโ ๐ subscribe.js
โ โ โโโ ๐ treatment.js
โ โ โโโ ๐ weather.js
โ โโโ ๐ about-us.html
โ โโโ ๐ adding-files.html
โ โโโ ๐ adminSub.html
โ โโโ ๐ advertisement.html
โ โโโ ๐ contact.html
โ โโโ ๐ dashboard.html
โ โโโ ๐ disease-library.html
โ โโโ ๐ dmca.html
โ โโโ ๐ donate.html
โ โโโ ๐ forgot-password.html
โ โโโ ๐ help.html
โ โโโ ๐ history.html
โ โโโ ๐ home.html
โ โโโ ๐ index.html
โ โโโ ๐ indexdev.html
โ โโโ ๐ login.html
โ โโโ ๐ official-rules.html
โ โโโ ๐ plants.html
โ โโโ ๐ privacy-policy.html
โ โโโ ๐ profile.html
โ โโโ ๐ recommendation.html
โ โโโ ๐ register.html
โ โโโ ๐ reminders.html
โ โโโ ๐ reset-password.html
โ โโโ ๐ scan.html
โ โโโ ๐ subscribe.html
โ โโโ ๐ terms.html
โ โโโ ๐ treatment.html
โ โโโ ๐ weather.html
โโโ ๐ routes
โ โโโ ๐ admin.js
โ โโโ ๐ adminSubscriptions.js
โ โโโ ๐ analytics.js
โ โโโ ๐ auth.js
โ โโโ ๐ chat.js
โ โโโ ๐ classify.js
โ โโโ ๐ contact.js
โ โโโ ๐ feedback.js
โ โโโ ๐ forum.js
โ โโโ ๐ general.js
โ โโโ ๐ guest.js
โ โโโ ๐ history.js
โ โโโ ๐ index.js
โ โโโ ๐ notification.js
โ โโโ ๐ plants.js
โ โโโ ๐ posts.js
โ โโโ ๐ recommendationRoutes.js
โ โโโ ๐ reminders.js
โ โโโ ๐ reports.js
โ โโโ ๐ subscription.js
โ โโโ ๐ treatment.js
โ โโโ ๐ weather.js
โโโ ๐ test
โโโ ๐ uploads
โ โโโ ๐ 2ab9d227-2420-4f26-974e-474e252854e0
โ โ โโโ ๐ผ๏ธ PotatoHealthy2-1746978295916-4cee9211.jpeg
โ โ โโโ ๐ผ๏ธ b2600118-800px-wm-1751451383175-fb364c64.jpg
โ โโโ ๐ 4c642cbd-b51a-4ca8-8ab5-5e0dace3cf67
โ โ โโโ ๐ผ๏ธ AppleCedarRust1-1752247645794-24f28feb.JPG
โ โโโ ๐ 548d8f65-b5f7-42ad-b928-846e8d5baa93
โ โ โโโ ๐ผ๏ธ AppleCedarRust1-1742793756033.JPG
โ โ โโโ ๐ผ๏ธ AppleCedarRust1-1742794028211.JPG
โ โ โโโ ๐ผ๏ธ AppleScab1-1742793998340.JPG
โ โโโ ๐ 67cf8380ee7c7f4c3915d14d
โ โ โโโ ๐ผ๏ธ CornCommonRust1-1741655108883.JPG
โ โโโ ๐ 67cf862b1728ed3ffc473bfc
โ โ โโโ ๐ผ๏ธ 00a6039c-e425-4f7d-81b1-d6b0e668517e___RS_HL 7669-1741656219547.JPG
โ โ โโโ ๐ผ๏ธ ......
โ โโโ ๐ 67d07c15b4acd2eca111e638
โ โ โโโ ๐ผ๏ธ 04-1744578691532.jpg
โ โ โโโ ๐ผ๏ธ AppleBlackrot-1742571106731.JPG
โ โ โโโ ๐ผ๏ธ ......
โโโ ๐ utils
โ โโโ ๐ formatDate.js
โ โโโ ๐ index.js
โ โโโ ๐ mailer.js
โ โโโ ๐ recommendationEngine.js
โ โโโ ๐ whatsappValidation.js
โโโ โ๏ธ .gitignore
โโโ ๐ app.js
โโโ ๐ log.txt
โโโ โ๏ธ package-lock.json
โโโ โ๏ธ package.json
โโโ ๐ server.js
โโโ ๐ staticRoutes.js
โโโ ๐ test-email.js
aibackend-pestector/
โโโ models/ # Trained ML models
โ โโโ plant_disease_vit_BEST_model_state.pth
โ โโโ vgg_model.h5
โโโ static/ # Simple UI
โ โโโ HTML,CSS,JS Files
โโโ uploads/ # User Images
โ โโโ ...images.png
โโโ requirements.txt
โโโ treatment_recommendations.json
โโโ reason.json
โโโ app_combined_v2_2_5.log # Log File
โโโ app.py # FastAPI app
- Training Accuracy: ~98%
- Validation Accuracy: ~96%
- Test Accuracy: ~95%
- Training Time: ~2 hours on GPU
- Model Size: ~50 MB
- Average Prediction Time: < 500ms
- Image Preprocessing: < 100ms
- Model Inference: < 300ms
- Response Time (End-to-End): < 1s
The model shows high accuracy across all 38 classes with minimal misclassification between visually similar disease categories.
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow existing code style
- Write descriptive commit messages
- Add tests for new features
- Update documentation as needed
This project is licensed under the MIT License - see the LICENSE file for details.
- Dataset: New Plant Diseases Dataset by Samir Bhattarai
- Deep Learning Framework: TensorFlow/Keras team
- Community: Open-source contributors and agricultural technology enthusiasts
- Developer: Abdelrahman968
- GitHub: @Abdelrahman968
- Email: Contact via GitHub
- [โ ] Mobile application (iOS & Android)
- Real-time camera detection
- [โ ] Treatment recommendations
- Multilingual support
- Offline mode capability
- Integration with IoT sensors
- [โ ] Advanced analytics dashboard
- [โ ] Community forum for farmers
Coming soon
Made with โค๏ธ for sustainable agriculture