Skip to content

abhi-abhi86/disease-predictor

Repository files navigation

πŸ”¬ Multi-Species Disease Detection and Management System

Python PySide6 PyTorch License: MIT Stars

AI-powered disease detection for Plants, Humans, and Animals | Desktop GUI Application | Offline-First | Privacy-Focused

An advanced desktop application that uses deep learning to detect and diagnose diseases across multiple species. Built with PyTorch and PySide6, featuring a modern GUI, real-time image analysis, and comprehensive disease information with treatment recommendations.

πŸš€ Quick Start β€’ ✨ Features β€’ πŸ“Έ Screenshots β€’ πŸ› οΈ Installation β€’ πŸ“– Usage β€’ 🀝 Contributing


🌟 What Makes This Special?

The Complete Disease Detection Solution

  • βœ… Multi-Species Support - Detect diseases in plants, humans, and animals from one application
  • βœ… Offline-First - Works completely offline, no internet required after setup
  • βœ… Privacy-Focused - All data stays on your device, no external APIs or cloud services
  • βœ… Custom Training - Train your own models with custom datasets
  • βœ… Modern GUI - Beautiful, intuitive desktop interface built with PySide6
  • βœ… Comprehensive Database - 27+ diseases with detailed information and treatments
  • βœ… Smart Validation - Rejects invalid images (diagrams, screenshots, text) automatically
  • βœ… Research Integration - Fetches Wikipedia and PubMed research data
  • βœ… Report Generation - Create PDF and HTML reports of diagnoses
  • βœ… Interactive Maps - Visualize disease distribution geographically

✨ Features

Core Capabilities

  • 🎯 AI-Powered Detection: Deep learning model (MobileNetV2) trained on 26 disease classes
  • πŸ–ΌοΈ Image Analysis: Upload and analyze disease images with confidence scoring
  • πŸ’¬ AI Chatbot: Interactive chatbot for disease information and guidance
  • πŸ“Š Disease Database: Comprehensive information on 27+ diseases across all species
  • πŸ—ΊοΈ Geographic Mapping: Visualize disease locations with interactive Folium maps
  • πŸ“„ Report Generation: Generate detailed PDF and HTML reports
  • πŸ” Smart Search: BM25-based search engine for finding disease information
  • 🌐 Research Integration: Automatic Wikipedia and PubMed research fetching
  • πŸ“ˆ Confidence Scoring: Shows prediction confidence with intelligent thresholding
  • ⚑ Real-time Processing: Fast inference with caching for improved performance

Technical Features

  • Image Validation: Automatically detects and rejects non-disease images (diagrams, text, screenshots)
  • Thread-Safe UI: Proper Qt threading to prevent crashes and ensure smooth operation
  • Caching System: In-memory and persistent caching for Wikipedia and PubMed data
  • Fuzzy Matching: Intelligent disease name matching using Levenshtein distance
  • Data Augmentation: Built-in augmentation for model training
  • Model Versioning: Track and manage different model versions
  • Error Handling: Robust error handling with user-friendly messages

User Interface

  • Modern Design: Clean, professional interface with dark mode support
  • Tabbed Interface: Separate tabs for Plants, Humans, and Animals
  • Image Preview: Visual feedback for uploaded images
  • Progress Indicators: Real-time progress updates during analysis
  • Interactive Results: Expandable disease information with stages, causes, and treatments
  • Map Visualization: Interactive maps showing disease locations
  • Report Preview: Preview generated reports before saving

πŸ“Έ Screenshots

Main Application Window

The application features a modern, tabbed interface for easy navigation between species:

  • Plant Diseases Tab: Detect crop and plant diseases
  • Human Diseases Tab: Analyze skin conditions and health issues
  • Animal Diseases Tab: Identify livestock and pet health problems

Key Features in Action

  • Image Upload: Drag-and-drop or browse for images
  • AI Analysis: Real-time disease detection with confidence scores
  • Disease Information: Detailed descriptions, symptoms, causes, and treatments
  • Research Data: Automatic Wikipedia and PubMed integration
  • Report Generation: Professional PDF and HTML reports
  • Interactive Maps: Geographic visualization of disease locations

πŸ› οΈ Installation

Prerequisites

  • Python 3.14+ (or Python 3.13+)
  • macOS, Linux, or Windows
  • 4GB RAM minimum (8GB recommended)
  • 500MB free disk space

Quick Install

# 1. Clone the repository
git clone https://github.com/abhi-abhi86/disease-predictor.git
cd disease-predictor

# 2. Create virtual environment
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# 3. Install dependencies
pip install -r comprehensive_requirements.txt

# 4. Run the application
./run_app.sh  # On Windows: python main.py

Detailed Installation

Click to expand detailed installation steps

Step 1: System Dependencies

macOS:

# Install Homebrew if not already installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install Python 3.14
brew install python@3.14

Linux (Ubuntu/Debian):

sudo apt update
sudo apt install python3.14 python3.14-venv python3-pip

Windows:

  • Download Python 3.14 from python.org
  • Make sure to check "Add Python to PATH" during installation

Step 2: Clone and Setup

# Clone repository
git clone https://github.com/abhi-abhi86/disease-predictor.git
cd disease-predictor

# Create virtual environment
python3 -m venv venv

# Activate virtual environment
# macOS/Linux:
source venv/bin/activate
# Windows:
venv\Scripts\activate

# Upgrade pip
pip install --upgrade pip

Step 3: Install Dependencies

# Install all required packages
pip install -r comprehensive_requirements.txt

# Verify installation
python verify_imports.py

Step 4: Train Model (Optional)

If you want to train your own model:

cd DiseaseDetectionApp
python train_disease_classifier.py
# Or if you encounter SSL errors:
./run_train.sh

The pre-trained model is included, so this step is optional.


πŸ“– Usage

Running the Application

# Activate virtual environment
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Run the application
./run_app.sh  # On Windows: python main.py

Using the Application

  1. Select Species Tab

    • Choose between Plants, Humans, or Animals
  2. Upload Image

    • Click "Upload Image" button
    • Select a clear photo showing disease symptoms
    • Supported formats: JPG, PNG, JPEG
  3. Analyze

    • Click "Diagnose" button
    • Wait for AI analysis (usually 2-5 seconds)
    • View results with confidence score
  4. Review Results

    • Read disease name and description
    • Check symptoms, causes, and risk factors
    • Review treatment recommendations
    • View Wikipedia and PubMed research
  5. Generate Reports

    • Click "Reports" menu
    • Choose PDF or HTML format
    • Save report to your computer
  6. Use Additional Features

    • Chatbot: Ask questions about diseases
    • Map View: See disease locations on interactive map
    • Search: Find diseases by name or symptoms

Command Line Usage

# Predict disease from image
cd DiseaseDetectionApp
python predict_disease.py path/to/image.jpg

# Train custom model
./run_train.sh

# Run tests
python test_disease_detection.py

πŸ—‚οΈ Project Structure

disease-predictor/
β”œβ”€β”€ DiseaseDetectionApp/          # Main application directory
β”‚   β”œβ”€β”€ core/                     # Core functionality modules
β”‚   β”‚   β”œβ”€β”€ ml_processor.py       # AI model and prediction logic
β”‚   β”‚   β”œβ”€β”€ worker.py             # Background worker for threading
β”‚   β”‚   β”œβ”€β”€ data_handler.py       # Disease database management
β”‚   β”‚   β”œβ”€β”€ llm_integrator.py     # AI chatbot integration
β”‚   β”‚   β”œβ”€β”€ search_engine.py      # BM25 search functionality
β”‚   β”‚   β”œβ”€β”€ report_generator.py   # PDF report generation
β”‚   β”‚   β”œβ”€β”€ html_report_generator.py  # HTML report generation
β”‚   β”‚   β”œβ”€β”€ wikipedia_integration.py  # Wikipedia API
β”‚   β”‚   β”œβ”€β”€ ncbi_integration.py   # PubMed research fetching
β”‚   β”‚   └── google_search.py      # Web search integration
β”‚   β”œβ”€β”€ ui/                       # User interface components
β”‚   β”‚   β”œβ”€β”€ main_window.py        # Main application window
β”‚   β”‚   β”œβ”€β”€ chatbot_dialog.py     # Chatbot interface
β”‚   β”‚   β”œβ”€β”€ map_dialog.py         # Map visualization
β”‚   β”‚   β”œβ”€β”€ image_search_dialog.py # Image search
β”‚   β”‚   └── spinner.py            # Loading animations
β”‚   β”œβ”€β”€ diseases/                 # Disease database (JSON files)
β”‚   β”‚   β”œβ”€β”€ plant/               # Plant disease data
β”‚   β”‚   β”œβ”€β”€ human/               # Human disease data
β”‚   β”‚   └── animal/              # Animal disease data
β”‚   β”œβ”€β”€ disease_model.pt         # Trained PyTorch model
β”‚   β”œβ”€β”€ class_to_name.json       # Class label mappings
β”‚   β”œβ”€β”€ main.py                  # Application entry point
β”‚   β”œβ”€β”€ train_disease_classifier.py  # Model training script
β”‚   └── predict_disease.py       # CLI prediction tool
β”œβ”€β”€ comprehensive_requirements.txt  # Python dependencies
β”œβ”€β”€ run_app.sh                   # Quick start script
β”œβ”€β”€ main.py                      # Root entry point
β”œβ”€β”€ verify_imports.py            # Dependency verification
└── README.md                    # This file

🧠 How It Works

AI Model Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Image Input    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
    β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”
    β”‚ Preproc  β”‚ (Resize, Normalize, Augment)
    β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
         β”‚
    β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
    β”‚ CNN Model β”‚ (Feature Extraction)
    β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
         β”‚
    β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ Classifier  β”‚ (Disease Categories)
    β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
    β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ Post-process  β”‚ (Confidence, Treatment)
    β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
    β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚   Output    β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Prediction Pipeline

Image Upload β†’ Validation β†’ Preprocessing β†’ AI Inference β†’ Post-processing β†’ Results
     ↓              ↓             ↓              ↓              ↓            ↓
  User Input   Reject Invalid  Resize/Norm   MobileNetV2   Confidence   Display
               (diagrams/text)  Transform     Prediction    Threshold    + Research

Confidence Thresholding

  • High Confidence (β‰₯55%): Disease identified with treatment recommendations
  • Low Confidence (<55%): Returns "No Confident Match Found" with 0% confidence
  • Invalid Images: Automatically rejected (diagrams, screenshots, text) with 0% confidence

Image Validation

The system validates images before processing:

  • Brightness Check: Rejects too dark/bright images
  • Color Variance: Detects diagrams and text (low variance)
  • Pixel Distribution: Identifies screenshots and documents
  • Thread-Safe: Uses PIL methods to avoid threading issues

πŸ“Š Supported Diseases

Plant Diseases (13 classes)

  • Pepper Bell Bacterial Spot
  • Pepper Bell Healthy
  • Potato Early Blight
  • Potato Healthy
  • Potato Late Blight
  • Tomato Target Spot
  • Tomato Mosaic Virus
  • Tomato Yellow Leaf Curl Virus
  • Tomato Bacterial Spot
  • Tomato Early Blight
  • Tomato Healthy
  • Tomato Late Blight
  • Tomato Leaf Mold
  • Tomato Septoria Leaf Spot
  • Tomato Spider Mites

Human Diseases (6 classes)

  • Acne Vulgaris
  • AIDS
  • Eczema
  • Smoker's Lung
  • And more...

Animal Diseases (7 classes)

  • Lumpy Skin Disease
  • Sarcoptic Mange
  • Swine Erysipelas
  • And more...

Total: 26 disease classes + healthy/normal states


πŸ”§ Configuration

Model Configuration

Edit DiseaseDetectionApp/core/ml_processor.py:

# Confidence threshold (0.0 to 1.0)
IMAGE_CONFIDENCE_THRESHOLD = 0.55  # Default: 55%

# Image size for model input
IMG_SIZE = 224  # Default: 224x224

# Healthy class names
HEALTHY_CLASS_NAMES = ('healthy', 'normal', 'clear_skin')

Training Configuration

Edit DiseaseDetectionApp/train_disease_classifier.py:

# Training parameters
EPOCHS = 10
BATCH_SIZE = 32
LEARNING_RATE = 0.001
VALIDATION_SPLIT = 0.2

πŸ§ͺ Testing

Run All Tests

# Activate virtual environment
source venv/bin/activate

# Run comprehensive tests
cd DiseaseDetectionApp
python comprehensive_test.py

# Run specific tests
python test_disease_detection.py
python test_train_model.py
python test_image_search.py

Verify Installation

# Check all dependencies
python verify_imports.py

# Should output:
# βœ“ All dependencies are correctly installed!

πŸš€ Advanced Usage

Training Custom Models

# 1. Prepare your dataset
# Organize images in folders by disease class:
# data/
#   β”œβ”€β”€ disease_class_1/
#   β”‚   β”œβ”€β”€ image1.jpg
#   β”‚   └── image2.jpg
#   └── disease_class_2/
#       └── image3.jpg

# 2. Update training script with your data path
# Edit train_disease_classifier.py

# 3. Train model
cd DiseaseDetectionApp
python train_disease_classifier.py

# 4. Model will be saved as disease_model.pt

API Integration

from DiseaseDetectionApp.core.ml_processor import MLProcessor
from DiseaseDetectionApp.core.data_handler import load_disease_database

# Initialize
ml_processor = MLProcessor()
database = load_disease_database()

# Predict
result, confidence, wiki, stage = ml_processor.predict_from_image(
    image_path="path/to/image.jpg",
    domain="Plant",  # or "Human" or "Animal"
    database=database
)

print(f"Disease: {result['name']}")
print(f"Confidence: {confidence}%")
print(f"Treatment: {result['solution']}")

Batch Processing

import os
from DiseaseDetectionApp.core.ml_processor import MLProcessor

ml_processor = MLProcessor()
database = load_disease_database()

# Process all images in a directory
image_dir = "path/to/images/"
for filename in os.listdir(image_dir):
    if filename.endswith(('.jpg', '.png', '.jpeg')):
        image_path = os.path.join(image_dir, filename)
        result, confidence, _, _ = ml_processor.predict_from_image(
            image_path, "Plant", database
        )
        print(f"{filename}: {result['name']} ({confidence:.1f}%)")

πŸ› Troubleshooting

Common Issues

Application crashes when uploading second image

Solution: This was a Qt threading issue that has been fixed in the latest version. Make sure you're using the latest code:

git pull origin main
pip install -r comprehensive_requirements.txt --upgrade
ModuleNotFoundError: No module named 'googleapiclient'

Solution: Install the missing dependency:

pip install google-api-python-client
Model file not found error

Solution: Train the model or download the pre-trained model:

cd DiseaseDetectionApp
./run_train.sh
PySide6 version incompatibility

Solution: Upgrade to Python 3.14 compatible version:

pip install "PySide6>=6.10.0"

Getting Help


🀝 Contributing

We welcome contributions! Here's how you can help:

Ways to Contribute

  • πŸ› Report Bugs: Found a bug? Open an issue
  • πŸ’‘ Suggest Features: Have an idea? Start a discussion
  • πŸ“ Improve Documentation: Help make the docs better
  • πŸ§ͺ Add Tests: Increase test coverage
  • 🎨 Enhance UI: Improve the user interface
  • πŸ”¬ Add Diseases: Contribute new disease data
  • πŸ“Š Share Datasets: Contribute training data (with proper licensing)

Contribution Process

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/AmazingFeature
  3. Commit your changes
    git commit -m "Add some AmazingFeature"
  4. Push to the branch
    git push origin feature/AmazingFeature
  5. Open a Pull Request

Development Guidelines

  • Follow PEP 8 style guide
  • Add tests for new features
  • Update documentation
  • Use descriptive commit messages
  • Keep PRs focused and small

πŸ“„ License

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

Third-Party Licenses

  • PyTorch: BSD License
  • PySide6: LGPL License
  • OpenCV: Apache 2.0 License
  • Pillow: HPND License

πŸ™ Acknowledgments

Datasets

  • PlantVillage: Plant disease dataset
  • Kaggle: Various disease datasets
  • Public Domain: Community-contributed images

Technologies

Inspiration

  • Medical imaging research from Stanford ML Group
  • Agricultural AI from PlantDoc project
  • Open-source computer vision community

⚠️ Disclaimer

Medical/Veterinary/Agricultural Disclaimer

This tool is designed for educational and research purposes only. It is NOT a substitute for professional medical, veterinary, or agricultural advice, diagnosis, or treatment.

Always consult qualified professionals:

  • πŸ‘¨β€βš•οΈ Medical doctors for human health concerns
  • πŸ• Licensed veterinarians for animal health issues
  • 🌾 Agricultural extension services for crop diseases

Liability

The developers and contributors assume no liability for any consequences resulting from the use of this software. Users are responsible for:

  • Validating all results
  • Seeking professional consultation
  • Using the tool responsibly
  • Understanding its limitations

Privacy

  • All data processing happens locally on your device
  • No data is sent to external servers (except optional Wikipedia/PubMed lookups)
  • No user data is collected or stored by the developers
  • You maintain full control of your data

πŸ“Š Project Statistics

GitHub stars GitHub forks GitHub issues GitHub pull requests GitHub last commit GitHub code size


πŸ—ΊοΈ Roadmap

Current Version (v1.0)

  • Multi-species disease detection
  • Desktop GUI application
  • Offline operation
  • Custom model training
  • Report generation (PDF/HTML)
  • Wikipedia and PubMed integration
  • Interactive maps
  • AI chatbot
  • Image validation
  • Thread-safe operation

Upcoming Features (v2.0)

  • Mobile applications (iOS/Android)
  • Web-based interface
  • Real-time video stream analysis
  • Multi-language support
  • Cloud-optional deployment
  • Integration with medical imaging standards (DICOM)
  • Advanced model architectures (Vision Transformers)
  • Federated learning support
  • API server mode
  • Docker containerization

πŸ“§ Contact & Support

Support the Project

If you find this project helpful:

  • ⭐ Star the repository
  • πŸ› Report bugs and issues
  • πŸ’‘ Suggest new features
  • 🀝 Contribute code or documentation
  • πŸ“’ Share with others who might benefit

πŸ”¬ Research & Citations

If you use this project in your research, please cite:

@software{disease_predictor_2025,
  author = {Abhi},
  title = {Multi-Species Disease Detection and Management System},
  year = {2025},
  publisher = {GitHub},
  url = {https://github.com/abhi-abhi86/disease-predictor},
  version = {1.0.0}
}

Made with ❀️ for better healthcare, agriculture, and animal welfare

⬆ Back to Top

About

AI disease detection and prediction for humans, plants, and animals. Complete ML project with custom training, offline operation, no API keys. Detect diseases from images using deep learning and computer vision. Open-source disease detection system for healthcare, agriculture, and veterinary applications. Full code and deployment guides.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors