Chest Diseases Prediction from X-ray Images using CNN Models: A Study

Chest Disease creates serious health issues for human beings all over the world. Identifying these diseases in earlier stages helps people to treat them early and save their life. Conventional Neural Networks play an important role in the health sector especially in predicting diseases in the earlier stages. X-rays are one of the major parameters which help to identify Chest diseases accurately. In this paper, we study the prediction of chest diseases such as Pneumonia, COVID-19, and Tuberculosis (TB) from the X-ray images. The prediction of these diseases is analyzed with the support of three CNN Models such as VGG19, Resnet50V2, and Densenet201, and results are elaborated in the terms of Accuracy and Loss. Though all three models are highly accurate and consistent, considering the factors like architectural size, training speed, etc. Resnet50V2 is the best model for all three diseases. It trained with F1 score accuracies of 0.98,0.92,0.97 for pneumonia, tuberculosis, covid respectively. Keywords—Convolutional neural networks; VGG19; ResNet50V2; DenseNet201


I. INTRODUCTION
Historically, Chest diseases are very serious health problems in the life of people. These diseases include chronic obstructive pulmonary disease, pneumonia, asthma, tuberculosis, and lung diseases. The timely infectious diseases have had civilization-altering consequences. so, diagnosis of chest diseases in the early stage is very important. To estimate the importance of diseases, different measures such as morbidity and mortality can be used. An X-ray is a quick, painless test that produces images of the structures inside your body. pneumonia, tuberculosis, or lung cancer can show up on chest X-rays. Generally, however, radiation exposure from an X-ray is low, and the benefits from these tests far outweigh the risks [1].
The study of major diseases from x-rays becomes a most challenging task. In this study, we have considered 3 diseases Pneumonia, COVID-19, and Tuberculosis (TB) these diseases can be easily identified using chest X-rays and CT scans. Chest X-rays are normally painless and non-invasive radiological tests to screen and diagnose many lung diseases also other methods such as CT and MRI can be used. Chest Xray is fast, easy and inexpensive than CT and MRI and they are mostly used in emergency diagnosis and treatment of lungs, hearts, and chest wall diseases. Coronavirus disease 2019 (COVID- 19) is an infectious disease caused by a coronavirus strain called severe acute respiratory syndrome coronavirus [2]. Results show that chest X-rays correctly diagnosed COVID-19 in 99% of people who had COVID-19. However, it incorrectly identified COVID-19 in 1% of people who did not have COVID-19 [3]. Pneumonia is a form of acute respiratory infection that is most commonly caused by viruses or bacteria [4,5]. The X-rays scans show 92 % of accuracy. Tuberculosis (TB) is caused by a bacterium called Mycobacterium tuberculosis. A total of 1.4 million people died from TB in 2019 [6,7]. X -rays help in 99% of the identification of tuberculosis.
The challenges and the increase in the number of cases for these diseases motivate us to explore the methods that help to study how to accurately identify this disease to help humans. Currently, Artificial Intelligence (AI) especially Machine Learning (ML) and Deep Learning (DL) algorithms help to effectively identify these diseases. For our study, we considered pre-trained deep Convolutional Neural Networks (CNNs) as feature extractors to extract powerful and discriminative deep features from brain magnetic resonance (MR) images and Chest X-ray images for various ML classifiers and deep learning networks to identify the infected and uninfected images. Also, to investigate the benefits of combining features from different pre-trained CNN models by comparing their Accuracies.
Our experiment results demonstrate that the ensemble of deep features can help to improve performance significantly. In this paper, we considered 3 datasets of disease X-rays namely COVID19, Pneumonia, Tuberculosis, and performed comparisons on various CNN pre-trained models VGG19, Resnet50V2, Densenet201. In summary, our contributions are listed as follows: • We designed and implemented a fully automatic disease classification, in which the pre-trained CNN VGG19, Resnet50V2, Densenet201 models extract the deep features from X-ray images.
• This is executed in three steps: (1) Training the model using CNN models (2) Comparing the pre-trained models based on their accuracies and losses (3) Selecting the top fine-tuned model to achieve state-ofthe-art performance for disease classification in X-ray images.
• We conducted extensive experiments on 3 datasets namely Pneumonia, COVID, Tuberculosis, and for each 3 pre-trained models namely VGG19, Resnet50V2, and Densenet201 to analyze the classification accuracy and precision for these models.
The Related works are described in section 2. Section 3 highlights the datasets and methodology, section 4 with model architecture section 5 shows a more detailed performance analysis. The Conclusion and future work are discussed in Section 6.

II. LITERATURE SURVEY
Many papers addressed CT scan and x-ray diagnosis of COVID, Irfan Ullah Khan et al. [8] compared the COVID-19 x-ray images by performing different deep learning techniques DenseNet121, ResNet50, VGG16, and VGG19 with accuracies of 96-99% and stated overall accuracy of 99.33% VGG16 and VGG19. Kumar [9] used ResNet50 and Support Vector Machine (SVM) classification for the diagnosis of COVID in x-ray images and got an accuracy of 95.38% for binary classes. Also, Ali [10] found the highest accuracy of 98% for ResNet50 using X-ray datasets [11]. However, most of the research is carried out for small datasets. When the size of the dataset increases it shows some in-efficiencies. Hence in our paper, we analyze the performance of the X-ray dataset in a large volume and the implications are measured.
In the research of classification of X-ray images, Rachna Jain [12] performs several pre-trained convolutional neural networks(CNN) on pneumonia x-rays to classify x-ray images into two classes i.e. pneumonia and non-pneumonia by varying different parameters and layers. She had compared 4 pre-trained models VGG16, VGG19, ResNet50, and Inception-v3 with accuracies of 87.28%, 88.46%, 77.56%, and 70.99% respectively. Similarly [13,14] examines various deep convolutional neural networks (DCNNs) for the prediction of tuberculosis and shows Densenet201 has better accuracy when compared to other algorithms. And [15] shows the analysis of various CNN algorithms in the prediction of Tuberculosis with different classification theories of tuberculosis. [16,17] proposed a deep learning-based approach using Densenet-121 with the radiology image learned by the CheXnet model to detect COVID-19 patients and performance analysis of these algorithms in the detection. [18,19] also describes the study on pneumonia with two convolutional neural network models Xception and VGG16.
Megha Chandra et al. [20] proposed a CNN-based MobileNet architecture for detecting diseases in plants. Authors in [21,22] proposed a method performing by combining clustering and classification for the effective diagnosis of tuberculosis. This model has various algorithms such as K-means, C4.5 decision tree, K-NN, Naïve Bayes, and SVM which produced an accuracy of 98.7%. They concluded that the SVM algorithm provided better accuracy in predicting tuberculosis. Lakhani P. [23] trained a deep CNN for the automated classification of pulmonary tuberculosis from chest radiographs. AlexNet and GoogLeNet, which are dual CNNs, were used for classification purposes. The dataset was preprocessed before evaluation. Their model had a high accuracy of 0.99. Their model had a specificity of 100% and a sensitivity of 97.3%. Anthimopoulos M. et al [24] The input dataset images are of size 256X256 pixels. The accuracy of the model is 0.964 on an average specificity and sensitivity of 91% showing that deep convolutional neural networks can be developed with high classification accuracy and can help in the diagnosis procedure. [25] proposed a Reliable Learning with Partial differential equation to detect various diseases from Chest X-rays.
Along with x-rays, MRI reports also play a major role in the diagnosis of brain diseases. Studying MRI reports is much more difficult than x-rays, a researcher named Ahmed Kharrat [26], proposed a hybrid approach for classifying Brain tissues in MRI based on a Genetic Algorithm(GA) and Support Vector Machine(SVM). He performed his research with fewer datasets consisting of 83 images, due to the small size of the dataset SVM classifier is employed. These two algorithms give heady results in classifying brain tumors. 94.44% accuracy is obtained while performing the following technique SGLDM+GA+SVM and 96.29% accuracy is obtained for WT+SGLDM+GA+SVM.
From the survey, X-ray images are very helpful in detecting most chest-related diseases. As a continuation of this, we began our research in analyzing these Chest diseases once again with three CNN models and the results are discussed.

III. METHODOLOGY
The methodology includes the analysis of the 3 datasets for three chest diseases with the three different CNN models. The execution steps include pre-processing of the x-ray images and the classification of data into normal cases and infected cases.
The dataset underwent different image processing techniques for the image analysis and to retrieve the values from those images. The given dataset is divided into three sets for the processing train data, test data, and validation data. The Pneumonia dataset is split before computation. Other datasets COVID, Tuberculosis are split with the ratios of 75:10:15 for train, test, and validation. The processed image sets are passed through the different layers present in the pre-trained model, which generates a model for disease classification by comparing it with the untrained imageset.

A. Data Pre-Processing
The pre-processing execution starts once the images are resized and augmented. NumPy tensor is used as the function for preprocessing and it produces the output image of the same shape. In the data pre-processing image will be resized to 224x224x3 and then it is converted to an array to store the values. Each value in an array is rescaled by 255. The tensor input will insert a dimension of length at the index axis of the input's shape to refer to the values. The dimension index follows indexing rules which are given as: It's zero-based, a negative index is counted backward from the end. It helps in aligning axes for broadcasting, to add an inner vector length axis to a tensor of scalars. www.ijacsa.thesai.org

B. Classification
Classification is a task that requires the use of machine learning algorithms that learn how to assign a class label to examples from the problem domain. The pre-trained architecture generated a model with various arguments by validating the trained set with a validation set for 50 epochs to learn from the losses of previous epochs gives good accuracy. This validation process plays a major role in the detection to classify infected and uninfected images. In the end, it tries to draw some conclusions from the input values given for training in the form of the confusion matrix and line graphs. It will predict the class labels/categories for the new data. The execution procedure is shown in Fig. 1.
In this model, we are using the algorithms of Conventional Neural Networks. VGG19, DenseNet201, and ResNet50V2 models of CNN are used for training the different datasets and the prediction accuracy is measured for these models.

C. Datasets
Below datasets are extracted from Kaggle namely Pneumonia, COVID, Tuberculosis dataset with the size of 1.15GB, 1.97GB, 662.49MB respectively.
The pneumonia dataset contains 5856 images of which 5216 are used for training with all three models, 624 for the test, and 16 for validation as shown in Fig. 2. This dataset consists of two categories of images -Pneumonia cases, Normal cases. The dataset was obtained from Kaggle:https://www.kaggle.com/paultimothymooney/chest -xray-pneumonia.  COVID dataset contains 4606 captured images in which 3470 are used for training the model, 562 for the test, and 674 for validation as shown in Fig. 3. This dataset consists of two categories of images -COVID, Normal. The dataset obtained from Kaggle:https://www.kaggle.com/amanullahasraf/covid19 -pneumonia-normal-chest-xray-pa-dataset?select=covid. The tuberculosis dataset contains 4606 images in which 3470 are used for training the model, 562 for the test, and 674 for validation as shown in Fig. 4. This dataset consists of two categories of images -Tuberculosis infected chest, Normal chest. The dataset obtained from Kaggle:https://www.kaggle. com/tawsifurrahman/tuberculosis-tb-chest-xray-dataset.

IV. EVALUATION OF THE MODEL
The untrained test set has gone through the same preprocessing steps and is used to test the generated model which predicts the image with a suitable label, where end users can test their x-rays and uses the result for their study. The saved trained model can be further converted to an API for a mobile application to create a better user interface for users.

A. VGG19 Architecture
VGG model consists of a variety of models like VGG11, VGG16, and many more, among them VGG19 consists of 19 layers (16 convolution layers, 3 fully connected layers, 5 MaxPool layers, and 1 SoftMax layer) and 19.6 billion FLOPs. The input to VGG based convNet is a 224x224 grayscale image. Preprocessing layer takes the grayscale image with pixel values in the range of 0 to 255. The processing model for the VGG 19 is shown in Fig. 5. 239 | Page www.ijacsa.thesai.org

B. ResNet50V2 Architecture
Resnet50V2 is a huge architecture, it is taken and modified from Resnet50 in later years for better performance than previous architectures like resnet101. It is a contemporary convolution neural network (CNN) which addresses vanishing gradient problems using residual blocks in the architecture. In a residual network, multiple residual blocks are stacked up one after another. Each residual block is formed of short-cut connections skipping one or more layers. Resnet50V2 uses the pre-activation of weight layers. ResNet50V2 achieves accurate predictions on the datasets. The processing model for Resnet50V2 is shown in Fig. 6.

C. DenseNet201 Architecture
DenseNet-201 is a convolutional neural network that is 201 layers deep. Recent work has shown that convolutional networks can be substantially deeper, more accurate, and efficient to train if they contain shorter connections between layers close to the input and those close to the output. DenseNet connects each layer to every other layer in a feedforward fashion. Whereas traditional convolutional networks with L layers have L connections -one between each layer and its subsequent layer -the DenseNet network has L(L+1)/2 direct connections. For each layer, the feature maps of all preceding layers are used as inputs, and their feature maps are used as inputs into all subsequent layers [21,22]. DenseNets have several compelling advantages: they alleviate the vanishing gradient problem, strengthen feature propagation, encourage feature reuse, and substantially reduce the number of parameters. The processing model for Densenet201 is shown in Fig. 7.

V. PERFORMANCE ANALYSIS
The performances of these three VGG19, Resnet50V2, and Densenet201 algorithms are analyzed for all the diseases data set COVID, Pneumonia, and Tuberculosis. The metrics used for performance analysis are defined in terms of Accuracy, Loss, Confusion matrix, and Classification report. The simulation is done in python with TensorFlow and Keras. Keras Layers are the functional building blocks of Keras Models. These layers are fed with input information, they process this information, do some computation and hence produce the output. Also, we used matplotlib for data visualization and a few standard libraries like NumPy and Pandas for calculations of image arrays.
A. Classification Report a) Pneumonia: Pneumonia causes the lungs that fill with fluid and make breathing difficult. The analysis is made with the help of 624 values. Table 1. a and Table 1.b shows the confusion matrix and classification report of all Pneumonia datasets which is compared for all three algorithms. From the analysis, it can be identified that Resnet50V2 and VGG19 show high prediction accuracy with 92% and Densenet201 shows 91% of accuracy. b) Tuberculosis: Tuberculosis caused by bacteria usually attacks the lungs, but TB bacteria can attack any part of the body such as the kidney, spine, and brain. TB is spread from person to person through the air. The analysis is made with the help of 422 values. VGG19 and Densenet201 show 99% of accuracy for Tuberculosis as shown in Table 2.a and  Table 2.b and ResNet50V2 show 98% of prediction accuracy. c) COVID19: COVID-19 is an infectious disease caused by a coronavirus strain called severe acute respiratory syndrome coronavirus. The analysis is made with the help of 422 values for testing. The result is shown in Table 3.a and  Table 3.b shows VGG19 shows 98% whereas 97% for ResNet50V2 and 96% for Densenet201. This shows that Though all the models are similar the VGG19 shows better accuracy in the prediction.
The overall analysis shows VGG19 and the Resnet50V2 show more accuracy when compared to Densenet201.

B. Training Vs Validation Set
This section shows the comparative analysis of the algorithms concerning Loss and Accuracy of the data during the training and the validation process of the dataset. Table 4 shows the values of performance measures in terms of loss and accuracy achieved by models VGG19, ResNet50V2 and DenseNet201.   Table 4 and the training loss for each epoch is shown in Fig. 8. (a). Similarly, the training loss for tuberculosis is 0.1041, 0.0125, 0.0068 for the models VGG19, ResNet50V2, and DenseNet201 shown in Table 4 and the training loss for each epoch is shown in Fig. 8. (b). Finally, the training loss for the COVID19 are 0.0721, 0.0848, 0.1172 for the models VGG19, ResNet50V2, and DenseNet201 shown in Table 4 and the training loss for each epoch is shown in Fig. 8. (c).  Table 4 and the Validation loss for each epoch is shown in Fig. 9. (a). Similarly, the Validation loss for tuberculosis are 0.0469, 0.0212, 0.00009 for the models VGG19, ResNet50V2, and DenseNet201, and the Validation loss for each epoch is shown in Fig. 9. (b). Finally, the Validation loss for the COVID19 are 0.1201, 0.9956, 0.4328 for the models VGG19, ResNet50V2, and DenseNet201, and the validation loss for each epoch is shown in Fig. 9. (c). c) Training Accuracy: The training accuracy for the pneumonia is 0.9879, 0.9916, 0.9904 for the models VGG19, ResNet50V2, and DenseNet201 shown in Table 4 and the training accuracy for each epoch is shown in Fig. 10. (a). Similarly, the training accuracy for tuberculosis is 0.9699, 0.9971, 0.9996 for the models VGG19, ResNet50V2, and DenseNet201 shown in Table 4 and the training accuracy for each epoch is shown in Fig. 10. (b). Finally, the training accuracy for the COVID19 are 0.9716, 0.9930, 0.9823 for the models VGG19, ResNet50V2, and DenseNet201 shown in Table 4 and the training accuracy for each epoch is shown in Fig. 10. (c).  Table 4 and the validation accuracy for each epoch is shown in Fig. 11. (a). Similarly, the Validation accuracy for tuberculosis are 0.9899, 0.9916, 0.1 for the models VGG19, ResNet50V2 and DenseNet201 shown in Table 4 and the validation accuracy for each epoch is shown in Fig. 11. (b). Finally, the validation accuracy for the COVID19 are 0.9555, 0.9570, 0.9599 for the models VGG19, ResNet50V2 and DenseNet201 shown in table 4 and the validation accuracy for each epoch is shown in Fig. 11. (c).

VI. CONCLUSION AND FUTURE WORK
High precise diagnostic results are expected in helping the healthcare system to provide efficient services to the patient in less time. To attain this goal a CNN model was built in our research to study x-rays images of covid 19, pneumonia, tuberculosis. For this, we study VGG19, ResNet50V2, DenseNet201 architectures, and their performances have been analyzed with the X-ray images. We used Adam optimizer and trained for 50 epochs. Though all three models are highly accurate and consistent, considering the factors like architectural size, training speed, etc. Resnet50V2 is the best model for all three diseases. It trained with F1 score accuracies of 0.98,0.92,0.97 for pneumonia, tuberculosis, covid respectively.
In this study, we can't predict the diseases at the earlier stages. So, to predict the above chest diseases in earlier stages with the support of other parameters can be extended as part of future work.