Giter Club home page Giter Club logo

pneumonia-detection's Introduction

logo

online hosted application License - Apache-2.0 Build - Passing GitHub release Python contributions welcome

web-app-screencast

Motivation

Pneumonia is a lung infection (๐Ÿซ) that inflames the air sacs in one or both lungs. This infection arises when the air sacs get filled with fluid or pus (purulent material). It can be a bacterial or viral infection. The main symptoms are - cough with phlegm or pus, fever, chills, and breathing difficulty.

This disease is responsible for over 15% of all deaths of children under five years old worldwide. This proves the severity of this disease and the need for accurate detection.

The most commonly used method to diagnose pneumonia is through chest radiograph or chest X-ray, which depicts the infection as an increased opacity in the lungs' specific area(s).

To increase the diagnosis procedure's efficacy and reach, we can leverage machine learning algorithms to identify abnormalities in the chest X-ray images. In this model, many chest X-ray images (both normal and pneumonia) are fed to build Convolutional Neural Network (CNN) model for fulfilling the purpose.

Requirements

  • Python 3.7.0+
  • Tensorflow 2.4.1+
  • Keras 2.4.3+
  • scikit-learn 0.24.1+
  • matplotlib 3.3.3+
  • texttable 1.6.3+
  • gradio 1.5.3+

Dataset

You can download the dataset from kaggle. Use the download link to download the dataset.

Instructions to follow

  • Extract the archive
  • You will find several directories in it
  • Copy the chest-xray directory contents (train, test and val subdirectories) to the data folder

The number of images belonging to both classes (Normal and Pneumonia) in the train, test and val datasets are -

Dataset Type Normal Pneumonia
Training 1341 3875
Test 234 390
Validation 8 8

Installation

  • Clone the repository

git clone https://github.com/baishalidutta/Pneumonia-Detection.git

  • Install the required libraries

pip3 install -r requirements.txt

Usage

Enter into the source directory to execute the following source codes.

  • To generate the model on your own, run

python3 model_training.py

  • To evaluate any dataset using the pre-trained model (in the model directory), run

python3 model_evaluation.py

Note that, for evaluation, model_evaluation.py will use all the images contained inside both test and val subdirectories (inside data directory).

Alternatively, you can find the whole analysis in the notebook inside the notebook directory. To open the notebook, use either jupyter notebook or google colab or any other IDE that supports notebook feature such as PyCharm Professional.

Evaluation

The model is trained with 96% accuracy on the training dataset. The model's accuracy on the test and val datasets are 91% and 88% respectively. In both cases, the f1-score and ROC_AUC Score are relatively high, as shown below.

On Test Dataset (624 images, 234 Normal and 390 Pneumonia)

Screenshot 2021-02-07 at 17 07 23

On Validation Dataset (16 images, 8 Normal and 8 Pneumonia)

Screenshot 2021-02-07 at 17 10 07

Web Application

To run the web application locally, go to the webapp directory and execute:

python3 web_app.py

This will start a local server that you can access in your browser. You can either upload/drag a new X-ray image or select any test X-ray images from the examples below.

You can, alternatively, try out the hosted web application here.

Developer

Baishali Dutta ([email protected])

Contribution contributions welcome

If you would like to contribute and improve the model further, check out the Contribution Guide

License License

This project is licensed under Apache License Version 2.0

pneumonia-detection's People

Contributors

baishalidutta avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.