Diagnosing COVID-19 using Artificial Intelligence.

Original article can be found here (source): Artificial Intelligence on Medium

Diagnosing COVID-19 using Artificial Intelligence.

COVID-19 is an infectious disease caused by a newly discovered coronavirus.World Health Organisation(WHO) has recently assessed that COVID-19 can be characterized as a pandemic which was first discovered in the Hubei Province,China.Currently it has spread to more than 100 countries in the world claiming more than 22 thousand lives.

The current testing methods cost from 10 dollars to 50 dollars to the government.To curb the cost,AI can be used as an alternative.This is not a scientifically rigorous study, nor will it be published in a journal.

Existing Methods.

RT-PCR testing.

The COVID-19 RT-PCR test is a real-time reverse transcription polymerase chain reaction (rRT-PCR) test for the qualitative detection of nucleic acid from SARS-CoV-2 in upper and lower respiratory specimens (such as nasopharyngeal or oropharyngeal swabs, sputum, lower respiratory tract aspirates, bronchoalveolar lavage, and nasopharyngeal wash/aspirate or nasal aspirate) collected from individuals suspected of COVID-19 by their healthcare provider.

Impact of COVID-19 on Humans.

In humans,the lining of the respiratory tree becomes injured, causing inflammation. This in turn irritates the nerves in the lining of the airway. Just a speck of dust can stimulate a cough.

But if this gets worse, it goes past just the lining of the airway and goes to the gas exchange units, which are at the end of the air passages.

Basically,it affects the functioning of the lungs in humans.


Since the virus affects the lungs,chest radio-graphs can reveal a lot about the impact that the virus creates in lungs.

For a initial U.S. case, published March 5 in the New England Journal of Medicine, the man’s first chest radiograph showed no abnormalities; lab tests, nose swabs and other clinical findings were also normal. Due to his travel history, clinicians at the Washington urgent care clinic and those at the state’s Department of Health immediately called the Centers for Disease Control and Prevention to collect samples from the patient.

His real-time reverse-transcriptase–polymerase-chain-reaction (rRT-PCR) test came back positive for 2019-nCoV and he was taken to an airborne-isolation unit at Providence Regional Medical Center for observation. The location of this area limited the man to point-of-care lab testing at first, the authors noted.

During Day 3 in the hospital, another chest x-ray appeared normal, showing “no evidence of infiltrates or abnormalities,” first author Michelle L. Holshue, with the CDC’s Epidemic Intelligence Service, and colleagues wrote. But on Day 5 of hospitalization, a second x-ray showed evidence of pneumonia in the lower lobe of the left lung. This occurred as the man’s respiratory status changed.

The next x-ray exam — performed on Day 6 of the patient’s hospitalization — yielded abnormal findings, including “basilar streaky opacities” in each lung, consistent with atypical pneumonia, the group wrote.

As far as chest radio-graphs are concerned,it cannot detect the virus atleast before 4 days.But after 4 days,X-rays starts to show signs which can be used to detect the corona virus as concluded by the study.


Left: COVID-19 positive x-ray. Right: Streptococcal Infection. ( Both are licensed as CC-NC-SA). Both images exhibit pneumonia. What can tell them apart?

The data-set contains 50 images in which 40 images are taken for training the model and the remaining 10 images is used to evaluate the model.

Thanks to Adrian Rosebrock, PhD for the dataset.

Transfer Learning.

Transfer learning (TL) is a research problem in machine learning (ML) that focuses on storing knowledge gained while solving one problem and applying it to a different but related problem. For example, knowledge gained while learning to recognize cars could apply when trying to recognize trucks.

This can be posed as a computer vision problem involving Convolutional Neural Networks.

Convolutional Neural Networks.

Convolutional Neural networks allow computers to see, in other words, Convnets are used to recognize images by transforming the original image through layers to a class scores. CNN was inspired by the visual cortex. Every time we see something, a series of layers of neurons gets activated, and each layer will detect a set of features such as lines, edges. The high level of layers will detect more complex features in order to recognize what we saw.

VGG Network.

VGG Network.

VGG16 is a convolutional neural network model proposed by K. Simonyan and A. Zisserman from the University of Oxford in the paper “Very Deep Convolutional Networks for Large-Scale Image Recognition”. The model achieves 92.7% top-5 test accuracy in ImageNet, which is a dataset of over 14 million images belonging to 1000 classes. It was one of the famous model submitted to ILSVRC-2014. It makes the improvement over AlexNet by replacing large kernel-sized filters (11 and 5 in the first and second convolutional layer, respectively) with multiple 3×3 kernel-sized filters one after another. VGG16 was trained for weeks and was using NVIDIA Titan Black GPU’s.

This model is used to train the model to detect whether a person is suffering from the Covid-19 or not.


On training with the VGG network,the accuracy of the model was improved to be 100 percent.

For the code.Please drop your email-id in the comments section.

CT Scans.

A Recent study has concluded that Chest CT has a high sensitivity for diagnosis of COVID-19. Chest CT may be considered as a primary tool for the current COVID-19 detection in epidemic areas.It is said to be more accurate than the existing RT-PCR test.Since CT scans data was not publicly available.This study was made on X-Rays.

This blog is just a proof of concept, but if developed further, this has enormous potential to address the existing limited diagnosis reach and the likely future manpower shortages.

Disclaimer: The following section does not claim, nor does it intend to “solve”, COVID-19 detection.


  1. https://pubs.rsna.org/doi/10.1148/radiol.2020200642
  2. https://www.medicaldevice-network.com/news/coronavirus-ct-scans/
  3. https://www.managedhealthcareexecutive.com/article/ct-scans-lung-may-help-coronavirus-diagnosis
  4. https://www.itnonline.com/content/ct-provides-best-diagnosis-novel-coronavirus-covid-19
  5. https://www.fda.gov/media/136151/download
  6. https://pubs.rsna.org/2019-ncov
  7. https://www.researchgate.net/post/Free_lung_CT_scan_dataset_for_cancer_non-cancer_classification
  8. https://www.pyimagesearch.com/2020/03/16/detecting-covid-19-in-x-ray-images-with-keras-tensorflow-and-deep-learning/
  9. https://github.com/ieee8023/covid-chestxray-dataset
  10. https://towardsdatascience.com/using-deep-learning-to-detect-ncov-19-from-x-ray-images-1a89701d1acd