PROJECT REPORT
‘
COVID-19 DETECTION USING CHEST X-RAY
SUBMITTED BY
SHWETA GADHAVE - INSA009
FRAVASH MOHATA - INSA031.
KARTIK WANKHEDE - IN5SA053
PRATHAMESH PAWAR - INSA039.
CLASS AND DIV: D13-INST
SUBMITTED TO,
MRS.AMUDHA SENTHILKUMAR,
Vivekanand education society’s institute of Technology
Chembur, Mumbai
MAY 2021CERTIFICATE
This is to certify that the report entitled
COVID - 19 DETECTION USING CHEST X-RAY
THIS IS BEING SUBMITTED BY :
SHWETA GADHAVE - INSA009
FRAVASH MOHATA — INSA031
KARTIK WANKHEDE - INSA053
PRATHAMESH PAWAR - INSA039
From D13-INST, V.E.S INSTITUTE OF TECHNOLOGY
In partial fulfillment for the MINI PROJECT to the University of Mumbai is a record of bonafide
work carried out by them under my guidance and supervision
Prof.Amudha Senthilkumar
Assistant Professor
V.E.S INSTITUTE OF TECHNOLOGY
Mumbai-74ACKNOWLEDGMENT
We would like to express our deepest appreciation to all those who provide us the possibility to
complete this report. A special gratitude we give to our project mentor, “Mrs. Amudha
Senthilkumar”,whose contribution in stimulating suggestion and encouragement, helped us to
coordinate our Project especially in writing this report,
We would like to thank our principal Dr.(Mrs).J.M.Nair & the Head of the department
Prof-Dr.(Mr)P.P.Vaidya for allowing us to do this project and also the staff and Management of
the Vivekanand Education Society's Institute Of Technology for providing their cooperation
without which it would not have been possible to complete the work in time and successfllly.
‘We would also like to thank our friend & family for their technical as well as manual support.Table of contents
1.Abstract
2.chapter 1:Introduction
3Chapter 2:Machine Learning
5.Chapter 3:Convolution neural networks
5.Chapter 4: Confusion matrix
6.Chapter 5: Data processing library
7.Chapter 6:Code
8.Bibliography
9.ConclusionAbstract
The exponential increase in COVID-19 patients is overwhelming healthcare
systems across the world. With limited testing kits, it is impossible for every
patient with respiratory illness to be tested using conventional techniques
(RT-PCR). The tests also have long turn-around time, and limited
sensitivity. Detecting possible COVID-19 infections on Chest X-Ray may
help quarantine high risk patients while test results are awaited. X-Ray
machines are already available in most healthcare systems, and with most
modern X-Ray systems already digitized, there is no transportation time
involved for the samples either. In this work we propose the use of chest
X-Ray to prioritize the selection of patients for further RT-PCR testing. This
may be useful in an inpatient setting where the present systems are
struggling to decide whether to keep the patient in the ward along with
other patients or isolate them in COVID-19 areas. It would also help in
identifying patients with high likelihood of COVID with a false negative
RT-PCR who would need repeat testing. Further, we propose the use of
modern Al techniques to detect the COVID-19 patients using X-Ray images
in an automated manner, particularly in settings where radiologists are not
available, and help make the proposed testing technology scalable. We
present CovidAID: COVID-19 Al Detector, a novel deep neural network
based model to triage patients for appropriate testing.Introduction
Application of machine learning methods for automatic diagnosis in the medical
field have recently gained popularity by becoming an adjunct tool for clinicians
Deep learning, which is a popular research area of artificial intelligence (A),
enables the creation of end-to-end models to achieve promised results using
input data, without the need for manual feature extraction . Deep learning
techniques have been successfully applied in many problems such as arrhythmia
detection , skin cancer classification, breast cancer detection, brain disease
classification, pneumonia detection from chest X-ray images, fundus image
segmentation, and lung segmentation . The COVID-19 epidemic's rapid rise has
necessitated the need for expertise in this field. This has increased interest in
developing the automated detection systems based on Al techniques. It is a
challenging task to provide expert clinicians to every hospital due to the limited
number of radiologists. Therefore, simple, accurate, and fast Al models may be
helpful to overcome this problem and provide timely assistance to patients.
Convolution neural network is CNN it is an advanced version of neural
network. It is used for feature extraction and classification.Here we used
CNN instead of ANN because ann only the highlights the border and the pixel
rate is very low whereas in cnn high revaluation technology is used where
the pixel rate is high and the picture is In more higher quality.In CNN there
are three layers that is convolution layer, padding layer, max poll layer
keras,Matplotlib,os, pandas,ImageDataGenerator, libraries used for deep
learning framework .So the features of convolution neural networks are
good and more accuracy is there than ann.. In convolution neural networks,
dense layers are used in binary form. In convolution layer it is in 3*3 matrix
which are in parallel.Cov layer convert matrix in form of series for higher
accuracy and Accurate accuracy is noted.What is machine learning?
Machine learning(ML) is the study of computer algorithms that
improve automatically through experience. It is seen as a subset of
artificial intelligence.machine learning algorithms build a model based
‘on sample data,known as “training data”,in order to make prediction
of decision without being explicitly programmed to do so.
What is deep learning?
Deep learning is the structure of human brain & subfield of
machine learning where artificial neural network,algorithms are
inspired by the human brain. It encompasses machine learning ,
where machine can learn by experience and acquire skills without
human involvement.Convolution neural network:
CNN=Feature extractiont+extraction
Fully
Connected
Comoltion
}.,
._ Output
Input
Pe
Feature Extraction Classification
Convolution Neural Network Architecture
-A Convolutional neural network (CNN) is a neural network that
has one or more convolutional layers and are used mainly for
image processing, classification, segmentation and also for other
auto correlated data. A convolution is essentially sliding a filter
over the input.
- In Deep learning, a convolutional neural network is a class of
Deep neural networks, most commonly applied to analyze visual
imagery. It uses a special technique called ConvolutionArchitecture Of CNN:
Convolutional Layer:
“This layer is the first layer that is used to extract the various features from
the input images. In this layer, the mathematical operation of convolution is
performed between the input image and a filter of a particular size MxM. By
sliding the filter over the input image, the dot product is taken between the
filter and the parts of the input image with respect to the size of the filter
(MxM).
+The output is termed as the Feature map which gives us information about
the image such as the corners and edges. Later, this feature map is fed to
other layers to learn several other features of the input image.
Max-Pooling Layer:
-A Convolutional Layer is followed by a Pooling Layer. The primary aim of
this layer is to decrease the size of the convolved feature map to reduce
the computational costs. This is performed by decreasing the connections
between layers and independently operating on each feature map.
Depending upon the method used, there are several types of Pooling
operations.
-In Max Pooling, the largest element is taken from the feature map.
Average Pooling calculates the average of the elements in a predefined
size Image section. The total sum of the elements in the predefined section
is computed in Sum Pooling .The Pooling Layer usually serves as a bridge
between the Convolutional Layer and the FC LayerPadding:
works by extending the area of which a convolution neural network
processes an image Adding padding to an image processed by a CNN
allows for more accurate analysis of images.What is the Confusion Matrix?
*Confusion matrices are used to visualize important predictive analytics like
recalll, specificity, accuracy, and precision.
+In confusion matrix, N x N Matrix used for evaluating the performance of a
classification model, where N is the number of target classes. The matrix
compares the actual target values with those predicted by the machine
learning model
*Confusion matrix are useful because they give direct comparisons of
values like True Positives, False Positives, True Negatives and False
Negatives.Data pre-processing library
*Keras - is a powerful and easy-to-use free open source Python library for
developing and evaluating deep learning models. It wraps the efficient
numerical computation libraries and allows you to define and train neural
network models in just a few lines of code.
+*Matplotlib - Matplotlib.pyplot is a collection of functions that make
matplotlib work like MATLAB. Each pyplot function makes some change to
a figure.it is a low level graph plotting library in python that serves as a
visualization utility.
+ImageDataGenerator - Image data augmentation is a technique that can
be used to artificially expand the size of a training dataset by creating
modified versions of images in the dataset. The Keras deep learning neural
network library provides the capability to fit models using image data
augmentation via the ImageDataGenerator class.
*Os - The os module is a part of the standard library . It provides the
function for creating and removing directory folders, fetching its content ,
changing and identifying .By using os.open() is used to open a specified
path.
+Pandas — It is an open source python package that is most widely used for
data analysis and machine learning tasks.fron keras. layers import Conv2D, MaxPo0l1ng20, GlobalAveragePo0ling2D
fron keras. layers import Activation, Dropout, Ssteiormalization, Flatten, Dense, AvgPo0120,NexPo0l20
fron keras models Smport Sequential, ode]
fron keras.applications.vggl6 import VEGI6, preprocess_input
from keras.optinizers import Adan, $60, RIDrop
import tensorflow as tf
import os
import numy as np
import pandas as pd
Amport matplotlb.pyplot as plt
‘snatplotlib inline
Using Tensortion backen.
DATASET.OIR = ~../Anput/covid-19-x-ray-10000-snages dataset”3
1
os. Listdir(DATASET_DIR)
Unommel’, ‘covid")
import glob
import matplotlib.pyplot as plt
import matplotlib.image as mping
‘smatplotlib inline
normal_images = []
for ing_path in glob.glob(OATASET_OIR + ‘ /normal/+")
normal _1mages.append(mping .1mread( 1mg_path))
fig = plt.figure()
fig. suptitle( ‘normal ')
plt.1mshow(normal_smages[@], cnap="gray’)
covid_smages = []
for ing_path in glob.glob(DATASET_DIR + '/covid/*"):
covid_images. append(mping. imread(img_path) )
fag = plt.figure()
fig. suptitle(‘covid')
plt.imshow(covid_images[@], map='gray")0 0 $00 m0 1000 1250 1500 175
covid
1000(81
model = Sequential()
model add(Conv20(32, (3, 3), input_shape=INPUT_SHAPE) )
model .add(Activation( 'relu’))
model .add(MaxPooling2D(pool_size=(2, 2)))
model .add(Conv20(32, (3, 3)))
model .add(Activation( 'relu’))
model .add(NaxPooling2D(pool_size=(2, 2)))
model. add(Conv2D(64,(3,3)))
model .add(Activation("relu”))
model . add (Conv20(250, (3,3)))
model .add(Activation("relu”))
model .add(Conv20(128, (3,3)))
model .add(Activation("relu"))
model .add(AvgP0012D(2,2))
model .add(Conv20(64, (3,3)))
model. add(Activation("relu”))
model .add(AvgP00120(2,2))
model .add(Conv2D(256, (2,2)))
model .add(Activation("relu”))
model . add (MaxPoo12D(2,2))
model.add(Flatten())
model add (Dense(32))
model add (Dropout (@.25))
model .add(Dense(1))
model -add(Actavation(~signoid”))
+ Code) ( + Markdown
model .compile(1oss=" binary_crossentropy’,model . summary ()
Model: “sequential_a”
Layer (pe) Output
‘Shape
Param @
conv2d_1 (Conv20) one,
‘activation_1 (Activation) (None,
imax poolingla_i (NexPooling? (one,
conv2d_2 (Conv20) Wore,
‘activation_2 (Activation) (none,
ax pooling2a_2 (WaxPooling? (Wore,
cones (ComD) Tene,
acthvation’s GER Tere,
Zonvdas (Conrad) Tiere,
‘detivetion® Getivetion) — Giene,
Zonvdas (Comv2d) Tere
‘activation_§ (Activation) (one,
‘average_pooling2d_i (Average (None,
148, 148, 32)
148, 148, 32)
74, 74, 32)
72,
7,
35,
34,
%,
32,
32,
38,
38,
3,
7,
7,
%,
%
Ea
B
ery
3
=
=)
Bay
ay
Tay
Tay
i)
598
Tea36
14825013, 13, 64)
33, 33, 6)
& 6, 64)
73792
‘conve (Conve) (ene,
5, 5, 256)
‘activation_7 (Activation) (None, 5,5, 256¢) 8
5, 5, 256)
wax_pooling2a_3 (NaxPooling2 (None, 2, 2,256) @
convad_6 (Convad) (one,
‘activation 6 (Activation) (None,
‘auerage_pooling2d_2 (Average (None,
‘Flatten_a (Flatten) (one,
Gensea (Dense) (one,
‘Gropout_t (Oropouty (one,
Gense_2 (Dense) (one,
2, 2, 256)
Tez)
3a)
32)
ay
3
‘activation § (Activation) (None,
Total params: 633,435,
Trainable params: 633,435
Non-trainable params: @
a
a‘train_datagen = InageDataGenerator(rescale=1./255,
shear_range=0
‘2o0n_range=0.2,
horizontal_flip=True,
validation_split=0.3)
‘train.generator = train.datagen. flow_fron_directory(
DATASET_OTR,
‘target_size-(ING_H, ING.N),
batch_size-BATCH SIZE,
class.node=' binary",
subset=" training’ )
validation generator = train_datagen.flow_from_directory(
DATASET_DIR,
‘target_eize=(ING_H, ING.N),
batch eize=BATOH SIZE,
clase_node=" binary’
shuffle= False,
subset=" validation’ )
history = model. f2t_generator(
‘train.generator,
steps_perepoch = train_generator.samples // BATCH SIZE,
validation data = validation_generator,
validation_steps = validation_generator samples // BATCH SIZE,
‘epochs = EPOCHS)
oun 69 snags selongingt2 2 clmce.
una 29 naps belonging fo 2 caste.
= Ae aaae/sten = Lone: 0.708» secure
so] = Ae 380e/etag~ ones 9.6525 - secure
4s msee/steg ~ tots 2.718 - acearay ok ecueys 0.6522
1 = De aran/step «ont: 0.644 - secur + wah ccuney: 9.6522
138 aea/sten =e
se] 34 283e/sten- sts 0.7515 - secur
= Be aun/step~ tones 9.6166» acura
235 ava/step« Loss: 8.4862» accuracy! OBIS val Joss: 2712 = wah ceurney 9.0758
ne] 34 380m/sten- oe:
S068 accuracy: 0254 - val oats 0.1996 - val sceuney: 8.6261
be a8iestep ~ Laas 04809 ~ acura 0.778 val ees 0.1708 ~ va scenes 8.6957
S945 - acuray: 0.4090 - va toss wat ecu
Se 0m/step ~ toes 0.2018 ~ accra 0.989 ~ val totes et ecireeya1
to plt.plot(history.history[ ‘accuracy’ ])
plt.plot(history-history[ "val_accuracy”])
plt.title(‘model accuracy’)
plt.ylabel(' accuracy’)
plt.xlabel( epoch’ )
plt.legend({'train’, ‘tes
plt.show()
1, loc="upper left’)
plt.plot(history.history[ loss" ])
plt.plot(history.history[ val_lo:
plt.title( ‘model loss’)
plt.ylabel( "loss" )
plt.xlabel(‘ epoch’ )
plt.legend([’train’, ‘test’], loc="upper left’)
plt.show()
ely
‘model accuracy
10 {wan
095
030
08s
080
07s
securacy
on
06s,
20) — west
as
os
00> grane-trannng-secrsey”. story mastor|sceurey III)
Drine(valsdatan.secaracy", aatory atory| val securaryIf-1))
Sitter ha
abel « valisatson grarator.clastoe
rede sode.pracst(valsdation generator)
Predicted. class_anéicesvp.argna(pred 28-1)
Libels = (eladation generator clase indies)
Tabelad = det( (4k) for kv an labeler)
presictione = [labels2fk] for K in predictea.class indices]
print (preaicted.cloee nates)
brant (labels)
rane (preatetins)
. ®
ce at ee oe cea ea er, “ok en,
from skiesen.setrics iaport confusion watrae
f= confuston-natras(preéicted class. andtces, label)
C3, Sly
series = pd. Seres(2abel)
Dredseries « p.serset (predicted class_andices)
paccronsab(omperses, predserses, romanes| Actual, colnaneas| Predicted] margine-teve)plt.natshon(cf)
plt.tstle( Confusion Matrix Plot
plt.colorbar(
plt.xlabel( Predicted")
pit ylabel( ‘Actual
pit show()
Coun arin otConclusion:
In this study, we have proposed a deep learning based model to detect and
classify COVID-19 cases from X-ray images. Our model is fully automated with an
end-to-end structure without the need for manual feature extraction. Our
developed system is able to perform binary and multi-class tasks. This system
can be used in remote places in countries affected by COVID-19 to overcome a
shortage of radiologists. Also, such models can be used to diagnose other
chest-related diseases including tuberculosis and pneumonia.A limitation of
the study is the use of a limited number of COVID-19 X-ray images. We intend to
make our model more robust and accurate by using more such images from
kaggle and github.Bibliography:
https://github.com/vijay-ss/Covid19-Xray-Detection/tree/master/im:
https: ine-learni
https: re iv
49myl
https:/www.sciencedirect.com/science/article/pii/S0378603X1500248X#s
ne-learning/
>www.wikipedia.in