Skip to content

Pratham-1229/Pneumonia-Detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pneumonia Detection Web App

A Flask web app that detects pneumonia from chest X-ray images using TensorFlow/Keras. Upload an image in the browser to receive a prediction and confidence score.

Features

  • Upload X-ray images (PNG, JPG, JPEG, BMP, WEBP)
  • Two model entry points (grayscale and RGB)
  • Simple, responsive UI with clear results and warnings

Tech Stack

  • Python
  • Flask
  • TensorFlow/Keras
  • NumPy
  • Pillow

Project Structure

app/
  factory.py
  templates/
    mainpage.html
  static/
  utils/
main.py
mainDense.py
model/
requirements.txt

Setup

  1. Create and activate a virtual environment
    • Windows (PowerShell)
      python -m venv .venv
      .\.venv\Scripts\activate
      
    • macOS/Linux
      python -m venv .venv
      source .venv/bin/activate
      
  2. Install dependencies
    pip install -r requirements.txt
    

Run

  • Grayscale model (default)
    python main.py
    
  • DenseNet RGB model
    python mainDense.py
    

Open http://127.0.0.1:5000 in your browser.

Configuration

The app is created via create_app in app/factory.py:

  • model_path: path to a Keras .h5 model
  • input_mode: grayscale or rgb
  • compile_model: set to True if your model requires compilation

Prediction logic:

  • A score is produced by the model
  • Normal if score >= 0.5, otherwise Pneumonia

Models

  • main.py uses model/pneumoniadetection2.h5 (grayscale)
  • mainDense.py uses model/pneumoniadetection_densenet.h5 (RGB)

If the model files are not present, add them under the model/ directory. If the files are large (e.g., >100 MB), use Git LFS to store them.

Uploads

Uploaded files are saved to app/static/uploads. This folder is safe to clear.

Disclaimer

This project is for educational and demonstration purposes only. It is not a medical device and should not be used for clinical diagnosis. Always consult a qualified healthcare professional.

Tests

No automated tests yet.

License

Add a license before publishing (MIT, Apache-2.0, etc.).

About

A Flask web app that runs TensorFlow/Keras models to detect pneumonia from chest X-ray images with a simple upload-based UI.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors