Skip to content

VincentOracle/Pest-Identification-Android-App-Using-Deep-Learning-Algorithms

Repository files navigation

Pestify - Pest Identification Android App

Android TensorFlow Java Python

Revolutionizing Pest Management with Deep Learning

๐Ÿ“ฑ Project Overview

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.

image

๐ŸŽฏ Vision

To democratize agricultural expertise through AI, making professional pest management accessible to every farmer worldwide.

๐ŸŒŸ Mission

Bridge the technology gap in agriculture by providing instant, accurate pest identification and management solutions directly to farmers' smartphones.

๐Ÿš€ Key Features

๐Ÿ” Core Capabilities

  • ๐Ÿ“ธ 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

๐Ÿ’ก Advanced Features

  • Multi-class pest classification
  • Confidence scoring for predictions
  • Historical identification tracking
  • Image quality assessment
  • Progressive learning system

๐Ÿ› ๏ธ Technology Stack

๐Ÿ“ฑ Mobile Development

Android Studio Java TensorFlow Lite CameraX

๐Ÿค– Deep Learning & AI

Python TensorFlow Keras CNN MobileNet

๐Ÿ“Š Data Processing

NumPy OpenCV Pandas Matplotlib Seaborn

โ˜๏ธ Platforms & Infrastructure

Google Colab Kaggle Git GitHub

๐Ÿ“‹ Prerequisites

For Model Training ๐Ÿง 

  • Python 3.6+
  • TensorFlow 2.0+
  • Keras
  • Google Colab account (recommended for training)
  • GPU access (optional but recommended)

For Android App ๐Ÿ“ฑ

  • Android Studio Arctic Fox+
  • Android SDK
  • Java Development Kit (JDK) 8+
  • Android device/emulator (API 21+)
  • Minimum 4GB RAM

๐Ÿ”ง Installation & Setup

1. Clone Repository

git clone https://github.com/VincentOracle/Pest-Identification-Android-App-Using-Deep-Learning-Algorithms.git
cd Pest-Identification-Android-App-Using-Deep-Learning-Algorithms

2. Model Training (Optional) ๐Ÿค–

The pre-trained model is included, but for retraining:

  1. Open Training Notebook

    # Open pest7.ipynb in Google Colab
    from google.colab import drive
    drive.mount('/content/drive')
  2. Setup Environment

    !pip install tensorflow==2.10.0
    !pip install opencv-python matplotlib seaborn
  3. Run Training Pipeline

    • Execute cells sequentially
    • Monitor training progress
    • Export trained model

3. Android App Setup ๐Ÿ“ฑ

Step 1: Open in Android Studio

  • Launch Android Studio
  • Select "Open an existing project"
  • Navigate to cloned repository

Step 2: Configure Dependencies

// 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'
}

Step 3: Build and Run

  • Connect Android device or start emulator
  • Build project: Build > Make Project
  • Run app: Run > Run 'app'

๐Ÿ—‚๏ธ Project Structure

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/

๐Ÿง  Model Architecture

Deep Learning Pipeline

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]
Loading

Detailed Architecture

1. Base Model

  • Architecture: MobileNetV2
  • Pre-trained Weights: ImageNet
  • Input Size: 224ร—224ร—3
  • Feature Extraction: Transfer learning

2. Custom Classification Head

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')
])

3. Training Specifications

# 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)
]

๐Ÿ“Š Dataset Information

Data Sources ๐ŸŒ

  • Kaggle Datasets: Primary pest image collections
  • Agricultural Research Institutions: Specialized pest databases
  • Field Collections: Real-world farm images
  • Expert Validated: Domain expert annotations

Data Statistics

Metric Value
Total Images 10,000+
Pest Categories 25+
Image Resolution 224ร—224
Train-Validation Split 95%-5%
Augmentation Techniques 8+

Data Preprocessing Pipeline

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)

๐ŸŽฏ Key Functionalities

Core Features โœจ

1. Image Capture & Processing

  • Real-time Camera: Live pest detection
  • Gallery Upload: Existing image analysis
  • Image Optimization: Auto-crop and enhance
  • Quality Check: Image suitability validation

2. Pest Identification

  • Multi-class Classification: 25+ pest species
  • Confidence Scoring: Probability estimates
  • Similar Species: Alternative suggestions
  • Detailed Information: Species characteristics

3. Management System

  • Treatment Recommendations: Chemical and organic solutions
  • Prevention Strategies: Long-term management
  • Economic Impact: Cost-benefit analysis
  • Environmental Considerations: Eco-friendly options

Technical Capabilities โšก

  • 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

โš™๏ธ Configuration

Model Parameters

# 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]
}

Android Permissions

<!-- 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" />

๐Ÿš€ Usage Guide

Step-by-Step Workflow

  1. Launch Application ๐Ÿ“ฑ
    • Open Pestify app
    • Grant necessary permissions
    • View welcome screen

6aa87fe0-7152-44cb-b404-fe8e12d5a83d

  1. Image Capture ๐Ÿ“ธ
    • Tap camera button
    • Position pest in frame
    • Capture clear image
    • Or select from gallery

369b6255-cc0e-4fed-9941-76c59cd35cf4

fbccf2fc-6681-4708-8877-2da29d9b15e6

  1. Analysis & Results ๐Ÿ”
    • Automatic image processing
    • Pest identification
    • Confidence score display
    • Detailed information

718c1b40-e4db-43b3-af1d-7fc16a918f62

  1. Action Plan ๐Ÿ› ๏ธ
    • Review recommendations
    • Implement strategies
    • Save results
    • Track progress

Best Practices ๐ŸŒŸ

  • 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

๐Ÿ“ˆ Performance Metrics

Model Performance ๐ŸŽฏ

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

d32b79c6-891b-468f-8b94-81f763433156

User Experience ๐Ÿ“Š

  • App Size: <50MB
  • Launch Time: <3 seconds
  • Battery Impact: <5% per hour
  • Memory Usage: <150MB RAM
  • Storage: Minimal local storage

๐Ÿ”ฎ Future Enhancements

Short-term Goals (2024) ๐ŸŽฏ

  • Expand pest database to 50+ species
  • Implement multi-language support
  • Add community reporting features
  • Integrate weather data analytics
  • Develop farmer education modules

Medium-term Vision (2025) ๐ŸŒŸ

  • iOS application development
  • Predictive pest outbreak modeling
  • Drone integration capabilities
  • Marketplace for pest control products
  • Government agency data sharing

Long-term Roadmap (2026+) ๐Ÿš€

  • Global pest monitoring network
  • AI-powered treatment optimization
  • Blockchain for supply chain tracking
  • Satellite imagery integration
  • Climate change impact analysis

๐Ÿค Contributing

We welcome contributions from developers, researchers, and agricultural experts!

How to Contribute ๐Ÿ‘ฅ

  1. Fork the Repository

    git fork https://github.com/VincentOracle/Pest-Identification-Android-App-Using-Deep-Learning-Algorithms.git
  2. Create Feature Branch

    git checkout -b feature/amazing-feature
  3. Commit Changes

    git commit -m "Add amazing feature"
  4. Push and Create PR

    git push origin feature/amazing-feature

Contribution Areas ๐Ÿ› ๏ธ

  • 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

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

License Features โœ…

  • โœ… Commercial use allowed
  • โœ… Modification permitted
  • โœ… Distribution allowed
  • โœ… Private use allowed
  • โœ… No warranty provided

๐Ÿ™ Acknowledgments

Academic Support ๐ŸŽ“

  • Kenyatta University - Academic guidance and resources
  • Agricultural Department - Domain expertise and validation
  • Research Supervisors - Technical guidance and mentorship

Technical Contributions ๐Ÿ’ป

  • Open Source Community - Libraries and frameworks
  • Kaggle Community - Datasets and competitions
  • TensorFlow Team - Machine learning framework

Field Support ๐ŸŒพ

  • Farmers and Agriculturists - Real-world testing and feedback
  • Agricultural Experts - Pest knowledge and validation
  • Beta Testers - Application testing and improvements

๐Ÿ“ž Support & Contact

Primary Developer

Were Vincent Ouma

  • ๐Ÿ“ง Email: oumawere2001@gmail.com
  • ๐Ÿ“ฑ Phone: +254 768653509
  • ๐Ÿซ Institution: Kenyatta University
  • ๐ŸŽ“ Department: Computing and Information Science
  • ๐Ÿ”— GitHub: VincentOracle

Support Channels ๐Ÿ“ž

  • GitHub Issues: Bug reports and feature requests
  • Email Support: Direct developer contact
  • Documentation: Comprehensive user guides
  • Community Forum: Planned for future release

Repository Access ๐Ÿ”—

git clone https://github.com/VincentOracle/Pest-Identification-Android-App-Using-Deep-Learning-Algorithms.git

๐ŸŒฑ Pestify - Growing Smarter, Farming Better ๐Ÿšœ

Empowering Farmers with AI-Driven Pest Management Solutions

Last Updated: January 2024
Project Status: Active Development
Version: 1.0.0

About

This is a Pest Identification Android App Using Deep Learning Algorithms: Convolution Neural Network

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages