Giter Site home page Giter Site logo

covid-detection's Introduction

Detecting covid-19 using Xray images

Collecting data

This repository contains a database of COVID-19 cases with chest X-ray or CT images as well as MERS, SARS, and ARDS. Clone this repository in order to proceed with building the dataset.

Using the metadata.csv, extract all images which are covid-positive using the build_dataset.py script.

python build_dataset.py -m <path to the cloned dataset folder> -o <path to where you want the output stored>

Next inorder to get some xrays of healthy patients/covid-negetive patients, we can randomly take images from the Kaggle chest xray dataset. To prevent class imbalance, keep the number of images of covid-positive and covid-negetive same. Store this in a folder called normal in your dataset.

The dataset should have a structure like the one in this repo.

My dataset consists of 68 covid-positive images and 70 normal images.

Training the model

The model is trained using VGGNet which is pre-trained on the imagenet dataset. To train obtain a model and save it, run the trainModel.py script.

python trainModel.py -d <path to dataset>

This will save the model in the same folder as the script as a file, [model.h5](https://github.com/yashk2000/covid-detection/blob/master/model.h5). A plot showing accuracy and loss curves will also be generated.

plot

This is the plot generated while I was training my model.

Classifying more images using the trained model

Now using the model obtained by running the above script, we can classify our own images as covid-positive or covid-negetive. To do this, run the detectCovid.py script.

python detectCovid.py -i <path to input image> -m <path to the trained model>

This will give an output with image labeled as covid-positive or covid-negetive.

Sample Output

There are a few sample images in the test-data folder.

For exmaple, for the image covid1.jpeg, which is covid-positive, I got the following output:

python detectCovid.py -i test-data/covid1.jpeg -m model.h5

Screenshot from 2020-03-21 00-48-17

For the image normal1.jpeg, which is covid-negetive, I got the following output:

python3 detectCovid.py -i test-data/normal1.jpeg -m model.h5

Screenshot from 2020-03-21 00-51-53

Cheers to this blog post by Adrian Rosebrock which was an invaluable resource.

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.