Skip to the content.

A 2-staged ML-based Detection of COVID-19 and Pneumonia

Authors: Sahil Khose, Richa Kulkarni, Shubham Kulkarni, James Wellington, Sneha Talwalkar

Introduction

The initial cases of COVID-19 were detected in Wuhan, China in late 2019. Though several precautionary steps were taken to contain the spread of the disease, by the end of spring 2020, the virus was already reported in most countries and the World Health Organization (WHO) declared the new virus a pandemic. [9]

The Polymerase Chain Reaction (PCR) test, which is the standard test for detecting COVID-19, detects the presence of infection antibodies. However, this test is time-consuming, requires high precision, and has a minor possibility of false negatives. [10] Furthermore, many countries lack the infrastructure required for conducting these tests on a large scale. To overcome such issues, chest X-rays are often used as an alternative method to the PCR test.

In such a scenario, Machine Learning solutions can play a crucial role. Many recent works have encouraged development based on deep learning technologies that can help human experts make better and faster decisions about their patient’s health. To accelerate detection of the presence of COVID-19 disease through X-ray images, our project aims to provide a new, completely automated diagnostic platform using convolutional neural networks (CNN) that is able to:

Stage 1. Segregate various types of medical reports like Chest CT, Chest X-Ray, Abdomen CT and then

Stage 2. Use the recognized Chest X-Ray reports for a downstream task of detecting COVID-19 or Viral Pneumonia.

We do this using 2 medical imaging datasets mentioned below.

Stage 1. Medical MNIST

Alt text

Stage 2. Covid-19 Image Dataset

Alt text

Problem Definition

Medical imaging plays a crucial role in the diagnosis and treatment of various diseases, and computer vision techniques have shown promising results in analyzing and interpreting medical images. With the outbreak of COVID-19, there has been a surge in the number of Chest CT and Chest X-Ray scans, making it challenging for radiologists to efficiently triage and diagnose patients. Therefore, there is a pressing need for an automated solution that can segregate medical reports based on their type and detect COVID-19 or Viral Pneumonia from Chest X-Ray reports.

In their work, Gao proposed a deep CNN to distinguish between Covid-19 Pneumonia and non-Covid-19 Pneumonia based on chest x-rays.[6] Both Hamza et. al. [7] and Kumar et. al [8] propose the use of pre-trained deep CNN models such as ResNet50 and InceptionV3 and enhance their capabilities through transfer learning for detecting Covid-19 using chest x-rays. In this project, we aim to develop a completely automated system that can segregate different types of medical reports and use the recognized Chest X-Ray reports for the downstream task of COVID-19 or Viral Pneumonia detection. The proposed solution has the potential to provide fast and accurate diagnoses, reducing the burden on radiologists and improving the overall efficiency of the healthcare system due to its high scalability.

Data Collection

The Medical MNIST and Covid-19 datasets are two popular medical image datasets collected from Kaggle. The Medical MNIST dataset is often used for classification tasks and is a good benchmark dataset for evaluating machine learning algorithms. On the other hand, the Covid 19 dataset consists of chest X-ray images of patients with Covid-19, normal patients, and patients with pneumonia. This dataset has been widely used for research on Covid-19 diagnosis and classification using machine learning techniques.

Data Cleaning

As both the datasets were taken from Kaggle and are standard datasets, there was no need for cleaning after our analysis. The images for COVID-19 were of different dimensions hence we resize all of them to (224, 224) which has been the standard image resolution for most of the similar medical imaging problems.

Methods

Supervised Methods

As the image dataset is high dimensional, we are primarily going to focus on using Convolutional Neural Networks to train our models for both the classification tasks.

Stage 1. Medical MNIST

Stage 2. COVID-19

  1. EfficientNet-b0
    • We use ImageNet pre-trained EfficientNet-b0 [5] model to benchmark the COVID-19 dataset.
    • ImageNet is a standard computer vision dataset that has 1000 classes and over 1 million images for the entire dataset.
    • Using a pre-trained model for downstream applications is called Transfer Learning. We use a pre-trained model because the images in this dataset are of higher dimensions and we found it harder to optimize as compared to Medical MNIST task.
    • We use batch size of 8, train the model for 40 epochs with a learning rate of 1e-4 using the Adam optimizer on the Cross Entropy Loss.
    • The architecture (compound scaling technique) and performance of the EfficientNet models is visualized below:

    Alt text

    Alt text

  2. ResNet-18
    • We also used a pre-trained ResNet-18 [4] model for the COVID-19 dataset.
    • ResNet-18 is a popular convolutional neural network architecture that has been shown to perform well on image classification tasks.
    • It has 18 layers and uses residual connections to improve training stability and performance.
    • We use the pre-trained model that allowed us to leverage the knowledge that the model has already learned from large amounts of data from the ImageNet dataset.
    • We use batch size of 8, train the model for 40 epochs with a learning rate of 1e-4 using the Adam optimizer on the Cross Entropy Loss.

Alt text

  1. MobileNet-V3-Small
    • MobileNetV3 [3] small is a lightweight neural network architecture optimized for mobile devices with limited computational resources.
    • It’s a combination of depthwise separable convolutions, linear bottlenecks, and a hard sigmoid activation function that can achieve high accuracy on image classification and other tasks while using fewer parameters and computational resources.
    • We use batch size of 8, train the model for 40 epochs with a learning rate of 1e-4 using the Adam optimizer on the Cross Entropy Loss.

Alt text

We choose the above models, specifically due to their exponential difference in parameters.

Model top-1 % top-5 % Parameters
ResNet18 69.758 89.078 11.7M
EfficientNet_B0 77.692 93.532 5.3M
MobileNet_V3_Small 67.668 87.402 2.5M

Oversampling and Augmentations

Unsupervised Methods

Visualizations

Stage 1: Medical MNIST

Class Distribution

We visualized the class distribution of the dataset using a bar graph. The bar graph showed that the dataset was well-balanced, with each class containing approx 10,000 images.

Here is a visualization of the class distribution:

Alt text

t-SNE Clusters on Raw Pixels

We used t-SNE (t-Distributed Stochastic Neighbor Embedding) to visualize the images in 2D space. We used the scikit-learn library in Python to perform the t-SNE analysis.

The t-SNE visualization showed that the images in the dataset were well-clustered by class. Each of the six classes formed distinct clusters in the 2D space. The CXR and Hand classes were well separated while the Abdomen CT and Chest CT had a lot of overlap.

Here is a visualization of the t-SNE clusters:

Alt text

t-SNE Clusters of our trained CNN embeddings

Here is a visualization of the t-SNE clusters:

Alt text

Stage 2: COVID-19

Class Distribution

We visualized the class distribution of the dataset using a bar graph. The bar graph showed that the dataset has more images of the Covid class while Normal X-ray Chest and Pneumonia are equal but less in number.

Here is a visualization of the class distribution:

Alt text

t-SNE Clusters on Raw Pixels

The three clusters even though seem separated, are intermixed to an extent that they are not easily separable. (0: COVID, 1: Normal, 2: Viral Pneumonia). Viral Pneumonia cluster has a massive overlap with Normal datapoints and a small overlap with COVID datapoints. There is a small overlap between COVID and normal datapoints. After we train our optimal model, we can see perfect separation of all the datapoints.

Here is a visualization of the t-SNE clusters:

Alt text

t-SNE Clusters of our trained CNN embeddings

We visualize the embeddings of MobileNet-v3-small that is our best model. Here is a visualization of the t-SNE clusters:

Alt text

Results

We report 2 supervised baselines, one for each of the dataset and report their validation performance using the following supervised metrics:

  1. Accuracy
  2. Precision and Recall
  3. F1 Score

Validation Results

Model Parameters Acc F1 P R
ResNet18 11.7M 93.94% 93.88% 94.95% 93.94%
EfficientNet_B0 5.3M 98.48% 98.48% 98.56% 98.48%
MobileNet_V3_Small 2.5M 100.00% 100.00% 100.00% 100.00%

Training Results

Model Parameters Acc F1 P R
ResNet18 11.7M 99.20% 99.20% 99.22% 99.20%
EfficientNet_B0 5.3M 100.00% 100.00% 100.00% 100.00%
MobileNet_V3_Small 2.5M 100.00% 100.00% 100.00% 100.00%

Ablations

EfficientNet-b0 Ablations validation results

Model Acc F1 P R
baseline 77.27% 77.34% 78.93% 77.27%
baseline + sampling 86.36% 85.64% 90.60% 86.36%
baseline + augmentation 59.09% 57.39% 80.25% 59.09%
final 98.48% 98.48% 98.56% 98.48%

EfficientNet-b0 Ablations training results

Model Acc F1 P R
baseline 99.20% 99.21% 99.23% 99.20%
baseline + sampling 100.00% 100.00% 100.00% 100.00%
baseline + augmentation 69.72% 66.78% 85.10% 69.72%
final 100.00% 100.00% 100.00% 100.00%

Final Results

Dataset Accuracy F1 Score Precision Recall
Medical MNIST 99.87% 99.87% 99.87% 99.87%
COVID-19 100.00% 100.00% 100.00% 100.00%

Result Analysis

Medical MNIST

COVID-19

COVID-19 Ablations

Contributions

Team8_Project tracker_7641 ML.xlsx

References

[1] Simonyan, Karen and Andrew Zisserman. “Very Deep Convolutional Networks for Large-Scale Image Recognition.” CoRR abs/1409.1556 (2014): n. pag.

[2] Szegedy, C. et al (2015, December 11). “Rethinking the inception architecture for computer vision” arXiv.org. Retrieved February 23, 2023, from https://arxiv.org/abs/1512.00567

[3] Howard, Andrew G. et al, “MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications”, 2017

[4] Kaiming He et al, “Deep Residual Learning for Image Recognition”, 2015

[5] Mingxing Tan and Quoc V. Le, “EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks”, 2019

[6] Gao, Terry. (2020). Chest X-ray image analysis and classification for COVID-19 pneumonia detection using Deep CNN. 10.21203/rs.3.rs-64537/v2.

[7] Hamza, Ameer, Muhammad Attique Khan, Majed Alhaisoni, Abdullah Al Hejaili, Khalid Adel Shaban, Shtwai Alsubai, Areej Alasiry, and Mehrez Marzougui. 2023. “D2BOF-COVIDNet: A Framework of Deep Bayesian Optimization and Fusion-Assisted Optimal Deep Features for COVID-19 Classification Using Chest X-ray and MRI Scans” Diagnostics 13, no. 1: 101. https://doi.org/10.3390/diagnostics13010101

[8] Kumar, S., Mallik, A. COVID-19 Detection from Chest X-rays Using Trained Output Based Transfer Learning Approach. Neural Process Lett (2022). https://doi.org/10.1007/s11063-022-11060-9

[9] Eurosurveillance editorial team. Note from the editors: World Health Organization declares novel coronavirus (2019-nCoV) sixth public health emergency of international concern. Euro Surveill. 2020 Feb;25(5):200131e. doi: 10.2807/1560-7917.ES.2020.25.5.200131e. Epub 2020 Jan 31. PMID: 32019636; PMCID: PMC7014669.

[10] Axell-House DB, Lavingia R, Rafferty M, Clark E, Amirian ES, Chiao EY. The estimation of diagnostic accuracy of tests for COVID-19: A scoping review. J Infect. 2020 Nov;81(5):681-697. doi: 10.1016/j.jinf.2020.08.043. Epub 2020 Aug 31. PMID: 32882315; PMCID: PMC7457918.