Skip to content

ErselSeyit/XrayPneumonia

Repository files navigation

X-ray Pneumonia Detection

Flutter Dart License TensorFlow Lite

A professional Flutter mobile application that leverages state-of-the-art deep learning models to detect pneumonia from chest X-ray images with real-time analysis capabilities.

FeaturesInstallationUsageModel PerformanceLicense


Overview

This application provides a comprehensive solution for X-ray pneumonia detection using multiple pre-trained deep learning models. It supports four advanced architectures: VGG16, EfficientNet, InceptionV3, and ResNet50, allowing users to compare model performance and select the most suitable classifier for their needs.

Features

Core Capabilities

  • 🧠 Multiple AI Models: Choose from 4 state-of-the-art deep learning architectures (VGG16, EfficientNet, InceptionV3, ResNet50)
  • Real-time Analysis: Instant image processing and prediction with optimized TensorFlow Lite inference
  • 📊 Confidence Scores: Detailed prediction confidence levels for transparent decision-making
  • 📈 Performance Metrics: Built-in model comparison with accuracy and F1 score statistics
  • 🎨 Modern UI/UX: Clean, intuitive interface with gradient design and smooth animations
  • 📱 Cross-platform: Native performance on both Android and iOS devices
  • 🔒 Privacy-focused: All processing performed on-device with no data transmission

Model Performance

The following table presents the performance metrics for each model on the test dataset:

Model Accuracy F1 Score Precision Recall
ResNet50 93.70% 95.42% - -
VGG16 91.87% 93.91% - -
EfficientNet 90.13% 92.67% - -
InceptionV3 89.55% 92.51% - -

Note: ResNet50 demonstrates the highest accuracy and F1 score, making it the recommended model for production use.

Prerequisites

Before you begin, ensure you have the following installed:

Required Software

  • Flutter SDK (>=3.38.5) - Installation Guide
  • Dart SDK (>=3.10.4) - Included with Flutter
  • Android Studio or VS Code with Flutter extensions
  • Android SDK (API level 21 or higher) for Android development
  • Xcode (latest version) for iOS development (macOS only)

System Requirements

  • Android: Minimum SDK 21 (Android 5.0 Lollipop)
  • iOS: iOS 12.0 or later
  • RAM: Minimum 4GB (8GB recommended)
  • Storage: At least 2GB free space for dependencies and models

Installation

Step 1: Clone the Repository

git clone https://github.com/ErselSeyit/XrayPneumonia.git
cd XrayPneumonia

Step 2: Install Dependencies

flutter pub get

Step 3: Verify Installation

Run Flutter doctor to ensure all dependencies are properly configured:

flutter doctor

Step 4: Verify Model Files

Ensure all TensorFlow Lite model files are present in the assets/ directory:

  • vgg16_model_finetuned.tflite
  • EfficientnetB3_fine_tuning.tflite
  • InceptionV3_model_finetuned.tflite
  • ResNet50_model_finetuned.tflite
  • labels.txt

Running the App

Development Mode

Run the app in debug mode on a connected device or emulator:

flutter run

To run on a specific device:

flutter devices                    # List available devices
flutter run -d <device-id>        # Run on specific device

Release Build

Android APK

Build a release APK optimized for production:

# Single APK (universal)
flutter build apk --release

# Split APKs by ABI (recommended for smaller size)
flutter build apk --split-per-abi --release

Android App Bundle

Build an Android App Bundle for Google Play Store:

flutter build appbundle --release

iOS

Build for iOS (requires macOS and Xcode):

flutter build ios --release

Project Structure

XrayPneumonia/
├── lib/
│   ├── main.dart                    # Main application entry point and UI
│   ├── classifier_vgg16.dart        # VGG16 model classifier implementation
│   ├── classifier_efficientnet.dart # EfficientNet model classifier
│   ├── classifier_inceptionv3.dart  # InceptionV3 model classifier
│   └── classifier_resnet.dart      # ResNet50 model classifier
│
├── assets/
│   ├── vgg16_model_finetuned.tflite
│   ├── EfficientnetB3_fine_tuning.tflite
│   ├── InceptionV3_model_finetuned.tflite
│   ├── ResNet50_model_finetuned.tflite
│   └── labels.txt                   # Model labels (NORMAL, PNEUMONIA)
│
├── android/                          # Android platform-specific code
├── ios/                              # iOS platform-specific code
├── test/                             # Unit and widget tests
├── pubspec.yaml                      # Flutter dependencies and configuration
└── README.md                         # Project documentation

Usage

Getting Started

  1. Launch the Application: Open the app on your device or emulator
  2. Select an Image: Tap the photo icon in the bottom-right corner to choose an X-ray image from your gallery
  3. Automatic Analysis: The app will automatically process the image using the currently selected model
  4. View Results: Review the prediction (NORMAL or PNEUMONIA) along with the confidence score
  5. Switch Models: Use the drawer menu (hamburger icon) to switch between different AI models and compare results

Best Practices

  • Use high-quality X-ray images for better accuracy
  • Ensure images are properly oriented and well-lit
  • Compare results across multiple models for validation
  • Review confidence scores to assess prediction reliability

Technology Stack

Framework & Language

  • Flutter (3.38.5+) - Cross-platform mobile application framework
  • Dart (3.10.4+) - Programming language

Machine Learning

  • TensorFlow Lite - On-device machine learning inference engine
  • tflite_flutter - Flutter plugin for TensorFlow Lite
  • tflite_flutter_helper - Helper utilities for TensorFlow Lite operations

Deep Learning Models

  • VGG16 - Visual Geometry Group 16-layer convolutional neural network
  • EfficientNet - Efficient convolutional neural network architecture
  • InceptionV3 - Google's Inception architecture v3
  • ResNet50 - 50-layer residual neural network

Additional Libraries

  • image_picker - Image selection from gallery
  • image - Image processing and manipulation
  • logger - Logging and debugging utilities
  • permission_handler - Runtime permission management

Important Notes

Medical Disclaimer

⚠️ IMPORTANT: This application is designed for educational and research purposes only. It should NOT be used as a substitute for professional medical diagnosis, advice, or treatment.

  • Always consult with qualified healthcare professionals for medical decisions
  • This tool is not intended to diagnose, treat, cure, or prevent any disease
  • Results should be interpreted by licensed medical professionals
  • The developers assume no liability for any medical decisions made based on this application

Limitations

  • Model accuracy may vary based on image quality and conditions
  • Results are probabilistic and should be validated by medical professionals
  • The application is not a replacement for clinical expertise

Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

License

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

Author

Ersel Seyit


Made with ❤️ using Flutter and TensorFlow Lite

⭐ Star this repository if you find it helpful!

About

Flutter mobile app for X-ray pneumonia detection using deep learning. Supports VGG16, EfficientNet, InceptionV3, and ResNet50 models with real-time image analysis.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors