Pestify is an innovative Android application that transforms pest identification and management by integrating cutting-edge deep learning algorithms into a user-friendly mobile platform. The app empowers farmers and agricultural professionals to accurately identify pests in real-time using their smartphone cameras, providing instant species information, harm assessment, and actionable management strategies.

To democratize agricultural expertise through AI, making professional pest management accessible to every farmer worldwide.
Bridge the technology gap in agriculture by providing instant, accurate pest identification and management solutions directly to farmers' smartphones.
- ๐ธ Real-time Pest Identification: Instant analysis using smartphone cameras
- ๐ฑ Offline Functionality: Works in remote areas with limited connectivity
- ๐ฟ Comprehensive Database: Extensive coverage of pest species
- ๐จโ๐พ Farmer-Centric Design: Intuitive interface for agricultural users
- ๐ก๏ธ Management Strategies: Actionable pest control recommendations
- ๐ Data Analytics: Pest tracking and insight generation
- Multi-class pest classification
- Confidence scoring for predictions
- Historical identification tracking
- Image quality assessment
- Progressive learning system
- Python 3.6+
- TensorFlow 2.0+
- Keras
- Google Colab account (recommended for training)
- GPU access (optional but recommended)
- Android Studio Arctic Fox+
- Android SDK
- Java Development Kit (JDK) 8+
- Android device/emulator (API 21+)
- Minimum 4GB RAM
git clone https://github.com/VincentOracle/Pest-Identification-Android-App-Using-Deep-Learning-Algorithms.git
cd Pest-Identification-Android-App-Using-Deep-Learning-Algorithms
The pre-trained model is included, but for retraining:
-
Open Training Notebook
# Open pest7.ipynb in Google Colab from google.colab import drive drive.mount('/content/drive')
-
Setup Environment
!pip install tensorflow==2.10.0 !pip install opencv-python matplotlib seaborn
-
Run Training Pipeline
- Execute cells sequentially
- Monitor training progress
- Export trained model
- Launch Android Studio
- Select "Open an existing project"
- Navigate to cloned repository
// app/build.gradle
dependencies {
implementation 'org.tensorflow:tensorflow-lite:2.10.0'
implementation 'androidx.camera:camera-camera2:1.2.0'
implementation 'androidx.camera:camera-lifecycle:1.2.0'
implementation 'androidx.camera:camera-view:1.2.0'
}
- Connect Android device or start emulator
- Build project:
Build > Make Project
- Run app:
Run > Run 'app'
Pestify/
โโโ ๐ฑ android-app/ # Android application
โ โโโ app/src/main/java/ # Java source files
โ โ โโโ MainActivity.java # Main application logic
โ โ โโโ CameraActivity.java # Camera functionality
โ โ โโโ ImageProcessor.java # Image processing
โ โ โโโ PestClassifier.java # ML model integration
โ โโโ app/src/main/res/ # Resources
โ โ โโโ layout/ # UI layouts
โ โ โโโ drawable/ # Images and icons
โ โ โโโ values/ # Strings and styles
โ โโโ app/src/main/assets/ # ML model and assets
โ โโโ pest_model.tflite # Trained TensorFlow Lite model
โโโ ๐ค ml-model/ # Machine learning components
โ โโโ pest7.ipynb # Model training notebook
โ โโโ training/ # Training scripts
โ โ โโโ data_preprocessing.py
โ โ โโโ model_training.py
โ โ โโโ model_conversion.py
โ โโโ models/ # Trained models
โ โโโ pest_model.h5
โ โโโ pest_model.tflite
โโโ ๐ datasets/ # Pest image datasets
โ โโโ train/ # Training images
โ โโโ validation/ # Validation images
โ โโโ test/ # Test images
โโโ ๐ documentation/ # Project documentation
โ โโโ user_guide.md
โ โโโ technical_specs.md
โ โโโ api_reference.md
โโโ ๐ง tests/ # Test suites
โโโ unit_tests/
โโโ integration_tests/
โโโ performance_tests/
graph TD
A[Input Image] --> B[Image Preprocessing]
B --> C[MobileNet Base]
C --> D[Global Average Pooling]
D --> E[Dense 256 + BN + ReLU]
E --> F[Dropout 0.5]
F --> G[Dense 128 + BN + ReLU]
G --> H[Dropout 0.3]
H --> I[Output Layer]
I --> J[Pest Classification]
- Architecture: MobileNetV2
- Pre-trained Weights: ImageNet
- Input Size: 224ร224ร3
- Feature Extraction: Transfer learning
model = Sequential([
base_model,
GlobalAveragePooling2D(),
Dense(256, activation='relu'),
BatchNormalization(),
Dropout(0.5),
Dense(128, activation='relu'),
BatchNormalization(),
Dropout(0.3),
Dense(num_classes, activation='softmax')
])
# Compilation
model.compile(
optimizer=Adam(learning_rate=0.001),
loss='categorical_crossentropy',
metrics=['accuracy', 'precision', 'recall']
)
# Callbacks
callbacks = [
EarlyStopping(patience=10, restore_best_weights=True),
ReduceLROnPlateau(factor=0.2, patience=5),
ModelCheckpoint('best_model.h5', save_best_only=True)
]
- Kaggle Datasets: Primary pest image collections
- Agricultural Research Institutions: Specialized pest databases
- Field Collections: Real-world farm images
- Expert Validated: Domain expert annotations
Metric | Value |
---|---|
Total Images | 10,000+ |
Pest Categories | 25+ |
Image Resolution | 224ร224 |
Train-Validation Split | 95%-5% |
Augmentation Techniques | 8+ |
def preprocess_image(image_path):
# Load image
image = cv2.imread(image_path)
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
# Resize and normalize
image = cv2.resize(image, (224, 224))
image = image / 255.0
# Data augmentation (training only)
if training_mode:
image = apply_augmentation(image)
return image
def apply_augmentation(image):
augmentations = [
RandomRotation(0.2),
RandomZoom(0.2),
RandomFlip("horizontal"),
RandomContrast(0.2)
]
return random.choice(augmentations)(image)
- Real-time Camera: Live pest detection
- Gallery Upload: Existing image analysis
- Image Optimization: Auto-crop and enhance
- Quality Check: Image suitability validation
- Multi-class Classification: 25+ pest species
- Confidence Scoring: Probability estimates
- Similar Species: Alternative suggestions
- Detailed Information: Species characteristics
- Treatment Recommendations: Chemical and organic solutions
- Prevention Strategies: Long-term management
- Economic Impact: Cost-benefit analysis
- Environmental Considerations: Eco-friendly options
- Offline Processing: No internet required
- Fast Inference: <2 second processing time
- Low Memory Usage: Optimized for mobile devices
- Battery Efficient: Minimal power consumption
- Error Handling: Graceful failure recovery
# Training Configuration
TRAINING_CONFIG = {
'IMAGE_SIZE': (224, 224),
'BATCH_SIZE': 32,
'EPOCHS': 50,
'LEARNING_RATE': 0.001,
'VALIDATION_SPLIT': 0.05,
'AUGMENTATION_FACTOR': 5
}
# Model Configuration
MODEL_CONFIG = {
'BASE_MODEL': 'mobilenetv2',
'TRAINABLE_LAYERS': 50,
'DROPOUT_RATES': [0.5, 0.3],
'DENSE_UNITS': [256, 128]
}
<!-- AndroidManifest.xml -->
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
- Launch Application ๐ฑ
- Open Pestify app
- Grant necessary permissions
- View welcome screen
- Image Capture ๐ธ
- Tap camera button
- Position pest in frame
- Capture clear image
- Or select from gallery
- Analysis & Results ๐
- Automatic image processing
- Pest identification
- Confidence score display
- Detailed information
- Action Plan ๐ ๏ธ
- Review recommendations
- Implement strategies
- Save results
- Track progress
- Image Quality: Clear, well-lit photos
- Pest Positioning: Center the pest in frame
- Multiple Angles: Capture from different views
- Regular Monitoring: Consistent pest checks
- Record Keeping: Maintain identification history
Metric | Value | Description |
---|---|---|
Accuracy | 94.5% | Overall classification accuracy |
Precision | 93.8% | Low false positive rate |
Recall | 92.1% | Effective pest detection |
F1-Score | 92.9% | Balanced performance |
Inference Time | 1.2s | Mobile processing speed |
- App Size: <50MB
- Launch Time: <3 seconds
- Battery Impact: <5% per hour
- Memory Usage: <150MB RAM
- Storage: Minimal local storage
- Expand pest database to 50+ species
- Implement multi-language support
- Add community reporting features
- Integrate weather data analytics
- Develop farmer education modules
- iOS application development
- Predictive pest outbreak modeling
- Drone integration capabilities
- Marketplace for pest control products
- Government agency data sharing
- Global pest monitoring network
- AI-powered treatment optimization
- Blockchain for supply chain tracking
- Satellite imagery integration
- Climate change impact analysis
We welcome contributions from developers, researchers, and agricultural experts!
-
Fork the Repository
git fork https://github.com/VincentOracle/Pest-Identification-Android-App-Using-Deep-Learning-Algorithms.git
-
Create Feature Branch
git checkout -b feature/amazing-feature
-
Commit Changes
git commit -m "Add amazing feature"
-
Push and Create PR
git push origin feature/amazing-feature
- Model Improvement: Better accuracy and speed
- UI/UX Design: Enhanced user experience
- Documentation: Improved guides and tutorials
- Testing: Comprehensive test coverage
- Localization: Additional language support
This project is licensed under the MIT License - see the LICENSE file for details.
- โ Commercial use allowed
- โ Modification permitted
- โ Distribution allowed
- โ Private use allowed
- โ No warranty provided
- Kenyatta University - Academic guidance and resources
- Agricultural Department - Domain expertise and validation
- Research Supervisors - Technical guidance and mentorship
- Open Source Community - Libraries and frameworks
- Kaggle Community - Datasets and competitions
- TensorFlow Team - Machine learning framework
- Farmers and Agriculturists - Real-world testing and feedback
- Agricultural Experts - Pest knowledge and validation
- Beta Testers - Application testing and improvements
Were Vincent Ouma
- ๐ง Email: oumawere2001@gmail.com
- ๐ฑ Phone: +254 768653509
- ๐ซ Institution: Kenyatta University
- ๐ Department: Computing and Information Science
- ๐ GitHub: VincentOracle
- GitHub Issues: Bug reports and feature requests
- Email Support: Direct developer contact
- Documentation: Comprehensive user guides
- Community Forum: Planned for future release
git clone https://github.com/VincentOracle/Pest-Identification-Android-App-Using-Deep-Learning-Algorithms.git