Skip to content


Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


The world's best Scientists and Doctors are currently working on finding and testing the cure to COVID-19. In the middle of all of this, some countries are unable to find testing kits for the virus, making it really difficult to detect the quickly spreading virus.With the help of Joseph Paul Cohen's X-ray dataset for COVID-19 patients and resources for various opacities, this project is aimed at helping better and faster diagnosis of the virus while releasing the stress over Radiologists.
In this matter, the biggest task for a machine to classify COVID would be to tackle

  1. Detection of Lungs- The datasets currently available for opacities might lead to overfitting and diversion of attention to text or other bones in the X-ray images.
  2. Detection of Opacities

This project aims to solve these issue to make a robust model which is capable of deployment in the future.

Note that the models provided here are not fully tested on real life scenarios. Further testing is essential before concrete claims

Model Architecture

The model uses an Inception/Xception Model like approach for Classification. The model consists of Separable Convolutional Layers for the starting layers since it attempts to make the initial extraction process faster. These also worked significantly better than normal Convolutions in this case. At every stage, the Convolution outputs get multiplied and normalized. The use of standard Convolutions in the last layers help in increasing trainable parameters and hence more attention can be given to the smaller features. The Feature Extractor is followed by Fully Connected Layers which finally give the output. The option for gradient visualisation can be treated as a mask if the output desired is a mask.

Full Architecture:

Testing scores

Custom Model

1.Accuracy- 0.9561
2. Precision- 0.9538
3. Recall- 0.9431
4. F1-Score - 0.9507
5. AUC - 0.9841

Resnet Model

1.Accuracy- 0.9733
2. Precision- 0.9749
3. Recall- 0.9649
4. F1-Score - 0.9698
5. AUC - 0.9890

                                                                          Training Graphs

                                                                       Prediction Visualisations

This result has been checked multiple times on unseen images and so far, for all the testing datasets, the model is able to score similarly.
It will be much appreciated if this model can be tested on further data because for now the small COVID-dataset available might not be a true test for it

How To Use

  1. Install all the requirements by using the following code while in the current directory
    pip install -r requirements.txt
  2. Execute the file through the terminal or your preferred IDE, give your choice of classification model and path to the directory containing images. Option for verbose is provided but turning it on will spam the output window with predictions if there are a lot of images. Choices for Models:
1. 'COVID-Resnet' for Resnet Based Model
2. 'Custom' for Custom Model 
3. 'Ensemble'
  1. After the individual results are displayed, you can choose whether to visualise the gradients of the model. If you do then a window will pop up with the image and it's attention gradients. You can move on to the next image by pressing any key.
    Gradient Visualisation is not available in Ensemble Mode

Data Used

  1. COVID-19 Xray images
  2. Paul Mooney's Amazing Pneumonia Dataset
  3. Twitter dataset for Spanish patients
  4. RSNA Pneumonia Dataset
  5. NIH X-Ray Dataset
  6. Link to all images and TFRecord files used for training, validation and testing can be found here on my drive ->


  1. Adrian Rosebrock for his article for grad-cam


Diagnosing COVID-19 patients through X-Rays






No releases published


No packages published