Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

DETECTION OF COVID-19 FROM CHEST X-RAYS

AND CT IMAGES USING RESNET-50

I. IINTRODUCTION
Abstract— The 2019 novel coronavirus disease (COVID-
19), with a starting point in China, has spread rapidly The coronavirus disease (COVID-19) pandemic emerged in
among people living in other countries, and is Wuhan, China in December 2019 and became a serious
approaching approximately 34,986,502 cases worldwide
public health problem worldwide [1,2]. Until now, no specific
according to the statistics of European Centre for Disease
Prevention and Control. There are a limited number of drug or vaccine has been found against COVID-19 [2]. The
COVID-19 test kits available in hospitals due to the virus that causes COVID-19 epidemic disease is called severe
increasing cases daily. Therefore, it is necessary to acute respiratory syndrome coronavirus-2 (SARS-CoV-2)
implement an automatic detection system as a quick [3]. Coronaviruses (CoV) is a large family of viruses that
alternative diagnosis option to prevent COVID-19 cause diseases such as Middle East Respiratory Syndrome
spreading among people. The aim of the study is to (MERS-CoV) and Severe Acute Respiratory Syndrome
evaluate performance of state-of-the-art pre-trained
(SARS-CoV). COVID-19 is a new species discovered in
model ResNet-50 using mixed precision and fine tuning.
1000 Chest X-ray and 750 CT images were used as dataset 2019 and has not been previously identified in humans [4].
for training and testing purposes. 95% and 82% COVID-19 causes lighter symptoms in about 99% of cases,
accuracies were obtained for Chest X-ray and CT according to early data, while the rest is severe or critical [5].
datasets individually. As of 4th October 2020, the total number of worldwide cases
of Coronavirus is 35,248,330. Of these, 1,039,541 (4%)
people were deaths and 26,225,235 (96%) were recovered.
Keywords— CNN, Deep Learning, Chest X-ray, The number of active patients is 7,983,554. Of these,
Transfer Learning, CT. 7,917,287 (99%) had mild disease while 66,267 (1%) had
more severe disease [6]. Nowadays the world is struggling
with the COVID-19 epidemic. Deaths from pneumonia
developing due to the SARS-CoV-2 virus are increasing day
by day.

Chest radiography (X-ray) is one of the most important


methods used for the diagnosis of pneumonia worldwide [7].
Chest X-ray is a fast, cheap [8] and common clinical method
[9-11]. The chest X-ray gives the patient a lower radiation
dose compared to computed tomography (CT) and magnetic
resonance imaging (MRI) [11]. However, making the correct
diagnosis from X-ray images requires expert knowledge and
experience [7]. It is much more difficult to diagnose using a
chest X-ray than other imaging modalities such as CT or MRI
[8]. By looking at the chest X-ray, COVID-19 can only be
diagnosed by specialist physicians. The number of specialists
who can make this diagnosis is less than the number of
normal doctors. Even in normal times, the number of doctors
per person is insufficient in countries around the world.
According to data from 2017, Greece ranks first with 607
doctors per 100,000 people. In other countries, this number is
much lower [12].

In case of disasters such as COVID-19 pandemic, demanding


health services at the same time, collapse of the health system
is inevitable due to the insufficient number of hospital beds
and health personnel. Also, COVID-19 is a highly contagious
disease, and doctors, nurses, and caregivers are most at risk.
Early diagnosis of pneumonia has a vital importance both in
terms of slowing the speed of the spread of the epidemic by Ghoshal and Tucker used the dropweights based Bayesian
quarantining the patient and in the recovery process of the CNN model using chest X-ray images for the diagnosis of
patient [13]. Doctors can diagnose pneumonia from the chest COVID-19 [23]. Hemdan et al. used VGG19 and DenseNet
X-ray more quickly and accurately thanks to computer-aided models to diagnose COVID-19 from X-ray images [24]. Uçar
diagnosis (CAD) [8]. Use of artificial intelligence methods and Korkmaz worked on X-ray images for COVID-19
are increasing due to its ability to cope with enormous diagnosis and supported the SqueezeNet model with
datasets exceeding human potential in the field of medical Bayesian optimization [25]. In the study conducted by
services [14]. Integrating CAD methods into radiologist Apostopolus et al., they performed automatic detection from
diagnostic systems greatly reduces the workload of doctors X-ray images using CNNs with transfer learning [26].
and increases reliability and quantitative analysis [11]. CAD
systems based on deep learning and medical imaging are Sahinbas and Catak used X-ray images for the diagnosis of
becoming more and more research fields [14,15]. COVID-19 and worked on VGG16, VGG19, ResNet,
DenseNet and InceptionV3 models [27]. Medhi et al. used X-
II. RELATED WORKS ray images as feature extraction and segmentation in their
study, then COVID-19 was positively and normally classified
Studies diagnosed with COVID-19 using chest X-rays have using CNN [28]. Barstugan et al. classified X-ray images for
binary or multiple classifications. Some studies use raw data the diagnosis of COVID-19 using five different feature
while others have feature extraction process. The number of extraction methods that are Grey Level Cooccurrence Matrix
data used in studies also varies. Among the studies, the most (GLCM), Local Directional Patterns (LDP), Grey Level Run
preferred method is convolutional neural network (CNN). Length Matrix (GLRLM), Grey Level Size Zone Matrix
(GLSZM), and Discrete Wavelet Transform (DWT). The
Apostolopoulos and Bessiana used a common pneumonia, obtained features were classified by SVM. During the
COVID-19-induced pneumonia, and an evolutionary neural classification process, 2-fold, 5-fold, and 10-fold cross-
network for healthy differentiation on automatic detection of validation methods were used [29]. Punn and Agarwal
COVID-19. In particular, the procedure called transfer worked on X-ray images and used ResNet, InceptionV3,
learning has been adopted. With transfer learning, the InceptionResNet models to diagnose COVID-19 [30]. Afshar
detection of various abnormalities in small medical image et al. developed deep neural network (DNN) based diagnostic
datasets is an achievable goal, often with remarkable results solutions and offered an alternative modeling framework
[16]. based on Capsule Networks that can process on small data
sets [31].
Based on chest X-ray images, Zhang et al. aimed to develop
a deep learning-based model that can detect COVID-19 with This study focuses on automatic prediction of COVID-19
high sensitivity, providing fast and reliable scanning [17]. using a deep convolution neural network based pre-trained
Singh et al. classified the chest computed tomography (CT) transfer model ResNet50 and chest X-ray and CT images.
images from infected people with and without COVID-19 The contribution of this study includes:-
using multi-objective differential evolution (MODE) based
CNN [18]. In the study of Chen et al, they proposed Residual a. Analysing the model on multimodal images including
Attention U-Net for automated multi class segmentation Chest X-ray and CT-scan having both positive and negative
technique to prepare the ground for the quantitative diagnosis cases.
of lung infection on COVID-19 related pneumonia using CT
images [19]. b. Using Pre-trained model ResNet-50, this study uses
methods like mixed precision and fine tuning using Fast AI
Adhikari's study suggested a network called “Auto v2 Library of PyTorch to achieve the best accuracy with very
Diagnostic Medical Analysis” trying to find infectious areas less execution time.
to help the doctor better identify the diseased part, if any.
Both X-ray and CT images were used in the study. It has been
recommended DenseNet network to remove and mark
infected areas of the lung [20]. In the study by Alqudah et al.,
two different methods were used to diagnose COVID-19
using chest X-ray images. The first one used AOCTNet,
MobileNet and ShuffleNet CNNs. Secondly, the features of
their images have been removed and they have been classified
using softmaxclassifier, K nearest neighbor (kNN), Support
vector machine (SVM) and Random forest (RF) algorithms
[21]. Khan et al. classified the chest X-ray images from
normal, bacterial and viral pneumonia cases using the
Xception architecture to detect COVID-19 infection [22].
to the target dataset. We also assume that the output layer of
the source model is closely related to the labels of the source
III. DESIGN AND METHODOLOGY dataset and is therefore not used in the target model.

• Add an output layer whose output size is the number of


target dataset categories to the target model, and randomly
A. DATASET AND PRE-PROCESSING initialize the model parameters of this layer.

The dataset for the project was gathered from two sources: • Train the target model on a target dataset, such as a chair
dataset. We will train the output layer from scratch, while the
A. Chest X-ray images (1000 images) were obtained from: parameters of all remaining layers are fine-tuned based on the
https://github.com/ieee8023/covid-chestxray-dataset. parameters of the source model.

So, Fine-tuning is a concept of transfer learning. Transfer


B. CT Scan images (750 images) were obtained from:
learning is a machine learning technique, where knowledge
https://github.com/UCSD-AI4H/COVID-
gain during training in one type of problem is used to train in
CT/tree/master/Data-split 80% of the images were used for
other related task or domain [32]. In deep learning, the first
training the models and the remaining 20% for testing.
few layers are trained to identify features of the task. During
transfer learning, you can remove last few layers of the
System Specifications: 2GB NVIDIA GPU, 8GB RAM with
trained network and retrain with fresh layers for target job.
Intel Core i7 8th Gen Processor. Python and all the necessary
Fine-tuned learning experiments require a bit of learning, but
packages like tensorflow, keras, Pytorch were used.
they are still much faster than learning from scratch [33].
Additionally, they are more accurate compared to models
trained from scratch.

Fig 1. Chest X-ray (L) and CT scan(R) image

B. PROPOSED METHODOLOGY

PRE- RESNET -
DATASET
PROCESSING 50
C
Fig 2. Fine Tuning

TRAINING MIXED FINE


AND D. MIXED PRECISION
PRECISION TUNING
TESTING There are numerous benefits to using numerical formats with
lower precision than 32-bit floating point. First, they require
. less memory, enabling the training and deployment of larger
neural networks. Second, they require less memory
bandwidth, thereby speeding up data transfer operations.
Third, math operations run much faster in reduced precision,
C. FINE TUNING especially on GPUs with Tensor Core support for that
precision. Mixed precision training achieves all these benefits
Fine tuning consists of the following four steps: while ensuring that no task-specific accuracy is lost compared
to full precision training. It does so by identifying the steps
• Pre-train a neural network model, i.e., the source model, on that require full precision and using 32-bit floating point for
a source dataset (e.g., the ImageNet dataset). only those steps while using 16-bit floating point everywhere
else.
• Create a new neural network model, i.e., the target model.
This replicates all model designs and their parameters on the Mixed precision is the use of both 16-bit and 32-bit floating-
source model, except the output layer. We assume that these point types in a model during training to make it run faster
model parameters contain the knowledge learned from the and use less memory. By keeping certain parts of the model
source dataset and this knowledge will be equally applicable in the 32-bit types for numeric stability, the model will have
a lower step time and train equally as well in terms of the IV. RESULTS AND DISCUSSION
evaluation metrics such as accuracy. This guide describes
how to use the experimental Keras mixed precision API to Performance were evaluated for both Chest X-ray and CT
speed up your models. Using this API can improve scan images individually by using Pre-Trained model
performance by more than 3 times on modern GPUs and 60% ResNet-50. Data Augmentation was used for increasing
on TPUs [34]. image complexity so that the model can learn more features.

20% was of the dataset was used for training.

E. FAST AI V2

Fastai is a deep learning library which provides practitioners Parameter Type/ Value
with high-level components that can quickly and easily Name
provide state-of-the-art results in standard deep learning
Epochs 10
domains, and provides researchers with low-level
components that can be mixed and matched to build new Batch Size 32
approaches. It aims to do both things without substantial
compromises in ease of use, flexibility, or performance. This Num_workers 0
is possible thanks to a carefully layered architecture, which
expresses common underlying patterns of many deep Input Size 100*100*3
learning and data processing techniques in terms of
decoupled abstractions. These abstractions can be expressed Table 1: Hyper parameters details
concisely and clearly by leveraging the dynamism of the
underlying Python language and the flexibility of the By using cnn_learner and learn.fine_tune the mixed precision
PyTorch library [35]. Fastai includes: and fine tuning were done. In learner command we mentioned
the training to be carried out in 16-bit floating point half
 A new type dispatch system for Python along with a precision format so that training time is reduced without any
semantic type hierarchy for tensors loss of information. By using half precision format lowers the
required memory enabling training of larger models or
 A GPU-optimized computer vision library which training with larger mini-batches.
can be extended in pure Python
By using fine tuning models training time is greatly reduced.
 An optimizer which refactors out the common Since using pre-trained weights, the model's first few layers
functionality of modern optimizers into two basic are already very effective. We just need to train the final
pieces, allowing optimization algorithms to be layers of your model and hence the model is free of problems
implemented in 4–5 lines of code like overfitting and activation exploding.

 A novel 2-way callback system that can access any


part of the data, model, or optimizer and change it at
any point during training

 A new data block API

F. RESNET-50

ResNet-50 is a convolutional neural network that is 50


layers deep. You can load a pretrained version of the
network trained on more than a million images from the
ImageNet database. The pretrained network can classify
images into 1000 object categories, such as keyboard,
mouse, pencil, and many animals. As a result, the Fig 4: Data Block Visualization (Chest X-ray)
network has learned rich feature representations for a
wide range of images. The network has an image input
size of 224-by-224 [36].

Fig 3. RESNET-50 Architecture Fig 5. Training of ResNet-50(Chest X-ray)


VI. REFERENCES

[1] Roosa K, Lee Y, Luo R, Kirpich A, Rothenberg R, Hyman


JM, and et al. Real-time forecasts of the COVID-19 epidemic
in China from February 5th to February 24th, 2020. Infectious
Disease Modelling, 5:256-263, 2020.

[2] Yan L, Zhang H-T, Xiao Y, Wang M, Sun C, Liang J, and


et al. Prediction of criticality in patients with severe COVID-
19 infection using three clinical features: a machine learning-
based prognostic model with clinical data in Wuhan.
medRxiv 2020.02.27.20028027, 2020.

[3] Stoecklin SB, Rolland P, Silue Y, Mailles A, Campese C,


Simondon A, and et al. First cases of coronavirus disease
2019 (COVID-19) in France: surveillance, investigations and
control measures, January 2020. Eurosurveillance,
Fig 6. Confusion Matrix for Chest X-ray 25(6):2000094, 2020.

[4] Coronavirus. World Health Organization:


https://www.who.int/healthtopics/coronavirus, 2020.
DATASET Accuracy Sensitivity Specificity
[5] McKeever A. Here's what coronavirus does to the body.
Chest X-ray 0.95 0.92 0.99 NationalGeographic:https://www.nationalgeographic.com/sc
CT-scan 0.82 0.86 0.80 ience/2020/02/here-is-what-coronavirus-doesto-the-body/,
2020.

[6] COVID-19 Coronavirus Pandemic. worldometer:


Table 2: Performance for Chest-Xray and CT scan https://www.worldometers.info/ coronavirus/, 2020.
All the above results were achieved within 5 min of execution [7] Jaiswal AK, Tiwari P, Kumar S, Gupta D, Khanna A, and
time. This study achieved best results for Chest X-ray Rodrigues JJ. Identifying pneumonia in chest X-rays: A deep
datasets, although the results were satisfactory for CT-scan learning approach. Measurement, 145:511-518, 2019.
images but it can be improved if we have more images to train
the model. [8] Antin B, Kravitz J, and Martayan E. Detecting Pneumonia
in Chest X-Rays with Supervised Learning.
http://cs229.stanford.edu/proj2017/final-
reports/5231221.pdf, 1-5, 2017.
V. CONCLUSION
[9] Das NN, Kumar N, Kaur M, Kumar V, and Singh D.
Automated Deep Transfer Learning-Based Approach for
Early prediction of COVID-19 patients is vital to prevent the Detection of COVID-19 Infection in Chest X-rays. IRBM,
spread of the disease to other people. In this study a deep https://doi.org/10.1016/j.irbm.2020.07.001, 2020.
transfer learning based approach was used for multimodal [10] Ayan E, and Ünver HM. Diagnosis of Pneumonia from
images of X-ray and CT using pre-trained model ResNet-50. Chest X-Ray Images Using Deep Learning. Scientific
By using methods like mixed precision and fine tuning this
Meeting on Electrical-Electronics Biomedical Engineering
study achieved best results for Chest X-ray dataset(acc: 0.95,
and Computer Science (EBBT), Istanbul, Turkey, pp. 1-5,
sensitivity: 0.92, specificity: 0.99) and satisfactory results for https://doi.org/10.1109/EBBT.2019.8741582, 2019.
CT-scan dataset(acc: 0.82, sensitivity: 0.86, specificity: 0.80)
with very less execution time . [11] Gaál G, Maga B, and Lukács A. Attention U-Net Based
Adversarial Architectures for Chest X-ray Lung
This study focused on concepts of transfer learning used for
Segmentation. arXiv:2003.10304, 2020.
medical image processing using pre-trained models and it is
believed that it will help in diagnosing for making quick [12] https://tr.euronews.com Accessed 4 October 2020.
decisions in clinical practice due to the higher performance
and less execution time with extreme accuracy. [13] Kadam K, Ahirrao S, Kaur H, Phansalkar S, and Pawar
A. Deep Learning Approach for Prediction of Pneumonia.
International Journal of Scientific Technology Research.
8(10):2986-2989, 2019.

[14] Liang G, and Zheng L. A transfer learning method with


deep residual network for pediatric pneumonia diagnosis.
Computer Methods and Programs in Biomedicine, with Xray. https://www.ozgurcatak.org/files/papers/covid19-
187:104964, 2020. deep-learning.pdf, 2020.

[15] Jaiswal A, Gianchandani N, Singh D, Kumar V, and [28] Jamil M, and Hussain I. Automatic Detection of COVID-
Kaur M. Classification of the COVID-19 infected patients 19 Infection from Chest X-ray using Deep Learning.
using DenseNet201 based deep transfer learning. Journal of medRxiv, https://doi.org/10.1101/2020.05.10.20097063,
Biomolecular Structure and Dynamics, 1-8, 2020.
https://doi.org/10.1080/07391102.2020.1788642, 2020.
[29] Barstugan M, Ozkaya U, and Ozturk S. Coronavirus
[16] Apostolopoulos ID, and Mpesiana TA. Covid-19: (COVID-19) Classification using CT Images by Machine
automatic detection from x-ray images utilizing transfer Learning Methods. arXiv:2003.09424, 2020.
learning with convolutional neural networks. Physical and
Engineering Sciences in Medicine, 43:635-640, 2020. [30] Punn NS, and Agarwal S. Automated diagnosis of
COVID-19 with limited posteroanterior chest X-ray images
[17] Zhang J, Xie Y, Li Y, Shen C, and Xia Y. COVID-19 using fine-tuned deep neural networks. arXiv:2004.11676v2,
Screening on Chest X-ray Images Using Deep Learning 2020.
based Anomaly Detection. arXiv:2003.12338v1, 2020.
[31] Afshar P, Heidarian S, Naderkhani F, Oikonomou A,
[18] Singh D, Kumar V, and Kaur M. Classification of Plataniotis KN, and Mohammadi A. COVID-CAPS: A
COVID-19 patients from chest CT images using multi- Capsule Network-based Framework for Identification of
objective differential evolution-based convolutional neural COVID-19 cases from X-ray Images. ArXiv: 2004.02696v2,
networks. European Journal of Clinical Microbiology 2020.
InfectiousDiseases,https://doi.org/10.1007/s10096-020-
03901-z, 2020. [32] Pan, S.J., Fellow, Q.Y., 2009. A Survey on Transfer
Learning, pp. 1–15.
[19] Chen X, Yao L, and Zhang Y. Residual Attention U-Net
for Automated Multi-Class Segmentation of COVID-19 [33] Mohanty, S.P., Hughes, D.P., Salathé, M., 2016. Using
Chest CT Images. arXiv:2004.05645v1, 2020. deep learning for image-based plant disease detection. Front.
Plant Sci. 7 (September), 1–7.
[20] Adhikari NCD. Infection Severity Detection of
CoVID19 from X-Rays and CT Scans Using Artificial [34] https://www.tensorflow.org/guide/mixed_precision.
Intelligence. International Journal of Computer (IJC),
38(1):73-92, 2020. [35] https://docs.fast.ai/.

[21] Alqudah AM, Qazan S, and Alqudah A. Automated [36]https://www.mathworks.com/help/deeplearning/ref/resn


Systems for Detection of COVID-19 Using Chest X-ray et50.
Images and Lightweight Convolutional Neural Networks.
https://doi.org/10.21203/rs.3.rs-24305/v1, 2020.

[22] Khan AI, Shah JL, and Bhat MM. Coronet: A deep
neural network for detection and diagnosis of COVID-19
from chest x-ray images. Computer Methods and Programs
in Biomedicine, 196:105581, 2020.

[23] Ghoshal B, and Tucker A. Estimating Uncertainty and


Interpretability in Deep Learning for Coronavirus (COVID-
19) Detection. arXiv:2003.10769v1, 2020.

[24] Hemdan EED, Shouman MA, and Karar ME. COVIDX-


Net: A Framework of Deep Learning Classifiers to Diagnose
COVID-19 in X-Ray Images. arXiv:2003.11055, 2020.

[25] Ucar F, and Korkmaz D. COVIDiagnosis-Net: Deep


Bayes-SqueezeNet based diagnosis of the coronavirus
disease 2019 (COVID-19) from X-ray images. Medical
Hypotheses, 140:109761, 2020.

[26] Apostolopoulos ID, Aznaouridis SI, and Tzani MA.


Extracting possibly representative COVID-19 Biomarkers
from X-Ray images with Deep Learning approach and image
data related to Pulmonary Diseases. Journal of Medical and
Biological Engineering, 40:462-469, 2020.

[27] Sahinbas K, and Catak FO. Transfer Learning Based


Convolutional Neural Network for COVID-19 Detection

You might also like