You are on page 1of 6

2021 International Conference on Nascent Technologies in Engineering (ICNTE 2021)

Pneumonia Detection using Deep Learning


Swapnil Singh
Computer Engineering
Mukesh Patel School of Technology, Management and Engineering, NMIMS University
Mumbai, India
Swapnil.Singh49@nmims.edu.in

Abstract— It is observed that pneumonia is the largest cause of Pneumonia can be cured easily if there is efficient and early
death in toddlers. Early detection would facilitate in early treatment, detection. There are more than 1,27,000 cases in 2018 alone in
2021 4th Biennial International Conference on Nascent Technologies in Engineering (ICNTE) | 978-1-7281-9061-7/21/$31.00 ©2021 IEEE | DOI: 10.1109/ICNTE51185.2021.9487731

hence, saving many lives. This paper intend to develop a method for India [23], considering the large numbers there is a need for a
automating the detection of pneumonia using chest X-rays and faster and efficient way to detect pneumonia. Pneumonia has
comparing convolutional neural network and multilevel perceptron. also been one of the early symptoms of numerous pandemics,
Custom Convolutional neural network and multi-layer perceptron thus an efficient and faster detection would help in defeating the
were implemented on a chest X-ray dataset by Kaggle. A GUI was pandemic.
created that accepts the chest X-ray and predicts the presence of
pneumonia and gives the congestion percentage. The model The advent of technology in the medical field has helped in
accuracy was 92.63% and 77.56% for convolutional neural network fighting many diseases. Machine learning and deep learning
and multilayer perceptron respectively. The GUI developed gives have helped to detect diseases at early stages, and also cater to
favourable outcomes. Convolutional neural network showed better a larger group of patients. Deep learning models could be
results as compared to multi-layer perceptron. Thus, the custom collaborated to provide a good accuracy for the automated
convolutional neural network was used for the GUI. detection process. The dataset should contain all features and
Keywords— Deep Learning, Convolutional Neural Network, enough images to provide enough data for training and
Pneumonia Detection, Medical Imaging, Chest X-Ray, Automatic evaluating the model.
Detection, Multi-Layer Perceptron
II. RELATED WORK
I. INTRODUCTION In recent years there have been multiple works on the
Pneumonia is an acute respiratory lung infection. There are detection of pneumonia and other respiratory diseases using
small sacs called alveoli in the lungs, which fill up with air deep learning. The related work describes the use of
when one breathes. When an individual is affected with convolutional neural networks, transfer learning, and stochastic
pneumonia, these sacs get filled up with pus and fluid, making gradient descent for the detection of pneumonia. Rajpurkar, et
breathing painful and limiting the oxygen intake. al. [1] (2017) used a 121 layered convolutional neural network
and chest X-ray 14 dataset to develop an algorithm that can
Patients with viral and bacterial pneumonia have similar detect pneumonia from chest X rays at a level exceeding
symptoms, though viral pneumonia has more symptoms than practicing radiologist. The patient history and lateral
bacterial pneumonia. Cough and/or difficult breathing, with or radiographs could be taken into consideration to improve their
without fever, are the symptoms shown by children under 5 model.
years of age. Most prominent symptoms of pneumonia are fast
breathing, lower wall indrawing while inhalation. Generally, Rajaraman, et al. [3] (2018) used the CXRs of children from
wheezing accompanies these symptoms. Severely ill infants are 1 to 5 years of age, to work on a novel visualization strategy to
unable to eat and drink. They may also experience localize the region of interest that is considered relevant for the
unconsciousness, hypothermia, and convulsions. model predictions across all the input that belong to an expected
class using a convolutional neural network. Zech, et al. [5]
Pneumonia is the single largest cause of death in children (2018) aimed at finding the performance of convolutional
worldwide. According to WHO pneumonia killed 8,08,694 neural networks generalized over three different hospital
children under the age of 5 in 2017, accounting for 15% of the systems for a simulated pneumonia screening task. They
deaths of children under 5 years of age. Pneumonia is a common utilized datasets from NIH, Indiana University Network of
disease in south Asia and sub-Saharan Africa [22]. It can be patient care, and Mount Sinai Hospital in their study.
cured and prevented, by low-cost, low-tech medication and
care. Pneumonia is caused by bacteria, viruses, and fungi. The Asnaoui, et al. [7] (2020) displayed a comparison of
transmission of the disease is in multiple ways. It can be air- recently developed deep convolutional neural networks for
borne by the droplets released during sneezing and coughing, it binary classification of pneumonia images. They were able to
also spreads through blood, especially after birth of infants. achieve an accuracy of 96% on chest X-ray and CT dataset.
Children have these viruses and bacteria in their trachea which Antin, et al. [8] (2017) aimed to train a model using the dataset
when inhaled could lead to pneumonia. Parental smoking, to help physicians in making diagnoses of pneumonia in chest
inhouse pollution, and living in a crowded house are the leading X-ray using a 121 layered convolutional neural network on NIH
environmental reasons for causing pneumonia. chest X-ray dataset. Their model could be improved by

978-1-7281-9061-7/21/$31.00 ©2021 IEEE


Authorized licensed use limited to: NATIONAL INSTITUTE OF TECHNOLOGY CALICUT. Downloaded on August 26,2023 at 16:49:26 UTC from IEEE Xplore. Restrictions apply.
2021 International Conference on Nascent Technologies in Engineering (ICNTE 2021)

considering various combinations of features, improving the the amount and diversity of the dataset is known as data
logistic regression baseline, and including more error analysis. augmentation. The most used operations are:
Team [10] (2018) aimed for pneumonia classification and ● Changing brightness levels
localization in chest radiographs using stochastic gradient
descent on a dataset of 3000 chest radiographs part of the 2018 ● Zooming
RSNA Pneumonia challenge. The model can be applied to other ● Flipping
medical imaging fields. Xianghong Gu, et al. [11] (2018)
proposed a novel CAD system to identify bacterial and viral ● Rotation
pneumonia in chest X-rays using deep conventional neural ● Cropping
network working on chest X-ray and CT dataset. Feature
extraction and tuning of the deep conventional neural network ● Shearing
could lead to better performance. Due to insufficient data for validation, data augmentation
Rahman, et al. [14] (2020) aimed to construct a system that was used. The techniques used here are:
could detect bacterial and viral pneumonia using X-ray images. ● Rotation by 30 degrees
They worked on 5247 X-ray images using convolutional neural
networks giving an accuracy of 95%. Stephen, et al. [15] (2019) ● 20% zooming
used a collection of 5856 chest X-ray images to train a ● Horizontal shift by 10% of the width
convolutional neural network made from scratch to classify and
detect the presence of pneumonia. The model could be further ● Vertical shift by 10% of the height
trained to differentiate between pneumonia and lung cancer.
V. ALGORITHM
Setiawan, et al. [16] (2020) discussed the detection of
pneumonia through x-ray images using a convolutional neural B. Convolutional Neural Network
network. They worked on the chest X-ray dataset by Kaggle A convolutional neural network (CNN/ConvNet) is a deep
providing an accuracy of 96.30%. X. Li, et al. [17] (2020) learning algorithm that takes in images as input and assigns
presented an improved convolutional neural network for importance to various aspects of the image. CNN requires very
pneumonia detection. Working on the Chest X-ray dataset by little pre-processing. CNN image classifier takes an input,
Kaggle they were able to get an accuracy of 91.41%. processes it, and classifies it under certain categories.
Raheel Siddiqi [18] (2019) presented a novel, 18 layered The architecture of CNN is analogous to the neurons of the
deep sequential convolutional neural network-based model that human brain.
is proven to outperform the state-of-the-art system for this task.
The input of the image is h x b x d, where h is the height of
He worked on a dataset of 5856 chest x-ray images giving an
the image, b is the breadth of the image and d is the dimensions
accuracy of 94.39%. Transferred training and fine-tuning
of the image. The value of d is 1 for grayscale and 3 for RGB
classification could lead to better performance of the model. H.
combination.
Sharma, et al. [19] (2020) proposed different deep
convolutional neural network architectures to extract features The convolutional neural network used for this paper is a
from images of chest x-ray and classify the images to detect the custom made ConvNet. A custom convolutional neural network
presence of pneumonia. Working on chest X-ray dataset by was used to develop a new model and see the performance of
Kaggle they got their accuracy in the range of 74.98% to the network.
90.68%. Use of different optimizers and other data
augmentation techniques could improve the model. The first convolutional layer is the input layer. The input
layer consisted of 32 neurons, stride of 1, relu was used as the
III. DATASET activation function, and the input is taken of the shape 150 x
150 x 1; followed by a max-pooling layer with 2 x 2 filter and
The dataset used for the paper is Chest X-ray by Kaggle.
2 strides.
[21]
The second convolutional layer had 64 neurons, 1 stride,
A. Chest X-Ray Images (Pneumonia) and relu is used as the activation function. It then has a max-
The dataset consists of 5,863 X-ray images in the jpg format pooling layer with a 2 x 2 filter and 2 strides. The third layer is
divided as normal and pneumonia. The dataset consisted of the same as the second convolutional layer. The fourth
anterior-posterior chest X-rays of pediatric patients in the age convolutional layer contains 128 neurons, 1 stride, and relu as
group of 1 to 5. All these patients were from Children’s Medical the activation function and then a max-pooling layer with 2 x 2
Center and Guangzhou Women. The chest x-rays were initially filter and 2 strides. The fifth convolutional layer is of 256
screened for quality control. This dataset was retrieved from neurons, 1 stride, and relu is the activation layer. Then, there is
Kaggle.[21] The data set consisted of 3 folders: train, test, and a flatten layer that converts the 2D array to 1D array. The output
val. Each containing subfolder normal and pneumonia. of the flatten layer was given as an input to a dense layer with
128 neurons and having activation function of relu. The last
IV. DATA AUGMENTATION layer contains a dense layer with 1 neuron and the activation
We can improve the performance of the model by function is the sigmoid function.
augmenting the dataset we are using. The process of increasing

Authorized licensed use limited to: NATIONAL INSTITUTE OF TECHNOLOGY CALICUT. Downloaded on August 26,2023 at 16:49:26 UTC from IEEE Xplore. Restrictions apply.
2021 International Conference on Nascent Technologies in Engineering (ICNTE 2021)

The model is compiled using adam optimizer, the loss C. Multi-Level Perceptron
function used is binary cross-entropy and the matrix is Artificial neural networks are usually referred to as neural
accuracy. networks or multi-level perceptron. A perceptron is a single
Relu stands for Rectified Linear Unit for non-linear neuron. A neural network with one or more than one hidden
operations. It proposes to introduce non-linearity to CNN. layer is known as a multi-layer perceptron. In order to train a
neural network, we define a loss function. While training the
Stride is the number of pixels shifted over the input matrix. model we tend to optimize this loss function. A neural network
When stride is 1 then we move the filter by 1 pixel at a time. works backward from the output node iteratively updating the
coefficients of the nodes. This process is called backdrop or
backpropagation. A neural network requires an activation
function. The activation function used was sigmoid represented
by (1) and ReLU.

Fig. 1. Convolutional Neural Network


(1)
Butt, Charmaine, et al. [2] (2020) proposed a comparison
between multiple convolutional neural network models to
classify CT scan samples with COVID-19, influenza, viral The neural network built here had 5 layers. The input layer
pneumonia, or normal. They used 618 transverse section CT had 256 neurons, followed by three hidden layers with 128
scan samples giving an accuracy of 86.70%. Li, Lin, et al. [4] neurons, 64 neurons, and 32 neurons respectively. The output
(2020) developed a fully automatic framework using layer used sigmoid as activation function and had 1 neuron. Fig.
convolutional neural network to detect COVID-19 using CT 2 shows the shape of a 4-layer neural network.
scans and evaluated its performance. The worked on 4356 chest
CT scans exams from 3322 patients. They were able to achieve
an accuracy of 90%. Saraiva et al. [6] (2019) portrayed a
comparative classification of pneumonia using convolutional
neural network. The data set consisted of labeled optical
coherence Tomography and chest X-ray images and achieved
an accuracy of 95.30%. Maghdid et al. [9] (2020) deployed a
simple and effective model using deep learning and transferred
learning algorithms for the detection of COVID-19 using X-
Rays and CT Scan images. They used AlexNet network on a
dataset including images collected from 5 sources, the images
included 170 X-ray images and 361 CT images, and achieved
an accuracy of 94.10%. Apostolopoulos, Loannis, and Tzani
[12] (2020) portrayed the performance of recent state-of-art
convolutional neural network architectures for medical image
classification. They used 1427 X-ray images over transfer
learning and convolutional neural network. Chowdhary et al.
[13] (2020) worked on automating the detection process of
COVID-19 pneumonia patients using their X-ray images, along Fig. 2. Multilayer Perceptron
with that they worked on maximizing the accuracy of detection
using preprocessing and deep learning techniques on the VI. STRUCTURE
images. Their dataset had 1341 normal, 190 COVID-19, and Using the above stated deep learning model as back-end
1345 viral pneumonia chest X-ray images and got an accuracy mechanism, and a simple user-friendly user interface was built
of 98.3%. Narin, Ali, Ceren Kaya, and Ziynet Pamuk [20] for the doctors or even the patient himself/herself.
(2020) deployed three different convolutional neural networks-
The input image is to be of a Chest X-ray. This input image
based models for the detection of coronavirus pneumonia
would be applied to the trained model and then the model would
infected patients using chest X-ray images. They used 50
predict using the learnings from the features of the images used
COVID-19 X-rays and 50 normal X-rays and achieved an
during training phase of the model.
accuracy of 87%.

Authorized licensed use limited to: NATIONAL INSTITUTE OF TECHNOLOGY CALICUT. Downloaded on August 26,2023 at 16:49:26 UTC from IEEE Xplore. Restrictions apply.
2021 International Conference on Nascent Technologies in Engineering (ICNTE 2021)

This model is further modified to provide the congestion neural network, we got the model accuracy as 92.63 %, whereas
percentage observed in the X-ray. This is done by considering after the execution of multi-layer perceptron, we got the model
the pixel intensities of the image. It was observed that the pixels accuracy as 77.56%.
showing congestion were found in the intensity range of 140 to
190. These pixels were found between pixel 20 and pixel 100
horizontally and between pixel 90 and pixel 130 vertically. It is TABLE I. CLASSIFICATION REPORT OF CONVOLUTIONAL NEURAL NETWORK
to be noted that all the images were resized to the size of 150
pixel x 150 pixel Precisio
Recall F1 Score Support
n
This model would not only automatically detect pneumonia Pneumonia
0.91 0.98 0.94 390
but also would help us in fast and early detection of pneumonia. (Class 0)
Fig. 3 shows the GUI developed for the interface and Fig. 4 Normal
0.96 0.84 0.89 234
(Class 1)
shows the algorithm for the interface.

TABLE II. CLASSIFICATION REPORT OF MULTI-LAYER


PERCEPTRON
Precisio
Recall F1 Score Support
n
Pneumonia
0.79 0.95 0.86 390
(Class 0)
Normal
0.86 0.57 0.69 234
(Class 1)

TABLE III. CONFUSION MATRIX OF CONVOLUTIONAL NEURAL


NETWORK

382 8
38 196

TABLE IV. CONFUSION MATRIX OF MULTI-LAYER PERCEPTRON

369 21
81 153

Table I describes the classification report whereas table III


Fig. 3. Detection GUI
describes the confusion matrix of convolutional neural network.
Table II describes the classification resort whereas table IV
describes the confusion matrix of multilayer perceptron.

Fig. 5. Visualization of the training and testing accuracy and loss of the
convolutional neural network
Fig. 4. Algorithm for the GUI

VII. RESULT
There were 1,244,225 parameters to train in convolutional
neural network whereas multi-level perceptron had 5,803,521
parameters to train. After the execution of the convolutional

Authorized licensed use limited to: NATIONAL INSTITUTE OF TECHNOLOGY CALICUT. Downloaded on August 26,2023 at 16:49:26 UTC from IEEE Xplore. Restrictions apply.
2021 International Conference on Nascent Technologies in Engineering (ICNTE 2021)

Fig. 6. Visualization of the training and testing accuracy and loss of the multi-
layer perceptron

Fig. 5 and 6 visualize the training and testing accuracies of


convolutional neural network and multilayer perceptron
respectively. The training loss is seen to be decreasing whereas
the training accuracy is seen to be increasing. There is variation
seen in the testing loss and accuracy. The model was trained for
50 epochs, the training was stopped after 50 epochs as no
significant increase in the accuracy was seen; Thus, we can see Fig. 8. Incorrect Predition for Convolutional Neural Network
that there is some continuity at the end of the epochs. The
validation accuracy and loss curves are not smooth due to the
insufficient amount of validation data, though data
augmentation was used to increase the dataset.

Fig. 9. Correct Predition for Multi-Layer Perceptron

Fig. 7. Correct Predition for Convolutional Neural Network

Authorized licensed use limited to: NATIONAL INSTITUTE OF TECHNOLOGY CALICUT. Downloaded on August 26,2023 at 16:49:26 UTC from IEEE Xplore. Restrictions apply.
2021 International Conference on Nascent Technologies in Engineering (ICNTE 2021)

REFERENCES
[1] Rajpurkar, et al. Chexnet: Radiologist-level pneumonia detection on chest
x-rays with deep learning. arXiv preprint. 2017. arXiv:1711.05225.
[2] Butt, et al. Deep learning system to screen coronavirus disease 2019
pneumonia. Applied Intelligence. 2020. 1.
[3] Rajaraman, et al. Visualization and interpretation of convolutional neural
network predictions in detecting pneumonia in pediatric chest
radiographs. Applied Sciences 8.10. 2018: 1715.
[4] Li, et al. Artificial intelligence distinguishes COVID-19 from community
acquired pneumonia on chest CT. Radiology. 2020: 200905.
[5] Zech, et al. Variable generalization performance of a deep learning model
to detect pneumonia in chest radiographs: A cross-sectional study. PLoS
medicine. 2018. vol. 15,11 e1002683. doi:10.1371/journal.pmed.1002683
[6] Saraiva, et al. Classification of Images of Childhood Pneumonia using
Convolutional Neural Networks. In Proceedings of the 12th International
Joint Conference on Biomedical Engineering Systems and Technologies
- Volume 2: BIOIMAGING. 2019. ISBN 978-989-758-353-7, pages 112-
119. DOI: 10.5220/0007404301120119
[7] Asnaoui, et al. "Automated methods for detection and classification
pneumonia based on x-ray images using deep learning." arXiv preprint.
2020. arXiv:2003.14363.
[8] Antin, et al. Detecting pneumonia in chest X-Rays with supervised
learning. Semanticscholar. org. 2017.
[9] Maghdid, et al. Diagnosing COVID-19 pneumonia from X-ray and CT
images using deep learning and transfer learning algorithms. arXiv
preprint. 2020. arXiv:2004.00038.
[10] Team, The DeepRadiology. Pneumonia detection in chest radiographs.
arXiv preprint. 2018 arXiv:1811.08939.
[11] Xianghong Gu, et al. Classification of Bacterial and Viral Childhood
Fig. 10. Inorrect Predition for Multi-Layer Perceptron Pneumonia Using Deep Learning in Chest Radiography. In Proceedings
of the 3rd International Conference on Multimedia and Image Processing
(ICMIP 2018). Association for Computing Machinery, New York, NY,
Fig. 7 and 9 depict correct prediction examples of USA. 2018. 88–93. DOI:https://doi.org/10.1145/3195588.3195597
convolutional neural network and multilayer perceptron [12] Apostolopoulos, Ioannis D., and Tzani A. Mpesiana. Covid-19: automatic
detection from x-ray images utilizing transfer learning with convolutional
respectively, whereas Fig. 8 and 10 depict incorrect prediction neural networks. Physical and Engineering Sciences in Medicine. 2020:
1.
examples of convolutional neural network and multilayer [13] Chowdhury, Muhammad EH, et al. Can AI help in screening viral and
perceptron respectively. The images in Fig 8 and 10 have very COVID-19 pneumonia?. arXiv preprint. 2020. arXiv:2003.13145.
less amount of chest congestion (seen as the white colour in the [14] Rahman, et al. Transfer Learning with Deep Convolutional Neural
Network (CNN) for Pneumonia Detection using Chest X-ray. Applied
lung region), thus it looks similar to a normal chest x-ray. While Sciences. 2020. 10.9: 3233.
maxpooling the maximum value is chosen, since brighter pixels [15] Stephen, et al. An efficient deep learning approach to pneumonia
classification in healthcare. Journal of healthcare engineering 2019. 2019.
would have a higher value than the darker pixels, so the value [16] Setiawan, et al. Layers Modification of Convolutional Neural Network for
of brighter pixels is taken, thus it seems that there is chest Pneumonia Detection. Journal of Physics: Conference Series. Vol. 1477.
2020.
congestion. [17] Based on Improved Convolutional Neural Network, IEEE 4th Information
Technology, Networking, Electronic and Automation Control Conference
VIII. RESULT (ITNEC), Chongqing, China, 2020, pp. 488-493, doi:
10.1109/ITNEC48623.2020.9084734.
This paper depicts a method for the detection of pneumonia [18] Raheel Siddiqi. Automated Pneumonia Diagnosis using a Customized
Sequential Convolutional Neural Network. In Proceedings of the 2019 3rd
using convolutional neural networks (CNN). The results of the International Conference on Deep Learning Technologies . Association
for Computing Machinery, New York, NY, USA. 2019. 64–70.
model show an accuracy of 92.63% for convolutional neural DOI:https://doi.org/10.1145/3342999.3343001
network and an accuracy of 77.56% for multilayer perceptron, [19] H. Sharma, et al. Feature Extraction and Classification of Chest X-Ray
Images Using CNN to Detect Pneumonia. 10th International Conference
showing that the convolutional neural network is efficient for on Cloud Computing, Data Science & Engineering (Confluence). Noida,
detecting pneumonia. The dataset used for this paper is chest X- India. 2020. pp. 227-231, doi: 10.1109/Confluence47617.2020.9057809.
[20] Narin, Ali, Ceren Kaya, and Ziynet Pamuk. Automatic detection of
ray dataset from Kaggle, this dataset contains paediatric coronavirus disease (covid-19) using x-ray images and deep
radiography, hence the model could be implemented for convolutional neural networks. arXiv preprint. 2020. arXiv:2003.10849 .
[21] https://www.kaggle.com/paultimothymooney/chest-xray-pneumonia, as
medical applications. Seeing the rise of epidemics in recent on 17 June 2020
years, we need to be prepared for such diseases. The model [22] WHO(2020) retrieved from https://www.who.int/health-
topics/pneumonia#tab=tab_1
could be trained using chest X-rays and CT scans of COVID-
[23] Fighting for Breath in India – A call to action to stop children dying from
19 patients, thus providing an efficient and fast mechanism for pneumonia(2019). Retrieved from https://stoppneumonia.org/wp-
detecting COVID-19. A dataset with more sample images content/uploads/2019/11/India-12.11.2019-Web.pdf
would help in attaining better results for the model.

Authorized licensed use limited to: NATIONAL INSTITUTE OF TECHNOLOGY CALICUT. Downloaded on August 26,2023 at 16:49:26 UTC from IEEE Xplore. Restrictions apply.

You might also like