You are on page 1of 32

ABSTRACT

The detection of severe acute respiratory syndrome coronavirus 2 (SARS cov-2), which is responsible for
coronavirus disease 2019 (COVID-19), using chest X-ray images has life- saving importance for both patients
and doctors. X-rays are cost-effective and widely available at public health facilities, hospital emergency
rooms they could be used for rapid detection of possible COVID-19-induced lung infections. Therefore,
toward automating the COVID-19 detection, in this paper, we propose a viable and efficient deep learning-
based chest radiograph classification (DL-CRC) framework to distinguish the COVID-19 cases with high
accuracy from other abnormal and normal cases. A unique dataset is prepared from four publicly available
sources containing the chest view of X-ray data for COVID-19, pneumonia, and normal cases. Our system
consists of Convolution Neural Network (CNN) architecture capableof detecting masked and unmasked faces.
The encouragingly high classification accuracy of our proposal implies that it can efficiently automate
COVID-19 detection from radiograph images to provide a fast and reliable evidence of COVID-19 infection
in the lung that can complement existing COVID-19 diagnostics modalities.

II
CONTENTS
CHAPTER NO DESCRIPTION PAGE NO

1 INTRODUCTION 1-7

2 LITERATURE REVIEW 8-14

3 SYSTEM REQUIREMENTS 15-18

4 SYSTEM ANALYSIS 19-20

5 SYSTEM DESIGN 21-28

6 METHODOLOGY 29-37

CONCLUSION 38

REFERENCES 39-40
Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

CHAPTER 1

INTRODUCTION
The outbreak of coronavirus disease in December 2019 in China spread rapidly across all parts
of the world by January 2020. The World Health Organization (WHO) termed it as COVID-
19 and declared it a pandemic on January 30, 2020. Till June 8th, 2020, the number of
confirmed cases is around 7 million globally, and the global fatality rate is around 3-4%.Sinceit
is a highly contagious disease and is spreading rapidly, governments of almost all of the
affected countries are taking it on priority to isolate infected individuals as early as possible.
The general symptoms of COVID-19 patients are flu-like such as fever, cough, dyspnoea,
breathing problem, and viral pneumonia. But these symptoms alone are not significant. There
are many cases where individuals are asymptomatic but their chest CT scan and the pathogenic
test were COVID-19 positive. So, along with symptoms, positive pathogenic testing and
positive CT images/X-Rays of the chest are being used to diagnose the disease. For
pathological testing, Real‐ time PCR is being used as a standard diagnostic tool. Healthcare
systems around the world are attempting to expand testing facilities for COVID-19. More and
more testing will lead to the identification and isolation of infected persons, thereby reducing
the spread among the community. But availability does not ensure reliability. The major
concern for the governments at this stage is the false negative test results – the test results are
negative for the infected individual. Such individuals may unknowingly transmit the virus to
others. False test results thus have a negative effect on the efforts to curb the spread of the
virus. The impact of this concern on the safety of public and health workers can’t be determined
as there are no clear or consistent reports on these test performance characteristics. The
sensitivity of these tests is largely unknown.

In this scenario, Chest X-Rays of COVID-19 patients have proved to be an important


alternative tool for COVID19 diagnosis due to its high sensitivity. But the accuracy of
diagnosis using X-Rays strongly depends on radiological expertise. And it becomes a tedious
task when the number of patients is large. A diagnosis recommender system that can assist the
doctor to examine the lung images of the patients will reduce the diagnostic burden of the
doctor. In several studies, CT scans were used for analysing and detecting features of COVID19
due to higher resolution of features of ground glass opacities and lung consolidation compared
to chest X-ray images. However, due to infection control matters associated with patient
transport to CT suites, relatively high cost (for procurement, operation and

Dept., of CSE, VKIT Page 1


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

equipment), and the limited number of CT machines in developing/rural areas, CT scan is not a
practical solution for detecting COVID-19. On the other hand, chest X-ray can be employed to
identify COVID-19 or other pneumonia cases as a more practical and cost-effective solution
because X-ray imaging equipment are pervasive at hospital ERs, public healthcare facilities,
and even rural clinics. Even for trained radiologists, detecting chest X-ray images pose
challenges to distinguish between features of COVID-19 and community acquired bacterial
pneumonia. Moreover, the influx of patients into hospital ERs during pandemic, manual
inspection of radiograph data and accurate decision making can lead to a formidable tradeoff
between detection time and accuracy that can overwhelm the radiologist department.
Therefore, an automated classification technique needs to be designed. As the second wave of
COVID-19 is expected in many countries, preparedness to combat the pandemic will involve
increasing use of portable chest X-ray devices due to widespread availability and reduced
infection control issues that currently limit CT utilization.

In the following section, we address the aforementioned problem and present a deep
learning-based approach to effectively solve the problem. Deep Learning techniques are
artificial neural networks in which each layer has multiple neurons that function similarly to
the neurons of the human body. Convolutional neural networks (CNNs) are one of the deep
learning techniques that have proven to be successful and effective in the field of medical
imaging classification. There have been several studies that have used CNN to diagnose
pneumonia and other diseases based on radiography. CNN based architecture has been
proposed in to identify different lung diseases. In, the Chest X-Ray dataset consisting of around
100,000 X-ray images was used to train a CNN model for the diagnosis of 14 diseases. CNN
has also been used for predicting pneumonia. A recommendation system has been proposed
that helps radiologists to identify infected areas in CT images.

Hence CNN becomes a natural candidate for diagnosis recommendation of COVID-19


patients. Seven different existing deep learning neural network architectures were compared
using small data sets consisting of only 50 images. Out of 50 samples, 25 were of COVID-19
positive and 25 from COVID-19 negative patients. Some researchers have proposed new
architectures of CNN for the problem of classifying Chest X-Rays. But they still are in the
preprint stage.

Dept., of CSE, VKIT Page 2


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

1.1 SCOPE

With the rapidly surging pandemic, the demand for efficient COVID-19 detection has
dramatically increased. The lack of availability of COVID-19 viral and antibody test-kits, and
the time required to obtain the test results (in the order of days to weeks) in many countries are
posing a great challenge in developing/rural areas with less equipped hospitals or clinics. For
instance, in many developing countries, hospitals do not have sufficient COVID-19 test-kits,
and therefore, they require the assistance of more advanced medical centers to collect,
transport, and test the samples. This creates a bottleneck in mass testing for COVID-19.
Therefore, to meet the daily demand for an enormous amount of new test cases, an automated
and reliable complementary COVID-19 detection modality is necessary, particularly to
confront the second wave of the. Radiograph image utilization for initial COVID-19 screening
may play a pivotal role in areas pandemic with inadequate access to a viral/antibody testing.

1.2 OBJECTIVE

Deep Learning techniques are artificial neural networks in which each layer has multiple
neurons that function similarly to the neurons of the human body. Convolutional neural
networks (CNNs) are one of the deep learning techniques that have proven to be successful and
effective in the field of medical imaging classification. CNN based architecture has been
proposed in to identify different lung diseases. In, the Chest X-Ray dataset consisting of around
1,000 X-ray images was used to train a CNN model for the diagnosis of covid-19 disease. CNN
has also been used for predicting pneumonia. A recommendation system has been proposed in
that helps radiologists to identify infected areas in CT images.

1.3 PROBLEM STATEMENT

Real-time PCR is a standard diagnostic tool being used for pathological testing.But the
increasing number of false test results has opened the path for exploration of alternative testing
tools. Chest X-Rays of covid-19 patients have proved to be an important alternative indicator
of in covid- 19 screening A diagnosis recommender system that can assist the doctor to examine
the lung images of the patients will reduce the diagnostic burden of the doctor.

Dept., of CSE, VKIT Page 3


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

CHAPTER 2

LITERATURE SURVEY
This section explores the relevant research work in the literature from two perspectives, i.e.,
imaging modalities for COVID-19 detection, and AI-based analysis of radiograph samples.

[1] Title: Imaging Modalities For Covid-19 Detection


Authors: Di dong, Zencho Tang, Shuowang, Homengliao, Fan Yang
Published Year: 2020
Findings:
Most nations had to take measures to react to the sudden and rapid outbreak of COVID-19
within a relatively short period of time. According to [12], radiology departments have started
to focus more on preparedness rather than diagnostic capability, after sufficient knowledge was
gathered regarding COVID-19. The study in [5] stated the resemblance of COVID-19 with
other diseases caused by other coronavirus variants such as the severe acute respiratory
syndrome (SARS) and the middle east respiratory syndrome (MERS). The importance of a
tracking the lung condition of a recovering coronavirus patient using CT scans was also
mentioned in the study. Chest imaging techniques were highlighted to be a crucial technique
for detecting COVID-19 by capturing the bilateral nodular and peripheral ground glass
opacities in the lung radiograph images.

Advantages:
 The quantitative analysis of imaging data using AI is also explored.
 Ultrasound is one of the most commonly used imaging modalities in clinical practices.

Disadvantages:
 Cost Expensive.
 CT scan alone can detect Pneumonia Chest X-Rays are essential.

Dept., of CSE, VKIT Page 4


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

[2] Title: Clinical features of patients infected with 2019 novel corona virus
in Wuhan, China
Authors: Prof Chaloin Huang, Yeming Wang, Prof Xingwang Li
Published Year: 2020
Findings:
All patients with suspected 2019-nCoV were admitted to a designated hospital in Wuhan. We
prospectively collected and analysed data on patients with laboratory-confirmed 2019-nCoV
infection by real-time RT-PCR and next-generation sequencing. Data were obtained with
standardised data collection forms shared by WHO and the International Severe Acute
Respiratory and Emerging Infection Consortium from electronic medical records. Researchers
also directly communicated with patients or their families to ascertain epidemiological and
symptom data. Outcomes were also compared between patients who had been admitted to the
intensive care unit (ICU) and those who had not. The 2019-nCoV infection caused clusters of
severe respiratory illness similar to severe acute respiratory syndrome coronavirus and was
associated with ICU admission and high mortality. Major gaps in our knowledge of the origin,
epidemiology, duration of human transmission, and clinical spectrum of disease need
fulfilment by future studies. Following the pneumonia cases of unknown cause reported in
Wuhan and considering the shared history of exposure to Huanan seafood market across the
patients, an epidemiological alert was released by the local health authority on Dec 31, 2019,
and the market was shut down on Jan 1, 2020. Meanwhile, 59 suspected cases with fever and
dry cough were transferred to a designated hospital starting from Dec 31, 2019. An expert team
of physicians, epidemiologists, virologists, and government officials was soon formed after the
alert.

Advantages:
 More accurate.
Disadvantages:
 Time consuming.
 Less availability.
 More cost.

Dept., of CSE, VKIT Page 5


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

[3] Title: DL-CRC: Deep Learning-Based Chest Radiograph Classification


for COVID-19 Detection
Authors: Sadman Sakib, Tharat Tazrin, Mostafa M. Fouda, Zubair MD. Fadlullah, Mohsen
Guizani
Published Year: 2020
Findings:
A Novel Approach With the exponentially growing COVID-19 (coronavirus disease 2019)
pandemic, clinicians continue to seek accurate and rapid diagnosis methods in addition to virus
and antibody testing modalities. Because radiographs such as X-rays and computed
tomography (CT) scans are cost-effective and widely available at public health facilities,
hospital emergency rooms (ERs), and even at rural clinics, they could be used for rapid
detection of possible COVID19-induced lung infections. Therefore, toward automating the
COVID-19 detection, in this paper, we propose a viable and efficient deep learning-based chest
radiograph classification (DL-CRC) framework to distinguish the COVID-19 cases with high
accuracy from other abnormal (e.g., pneumonia) and normal cases. A unique dataset is prepared
from four publicly available sources containing the posteroanterior (PA) chest view of X-ray
data for COVID-19, pneumonia, and normal cases. Our proposed DL-CRC framework
leverages a data augmentation of radiograph images (DARI) algorithm for the COVID-19 data
by adaptively employing the generative adversarial network (GAN) and generic data
augmentation methods to generate synthetic COVID-19 infected chest X-ray images to train a
robust model. The training data consisting of actual and synthetic chest X-ray images are fed
into our customized convolutional neural network (CNN) model in DL-CRC, which achieves
COVID-19 detection accuracy of 93.94% compared to 54.55% for the scenario without data
augmentation (i.e., when only a few actual COVID-19 chest X-ray image samples are available
in the original dataset).
Advantages:
 It provides reasonable accuracy for COVID-19 detection.
 It requires less man power.
Disadvantages:
 The system might be having some fault due to faculty software installation.

Dept., of CSE, VKIT Page 6


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

[4] Title: COVIDX-Net: A Framework of Deep Learning Classifiers to


Diagnose COVID-19 In X-Ray Iamges.
Authors: Ezz El-Din Hemdan, Marwa A. Shouman, Mohamed Esmail Karar
Published Year: 2020
Findings:
The aim of this article is to introduce a new deep learning framework; namely COVIDX-Net to
assist radiologists to automatically diagnose COVID-19 in X-ray images. Materials and
Methods: Due to the lack of public COVID-19 datasets, the study is validated on 50 Chest X-
ray images with 25 confirmed positive COVID-19 cases. The COVIDX-Net includes seven
different architectures of deep convolutional neural network models, such as modified Visual
Geometry Group Network (VGG19) and the second version of Google MobileNet. Each deep
neural network model is able to analyze the normalized intensities of the X-ray image to
classify the patient status either negative or positive COVID-19 case. Results: Experiments and
evaluation of the COVIDX-Net have been successfully done based on 80-20% of X-ray images
for the model training and testing phases, respectively. The VGG19 and Dense Convolutional
Network (DenseNet) models showed a good and similar performance of automated COVID-
19 classification with f1-scores of 0.89 and 0.91 for normal and COVID-19, respectively. This
study demonstrated the useful application of deep learning models to classify COVID-19 in X-
ray images based on the proposed COVIDX-Net framework. Clinical studies are the next
milestone of this research work.
Advantages:
 The proposed COVIDX-Net framework supports interdisciplinary researches to
continue developing advanced artificial intelligence techniques for CAD systems to
fight COVID-19 outbreak.
 Time required is less compared to other models.
Disadvantages:
 Overall performance evaluation is low.

Dept., of CSE, VKIT Page 7


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

[5] Title: Pneumonia Detection In Covid-19 Patients Using CNN Algorithm


Authors: Vishesh, Nishanth, Bharath, Amith
Published Year: 2020
Findings:
The outbreak of corona virus disease in December 2019 in China spread rapidly across all parts
of the world by January 2020. The World Health Organization (WHO) termed it as COVID-
19 and declared it a pandemic on January 30, 2020. Till June 8th, 2020, the number of
confirmed cases is around 7 million globally, and the global fatality rate is around 3-4%. Sinceit
is a highly contagious disease and is spreading rapidly, governments of almost all of the
affected countries are taking it on priority to isolate infected individuals as early as possible.
The general symptoms of COVID19 patients are flu-like such as fever, cough, dyspnea,
breathing problem, and viral pneumonia. But these symptoms alone are not significant. There
are many cases where individuals are asymptomatic but their chest CT scan and the pathogenic
test were COVID-19 positive. So, along with symptoms, positive pathogenic testing and
positive CT images/X-Rays of the chest are being used to diagnose the disease. Deep Learning
(DL) techniques specifically Convolutional Neural Networks (CNN) has proven successful in
medical imaging classification. Four different deep CNN architectures were investigated on
images of chest X-Rays for diagnosis of COVID-19. These models have been pre-trained on
the traintest database thereby reducing the need for large training sets as they have pre-trained
weights. It was observed that CNN based architectures have the potential for diagnosis of
COVID-19 disease.
Advantages:
 Validation loss can be reduced and thereby increasing the detection accuracy by AI
unit.
 Chest X-Ray is used to decrease the negative false report of COVID-19.
Disadvantages:
 If epoch increases, model takes more time for prediction..

Dept., of CSE, VKIT Page 8


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

CHAPTER 3

SYSTEM ANALYSIS
In system engineering and software engineering, requirements analysis focuses on the tasks
that determine the needs or conditions to meet the new or altered product or project, taking
account of the possibly conflicting requirements of the various stakeholders, analyzing,
documenting, validating and managing software or system requirements. Requirements
analysis is critical to the success or failure of systems or software project. The requirements
should be documented, actionable, measurable, testable, traceable, related to identified
business needs or opportunities, and defined to a level of detail sufficient for system design.

3.1 Existing System


Samples are taken from places likely to have the virus that causes COVID-19, like the back of
the nose or mouth or deep inside the lungs. After a sample is collected, RNA, which is part of
the virus particle, is extracted and converted to complementary DNA for testing. The PCR test
involves binding sequences on the DNA that only are found in the virus and repeatedly copying
everything in between. This process is repeated many times, with doubling of the target region
with each cycle. A fluorescent signal is created when amplification occurs, and once the signal
reaches a threshold, the test result is considered positive. If no viral sequence is present,
amplification will not occur, resulting in a negative result. Recommendations for testing are
regularly updated by the Centers for Disease Control and Prevention (CDC).
3.1.1 Limitations of Existing System

Fig 3.1: Limitations of Existing System

Dept., of CSE, VKIT Page 9


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

 The existing system for detecting COVID-19 using aforementioned virus and antibody testing
modalities is time-consuming and requires additional resources and approval, which can be a
luxury in many developing communities.
 Hence, at many medical centers, the test kits are often unavailable.
 Due to the shortage of kits and false-negative rate of virus and antibody tests, the authorities in
Hubei Province, China momentarily employed radiological scans as a clinical investigation for
COVID-19.

3.2 Proposed System


A diagnosis recommender system that can assist the doctor to examine the lung images of the patients
is designed using the Deep Learning techniques. In this work we propose the use of Chest X-Ray to
pritorize the selection of patients for further testing. Deep Learning techniques are artificial neural
networks in which each layer has multiple neurons that function similarly to the neurons of the human
body. Convolutional neural networks (CNNs) are one of the deep learning techniques that have proven
to be successful and effective in the field of medical imaging classification. There have been several
studies that have used CNN to diagnose pneumonia and other diseases based on radiography. CNN
based architecture has been proposed in to identify different lung diseases. In , the Chest X-Ray dataset
consisting of around 100,000 X-ray images was used to train a CNN model for the diagnosis of 14
diseases. CNN has also been used for predicting pneumonia . A recommendation system has been
proposed in [9] that helps radiologists to identify infected areas in CT images. Hence CNN becomes a
natural candidate for diagnosis recommendation of COVID-19 patients. In, seven different existing
deep learning neural network architectures were compared using small data sets consisting of only 50
images. Out of 50 samples, 25 were of COVID-19 positive and 25 from COVID-19 negative patients.

3.2.1 Advantages of Proposed System


 Training in minutes.
 Test results in seconds or milliseconds.
 No human intervention. System once trained can carry out n number of testing for pneumonia
in covid-19 positive patients
 Code or model which is dynamic can be reused.
 CNN algorithm has high prediction accuracy to any image set.
 Patient database can be updated in real time and model is dynamic.

3.3 System Requirements Specification


3.3.1 Software Requirements
 Anaconda navigator, Jupyter Notebook,Python 3.7

Dept., of CSE, VKIT Page 10


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

 Python 3.3 or 2.7 or higher


 Libraries: Matplotlib,Seaborn ,Numpy ,Pandas ,Keras ,Tensorflow ,Pillow,
 SK Learn ,Open CV, OS

3.3.2 Hardware Requirements


 Processor: 64-bit 2.8GHz 8.00 GT/s, i3/i5/i7
 Laptop or PC
 Web Camera, Mobile Camera
 RAM: 8GB or higher
 Operating System: Windows 8 or newer, 64-bit macOS 10.13+, or Linux, including
Ubuntu, RedHat, CentOS 6+ and others.

Dept., of CSE, VKIT Page 11


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

CHAPTER 4

DESIGN
4.1 SYSTEM ARCHITECTURE

Fig 4.1: System Architecture


The above figure shows the system architecture. Various deep learning based approaches have
been developed to identify different thoracic diseases, including pneumonia . We choose
Cascade classifier (CNN Model) to build upon, which could detect pneumonia from chest X-
Rays at a level exceeding practicing radiologists. CNN is trained on ChestX-ray (the largest
publicly available chest X-ray dataset), gives better performance than previous approaches and
has a simpler architecture than later approaches. The model is trained to classify X-Ray images
into COVID-19 or normal. The model takes images as input and identifies the patterns in them
and classify the images. Given the visual similarity of the input samples, we found this to be
the closest pre-trained backbone to develop a model for identifying COVID-19.

4.2 METHODOLOGY

Fig 4.2: Methodology

Dept., of CSE, VKIT Page 12


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

There are six steps which need to be followed. They are mentioned below:
 Data Acquisition
A total of 1000 Chest X-Ray images were collected from public databases
available on various GitHub repositories. Among these, 400 were of COVID-19
positive patients and 600 were of patients who did not have the virus. Images were
classified as COVID-19 and Non-COVID-19.
 Data Splitting
The ratio is used to divide into training and testing sets was kept at 75:25. For
ttraining 750 records were used and 250 were used for testing. The validation set is kept
as 30% of the training set.
 Data Preprocessing
The image which is in jpg or jpeg format is fed to the pre-processing unit where
RGB to Grey conversion takes place and the image is resized at 1:1 ratio (100/100).
 CNN
Next, we need to train a deep learning model which can take advantage of the
robust dataset obtained from our proposed algorithm. Since the problem can be
regarded as a classification task of normal, COVID-19, and other abnormal cases (e.g.,
pneumonia), we investigate the contemporary deep learning architectures suited for
classification. In contrast with other variants of deep learning architectures (i.e., long-
short term memory (LSTM), deep belief networks, and so forth) and extreme learning
machines, CNNs are regarded as the most powerful deep learning architecture for image
classification. Therefore, we explore the robust CNN models recently employed to gain
reasonable classification accuracy with chest X-ray data. By applying the contemporary
CNN models on the latest dataset compiled from four and public repositories, we realize
that their reported performances are constrained by overfitting and influenced by biased
test data. To address this issue, we propose a two-dimensional (2-D), custom CNN
model for classifying X-ray images to predict COVID-19 cases.The 2-D CNN structure
is utilized to learn the discriminating patterns automatically from the radiograph
images. The proposed CNN model consists of three components. The first component
is a stack of nc convolution layers while the second segment consists of nd fully
connected layers. The final component is responsible for generating the output
probability. At first, the convolution layers (i.e., the first component of the model)
receive radiograph images (X) as input, identify discriminative features from the input

Dept., of CSE, VKIT Page 13


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

examples, and pass them to the next component for the classification task. Each ith
layer among the nc convolution layers consists of a filter size of zi. Initially, the filter
size is set to xir in the 1st layer, and it is decreased by λ in each successive layer.
 Iterations
Online Jupyter Notebook based service Collaboration by Google Research was
used to execute the Python code. The Tesla P4 GPU was used for faster processing
which is provided by Collaboratory. Adadelta Optimizer was used to train all the
networks and Mean Squared Error was used as the loss function. For training, the batch
size was set to 32 and the number of epochs was set to 25.
 Real Time Testing
Real- time images are fed to the system and now the trained system takes
decisions that based on the matrix formation and CNN model.

Dept., of CSE, VKIT Page 14


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

CHAPTER 5

IMPLEMENTATION
Implementation phase plays a vital role in implementing the design requirements into the
reality. Final result can be found in the implementation phase. Therefore, successful new
system can be achieved in this key stage. Careful planning and controlling are required in this
implementation phase. Major decisions have to be taken care, before implementing any project.
They are as follows:
 Selecting the proper attributes in the data that are used for implementing the model.
 Selecting the right tool that is used to implement the different machine learning
algorithms in order to get the desired results.
 Storing the data in the format that tool works on.
 Obtaining desired result using the tool.

5.1 Data Preprocessing


The below code is used for data preprocessing:
import cv2,os
data_path=r'C:\Users\Harishitha\Downloads\covid'
categories=os.listdir(data_path)
labels=[i for i in range(len(categories))]
label_dict=dict(zip(categories,labels))
print(label_dict)
print(categories)
print(labels)
img_size=100
data=[] target=[]
for category in categories:
folder_path=os.path.join(data_path,category)
img_names=os.listdir(folder_path)

for img_name in img_names:


img_path=os.path.join(folder_path,img_name)
img=cv2.imread(img_path)

Dept., of CSE, VKIT Page 15


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

try:
gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
#Coverting the image into gray scale
resized=cv2.resize(gray,(img_size,img_size))
#resizing the gray scale into 100x100, since we need a fixed common size for all the
images in the dataset
data.append(resized)
target.append(label_dict[category])
#appending the image and the label(categorized) into the list (dataset)

except Exception as e:
print('Exception:',e)
#if any exception rasied, the exception will be printed here. And pass to the next
image
import numpy as np
data=np.array(data)/255.0
data=np.reshape(data,(data.shape[0],img_size,img_size,1))
target=np.array(target)
from keras.utils import np_utils
new_target=np_utils.to_categorical(target)
np.save('data',data)
np.save('target',new_target)

5.2 Loading Data

Loading the save numpy arrays in the previous code.


import numpy as np
data=np.load('data.npy')
target=np.load('target.npy')

5.3 Model Creation


from keras.models import Sequential
from keras.layers import Dense,Activation,Flatten,Dropout
from keras.layers import Conv2D,MaxPooling2D

Dept., of CSE, VKIT Page 16


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

from keras.callbacks import ModelCheckpoint


model=Sequential()
model.add(Conv2D(200,(3,3),input_shape=data.shape[1:]))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2,2)))
#The first CNN layer followed by Relu and MaxPooling layers
model.add(Conv2D(100,(3,3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2,2)))
#The second convolution layer followed by Relu and MaxPooling layers
model.add(Flatten())
model.add(Dropout(0.5))
#Flatten layer to stack the output convolutions from second convolution layer
model.add(Dense(50,activation='relu'))
#Dense layer of 64 neurons
model.add(Dense(2,activation='softmax'))
#The Final layer with two outputs for two categories
model.compile(loss='categorical_crossentropy',optimizer='adam',metrics=['accuracy'])

5.4 Training and Testing


from sklearn.model_selection import train_test_split
train_data,test_data,train_target,test_target=train_test_split(data,target,test_size=0.1)
checkpoint = ModelCheckpoint('model-
{epoch:03d}.model',monitor='val_loss',verbose=0,save_best_only=True,mode='auto')
history=model.fit(train_data,train_target,epochs=10,callbacks=[checkpoint],validation_split=
0.2)
from matplotlib import pyplot as plt
plt.plot(history.history['loss'],'r',label='training loss')
plt.plot(history.history['val_loss'],label='validation loss')
plt.xlabel('# epochs')
plt.ylabel('loss')
plt.legend() plt.show()
from matplotlib import pyplot as plt

Dept., of CSE, VKIT Page 17


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

plt.plot(history.history['loss'],'r',label='training loss')
plt.plot(history.history['val_loss'],label='validation loss')
plt.xlabel('# epochs')
plt.ylabel('loss')
plt.legend() plt.show()
print(model.evaluate(test_data,target_data))

5.5 Real time testing


import tensorflow.keras
from PIL import Image, ImageOps
import numpy as np
# Disable scientific notation for clarity
np.set_printoptions(suppress=True)
# Load the model
model = tensorflow.keras.models.load_model(r'C:\Users\DELL\Desktop\keras_model.h5')#
Create the array of the right shape to feed into the keras model
# The 'length' or number of images you can put into the array is
# determined by the first position in the shape tuple, in this case 1.
data = np.ndarray(shape=(1, 224, 224, 3), dtype=np.float32)
# Replace this with the path to your image
image = Image.open(r'C:\Users\DELL\Desktop\pne.jpeg')
#resize the image to a 224x224 with the same strategy as in TM2:
#resizing the image to be at least 224x224 and then cropping from the center
size = (224, 224)
image = ImageOps.fit(image, size, Image.ANTIALIAS)
#turn the image into a numpy array
image_array = np.asarray(image)#
display the resized image
image.show()
# Normalize the image
normalized_image_array = (image_array.astype(np.float32) / 127.0) - 1#
Load the image into the array
data[0] = normalized_image_array

Dept., of CSE, VKIT Page 18


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

# run the inference


prediction = model.predict(data)
print(prediction)

Dept., of CSE, VKIT Page 19


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

CHAPTER 6

TESTING
This chapter gives the outline of the testing methods that are carried out to get a bug free
system. Quality can be achieved by testing the product using different technique at different
phases of the project development. The purpose of testing is to discover the error. There are
various type of tests. Each test type addresses a specific test requirement.

6.1 Testing
Unit testing involves the design of test cases that validate that the internal program logic
is functioning properly, and that program inputs produce valid outputs. All decision branches
and internal code flow should be validated. It is the testing of individual software units of the
application .it is done after the completion of an individual unit before integration. This is a
structural testing, that relies on knowledge of its construction and is invasive. Unit tests perform
basic tests at component level and test a specific business process, application, and/or system
configuration. Unit tests ensure that each unique path of a business process performs accurately
to the documented specifications and contains clearly defined inputs and expected results.

Table 6.1: Test Cases

Sl. Testcase Expected Actual Remarks


No. Results Results
1 Loading the images. Successfully loaded. Successfully Pass
loaded.

2 List the classification of Displays the Displayed Pass


images. categories. successfully.

3 Covert the images to Gray Successful. Successful . Pass


Scale and resize the
images.

4 Create and save data and Successfully saved. Successfully saved. Pass
target data files.

Dept., of CSE, VKIT Page 20


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

5 Load the required Successful. Successful. Pass


libraries.

6 Create the model. Created Created Pass


successfully. successfully.

7 Train and validate the Displays the training Displayed Pass


model. successfully.
and validation
results..
8 Evaluate the model. Displays the Successful. Pass
accuracy.

9 Test the model using real Displays the results. Successfully Pass
time images. displayed.

Dept., of CSE, VKIT Page 21


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

CHAPTER 7

RESULT AND SNAPSHOTS


This chapter shows the snaphosts and results of our project.

7.1 Training
Here we will see the training part of the model,where the images are collected from various git
hub repositories is used in order to train a model to predict the person is in normal condition or
not means covid -19 or non covid-19. We need to train deep learning model which can take
advantage of robust dataset obtained.

Fig 7.1: Training Output


Here we have set for 10 epochs, epochs is a term used in machine learning and indicates the
number of passes of the entire training dataset the machine learning algorithm has completed if
batch size is the whole training dataset then the number of epochs is the number of iterations.
Train on 1057 samples validates on 265 samples. Here we can get the training accuracy and
training loss and validation accuracy and validation loss.

Dept., of CSE, VKIT Page 22


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

Fig 7.1.1: Accuracy Graph

Fig 7.1.2: Loss Graph


When we mention validation_split as fit parameter while fitting deep learning model, it splits
data into two parts for every epoch i.e. training data and validation data and since we are suings
huffle as well it will shuffle dataset before spitting for that epoch. It trains the model on
training data and validate the model on validation data by checking its loss and accuracy.
 val_loss starts increasing, val_acc starts decreasing. This means model is cramming
values not learning.
 val_loss starts increasing, val_acc also increases.This could be case of overfitting or
diverse probability values in cases where softmax is being used in output layer.
 val_loss starts decreasing, val_acc starts increasing. This is also fine as that means
model built is learning and working fine.

7.2 Testing
Here we will see the testing part of the model, where the images are collected from various git
hub repositories is used in order to test a model to predict the person is in normal condition or

Dept., of CSE, VKIT Page 23


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

not means covid -19 or non covid-19. We need to test x rays images. Here we are evaluate
model on test data.

Fig 7.2: Model Evaluation

Model Evaluation is an integral part of the model development process. It helps to find the best
model that represents our data and how well the chosen model will work in the future. And The
three main metrics used to evaluate a classification model are accuracy, precision, and recall.
Accuracy is defined as the percentage of correct predictions for the test data. It can be
calculated easily by dividing the number of correct predictions by the number of total
predictions. Here we got Accuracy of 0.97 .and get the result in 5s 32ms/step.
7.2.1 Import Model

Fig 7.2.1: Import Model


It is a HDF5/H5 file, which is a file format to store structured data, its not a model by itself.
Keras saves models in this format as it can easily store the weights and model configuration
in a single file.

Dept., of CSE, VKIT Page 24


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

7.2.2 Data

Fig 7.2.2: Data

7.2.3 Matrix Formation

Fig 7.2.3 Matrix Formation

Dept., of CSE, VKIT Page 25


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

7.2.4 Normalized Matrix and Output

Fig 7.2.4: Normalized Matrix and Output

7.3 Result
Real- time images are fed to the system and now the trained system takes decisions that based
on the matrix formation and CNN model. Import the model, import real time image ,then image
is get resized and normalized matrix formation takes place, then predict the output.

Fig 7.3: Input Image

Dept., of CSE, VKIT Page 26


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

Fig 7.3.1: Result


The above figure shows the result of the real time image which is applied. Here we got result
for normal condition. If left side value is high it considered as normal case if right side value is
high it considered as covid-19 positive condition case.

Dept., of CSE, VKIT Page 27


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

CONCLUSION AND FUTURE SCOPE


COVID-19 is affecting the health of the global population at an alarming rate. Testing of large
numbers of individuals is crucial to curb the spread of disease. Real-time PCR is a gold standard
pathological test for the diagnosis of this disease. But the increasing number of negative false
reporting has led to the use of Chest X-rays as an alternative for diagnosis of COVID-19. Deep
learning based recommender systems can be of great help in this scenario when the volume
of patients is very high and required radiological expertise is low. We have presented results
on detecting COVID-19 positive cases from chest X-Rays using a deep-learning model. The
results look promising, though the size of the publicly available dataset is small.The results
suggest that CNN based architectures have the potential for the correct diagnosis of COVID-
19 disease.
The future scope of this project are Fine tuning of these models may further improve the
accuracy. We may further validate our approach using larger COVID-19 X-ray image datasets
and clinical trials. Other methods can be discovered to get more precise results.

Dept., of CSE, VKIT Page 28


Deep Learning Based Diagnosis Recommendation for COVID-19 using Chest X-Ray Images 2020-21

REFERENCES
[1] P. Chatterjee et al., “The 2019 novel coronavirus disease (Covid-19) pandemic: A review
of the current evidence,” Indian Journal of Medical Research, Supplement, vol. 151, no. 2–3.
Indian Council of Medical Research, pp. 147–159, 2020, doi: 10.4103/ijmr.IJMR_519_20.
[2] G. Pascarella et al., “COVID-19 diagnosis and management: a comprehensive review,”
Journal of Internal Medicine, 2020, doi: 10.1111/joim.13091.
[3] C. P. West, V. M. Montori, and P. Sampathkumar, “COVID-19 Testing: The Threat of
False- Negative Results,” Mayo Clinic Proceedings. Elsevier Ltd, 2020, doi:
10.1016/j.mayocp.2020.04.004.
[4] D. Wang et al., “Clinical Characteristics of 138 Hospitalized Patients with 2019 Novel
Coronavirus-Infected Pneumonia in Wuhan, China,” JAMA - Journal of the American Medical
Association, vol. 323, no. 11, pp. 1061–1069, Mar. 2020, doi: 10.1001/jama.2020.1585.
[5] C. Huang et al., “Clinical features of patients infected with 2019 novel coronavirus in
Wuhan, China,” The Lancet, vol. 395, no. 10223, pp. 497–506, Feb. 2020, doi: 10.1016/S0140-
6736(20)30183-5.
[6] M. Anthimopoulos, S. Christodoulidis, L. Ebner, A. Christe, and S. Mougiakakou, “Lung
Pattern Classification for Interstitial Lung Diseases Using a Deep Convolutional Neural
Network,” IEEE Transactions on Medical Imaging, vol. 35, no. 5, pp. 1207–1216, May 2016,
doi: 10.1109/TMI.2016.2535865.
[7] P. Rajpurkar et al., “CheXNet: Radiologist-Level Pneumonia Detection on Chest X-Rays
with Deep Learning,” Nov. 2017, [Online]. Available: http://arxiv.org/abs/1711.05225.
[8] E. Luz, P. L. Silva, R. Silva, L. Silva, G. Moreira, and D. Menotti, “Towards an Effective
and Efficient Deep Learning Model for COVID-19 Patterns Detection in X-ray Images,” Apr.
2020, [Online]. Available: http://arxiv.org/abs/2004.05717.
[9] F. Shan et al., “Lung Infection Quantification of COVID-19 in CT Images with Deep
Learning Author list.”
[10] E. El-Din Hemdan, M. A. Shouman, and M. E. Karar, “COVIDXNet: A Framework of
Deep Learning Classifiers to Diagnose COVID-19 in X-Ray Images,” arXiv preprint arXiv:
2003.11055, 2020.

Dept., of CSE, VKIT Page 29

You might also like