Skip to content

Latest commit

Β 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🩻 Chest X-Ray Pneumonia Detection AI

A Deep Learning-based web application that detects Pneumonia from Chest X-Ray images using a Convolutional Neural Network (CNN) built with TensorFlow/Keras. The application provides an interactive clinical dashboard developed with Streamlit, displaying prediction probabilities, confidence scores, patient information, and downloadable AI-generated diagnostic reports.

Note: This project is intended for educational and research purposes only and is not a substitute for professional medical diagnosis.


πŸš€ Features

  • 🩻 Chest X-Ray Classification

    • Binary classification of Chest X-Ray images
    • Detects:
      • βœ… Normal
      • 🦠 Pneumonia
  • πŸ€– Deep Learning CNN

    • Built using TensorFlow/Keras
    • Image preprocessing and normalization
    • Binary classification using Sigmoid activation
  • πŸ“Š Prediction Dashboard

    • Prediction result
    • Confidence score
    • Normal probability
    • Pneumonia probability
    • Risk assessment
  • πŸ‘€ Patient Information

    • Patient Name
    • Patient ID
    • Age
    • Gender
    • Hospital
    • Doctor
  • πŸ“ˆ Interactive Probability Chart

    • Built using Plotly
    • Displays prediction probabilities visually
  • πŸ“„ PDF Report Generation

    • AI-generated diagnostic report
    • Includes patient information
    • Prediction summary
    • Confidence score
    • Probability values
    • AI recommendation
  • πŸŒ™ Modern Streamlit UI

    • Responsive layout
    • Dark theme
    • Interactive dashboard

πŸ“Έ Dashboard

Dashboard


🩻 AI Prediction Dashboard

Prediction


πŸ“Š Prediction Analytics

Analytics


πŸ“„ AI Diagnostic Report

Report

πŸ“Έ Application Workflow

Chest X-Ray Image
        β”‚
        β–Ό
 Image Preprocessing
        β”‚
        β–Ό
 TensorFlow CNN Model
        β”‚
        β–Ό
Prediction
        β”‚
        β–Ό
Probability Analysis
        β”‚
        β–Ό
Risk Assessment
        β”‚
        β–Ό
PDF Report Generation

πŸ—οΈ Project Structure

Pneumonia-Detection-AI/
β”‚
β”œβ”€β”€ app.py
β”œβ”€β”€ README.md
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ x_ray.ipynb
β”œβ”€β”€ .gitignore
β”‚
β”œβ”€β”€ assets/
β”‚   β”œβ”€β”€ dashboard.png
β”‚   β”œβ”€β”€ prediction.png
β”‚   β”œβ”€β”€ analytics.png
β”‚   └── report.png
β”‚
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ helpers.py
β”‚   β”œβ”€β”€ preprocess.py
β”‚   β”œβ”€β”€ predict.py
β”‚   └── report.py
β”‚
└── LICENSE

If pneumonia_model.keras is not included, download it separately and place it in the project root.


πŸ› οΈ Tech Stack

Deep Learning

  • TensorFlow
  • Keras

Computer Vision

  • OpenCV
  • Pillow (PIL)

Web Framework

  • Streamlit

Visualization

  • Plotly
  • Matplotlib

Data Processing

  • NumPy
  • Pandas

PDF Generation

  • ReportLab

🧠 CNN Architecture

Input Image (224 Γ— 224 Γ— 3)

        β”‚
        β–Ό

Conv2D (32 Filters)

        β”‚
        β–Ό

MaxPooling2D

        β”‚
        β–Ό

Conv2D (64 Filters)

        β”‚
        β–Ό

MaxPooling2D

        β”‚
        β–Ό

Flatten

        β”‚
        β–Ό

Dense (128 Units)

        β”‚
        β–Ό

Dense (1 Unit - Sigmoid)

        β”‚
        β–Ό

Prediction

πŸ“Š Model Output

The model predicts:

Prediction Description
Normal Chest X-Ray appears normal
Pneumonia Features associated with pneumonia detected

The application also displays:

  • Confidence Score
  • Normal Probability
  • Pneumonia Probability
  • Risk Level
  • AI Recommendation

πŸ“‚ Dataset

The model was trained using a labelled Chest X-Ray image dataset containing two classes:

  • Normal
  • Pneumonia

All images are resized to:

224 Γ— 224 Γ— 3

before inference.


βš™οΈ Installation

1. Clone the Repository

git clone https://github.com/Shaipratt51/Pneumonia-Detection-AI.git

2. Navigate to the Project

cd Pneumonia-Detection-AI

3. Create a Virtual Environment (Optional)

Windows

python -m venv venv
venv\Scripts\activate

Linux / macOS

python3 -m venv venv
source venv/bin/activate

4. Install Dependencies

pip install -r requirements.txt

5. Run the Application

streamlit run app.py

The application will open at:

http://localhost:8501

πŸ“ How to Use

  1. Launch the Streamlit application.
  2. Enter patient information.
  3. Upload a Chest X-Ray image.
  4. Wait for the model prediction.
  5. Review:
    • Prediction
    • Confidence
    • Probability chart
    • Risk level
    • AI recommendation
  6. Download the generated PDF report.

πŸ“„ PDF Report Includes

  • Patient Details
  • Hospital Information
  • Doctor Name
  • Prediction
  • Confidence Score
  • Normal Probability
  • Pneumonia Probability
  • Risk Level
  • AI Recommendation

πŸ“¦ Requirements

tensorflow
streamlit
opencv-python
numpy
pandas
matplotlib
plotly
pillow
reportlab

Install using:

pip install -r requirements.txt

πŸ“ˆ Future Improvements

  • Multi-class lung disease detection
  • Tuberculosis detection
  • COVID-19 detection
  • DICOM image support
  • Cloud deployment
  • User authentication
  • Patient history management
  • Model monitoring dashboard

πŸ“Š Performance

The model uses:

  • Convolutional Neural Network (CNN)
  • Binary Cross-Entropy Loss
  • Adam Optimizer
  • Sigmoid Activation

Evaluation metrics include:

  • Accuracy
  • Prediction Probability
  • Confidence Score

πŸ“₯ Model File

The trained model (pneumonia_model.keras) may not be included in this repository because it exceeds GitHub's file size limit.

If unavailable, place the trained model file in the project root:

Pneumonia-Detection-AI/
β”‚
β”œβ”€β”€ pneumonia_model.keras

⚠️ Medical Disclaimer

This project is intended solely for educational and research purposes.

The predictions generated by this AI system should NOT be considered a medical diagnosis or used as a substitute for professional medical advice, diagnosis, or treatment.

Always consult a qualified physician or radiologist for clinical decisions.


About

AI-powered pneumonia detection from chest X-ray images using TensorFlow CNN with Streamlit, confidence analysis, interactive visualizations, and automated PDF medical reports.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages