Skip to content

This project implements a deep learning model to detect pneumonia from chest X-ray images using transfer learning with the Xception architecture. The model achieves high accuracy in distinguishing between normal chest X-rays and those showing signs of pneumonia.

License

Notifications You must be signed in to change notification settings

AmirrHussain/Pneumonia-Detection-from-Chest-X-Ray-Images

Folders and files

NameName
Last commit message
Last commit date
Nov 18, 2024
Nov 18, 2024
Nov 18, 2024

Repository files navigation

Pneumonia Detection from Chest X-Ray Images 🫁

Python TensorFlow Keras License

πŸ“‹ Overview

This project implements a deep learning model to detect pneumonia from chest X-ray images using transfer learning with the Xception architecture. The model achieves high accuracy in distinguishing between normal chest X-rays and those showing signs of pneumonia. Chest X-Ray Images (Pneumonia) Dataset

πŸ”„ Processing Flow

Loading
flowchart TD
    A[Input X-Ray Image] --> B[Xception Base Model]
    B --> C[Custom Classification Layers]
    C --> D[Prediction Normal/Pneumonia]
    
    style A fill:#f9f,stroke:#333,stroke-width:2px
    style B fill:#bbf,stroke:#333,stroke-width:2px
    style C fill:#dfd,stroke:#333,stroke-width:2px
    style D fill:#fdd,stroke:#333,stroke-width:2px

πŸš€ Features

  • Transfer learning using pre-trained Xception model
  • Data augmentation and preprocessing
  • Binary classification (Normal vs Pneumonia)
  • Visualization tools for model predictions
  • Detailed performance metrics
  • Interactive prediction interface

πŸ“Š Model Architecture

Loading
flowchart TD
    A[Input Layer<br>256x256x3] --> B[Xception Base Model<br>Pre-trained]
    B --> C[Batch Normalization]
    C --> D[Dropout 0.45]
    D --> E[Dense Layer<br>220 units, ReLU]
    E --> F[Dropout 0.25]
    F --> G[Dense Layer<br>60 units, ReLU]
    G --> H[Output Layer<br>1 unit, Sigmoid]
    
    style A fill:#f9f,stroke:#333,stroke-width:2px
    style B fill:#bbf,stroke:#333,stroke-width:2px
    style C fill:#dfd,stroke:#333,stroke-width:2px
    style D fill:#fdb,stroke:#333,stroke-width:2px
    style E fill:#dfd,stroke:#333,stroke-width:2px
    style F fill:#fdb,stroke:#333,stroke-width:2px
    style G fill:#dfd,stroke:#333,stroke-width:2px
    style H fill:#fdd,stroke:#333,stroke-width:2px

πŸ“ˆ Performance

The model achieves:

  • Training Accuracy: ~95%
  • Validation Accuracy: ~92%
  • Test Accuracy: ~90%

πŸ› οΈ Installation

# Clone the repository
git clone https://github.com/AmirrHussain/chest-x-ray-images.git

# Install dependencies
pip install -r requirements.txt

πŸ“¦ Requirements

  • Python 3.8+
  • TensorFlow 2.0+
  • OpenCV
  • NumPy
  • Pandas
  • Matplotlib
  • Seaborn

πŸ’» Usage

# Load and preprocess image
image = cv2.imread('path_to_xray.jpg')
image = cv2.resize(image, (256, 256))
image = image / 255.0

# Make prediction
prediction = model.predict(np.expand_dims(image, axis=0))

πŸ“ Dataset Structure

chest_xray/
β”‚
β”œβ”€β”€ train/
β”‚   β”œβ”€β”€ NORMAL/
β”‚   └── PNEUMONIA/
β”‚
β”œβ”€β”€ test/
β”‚   β”œβ”€β”€ NORMAL/
β”‚   └── PNEUMONIA/
β”‚
└── val/
    β”œβ”€β”€ NORMAL/
    └── PNEUMONIA/

πŸ“Š Sample Results

Here's how predictions look on test images:

Normal X-Ray β†’ Predicted: Normal (99.2% confidence)
Pneumonia X-Ray β†’ Predicted: Pneumonia (97.8% confidence)

🀝 Contributing

  1. Fork the repository
  2. Create your 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

πŸ“ License

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

πŸ™ Acknowledgments

  • Dataset provided by Kaggle
  • Inspired by various research papers on medical image analysis
  • Thanks to the medical community for providing labeled data

πŸ“§ Contact

Project Link

About

This project implements a deep learning model to detect pneumonia from chest X-ray images using transfer learning with the Xception architecture. The model achieves high accuracy in distinguishing between normal chest X-rays and those showing signs of pneumonia.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published