1. Introduction
Respiratory infections caused by viral pneumonia or COVID-19 may become severe, especially for old age people, people already having a chronic medical illness, or people with a weak immune system. Pneumonia is an infectious disease that causes lung inflammation, which viruses, bacteria, fungi, or other germs may cause. The tiny sacs of the lungs are filled with pus and fluid, which makes breathing painful due to limited oxygen intake [1]. Pneumonia can also be a complication of COVID-19, the illness caused by the new coronavirus known as SARS-CoV-2. The symptoms of COVID-19 may be similar to the other kinds of viral pneumonia; therefore, it is hard to discover the cause of infection without a test [2]. In recent years, a large number of studies and research work have been carried out on applying machine learning models for automated detection of various diseases such as diabetic retinopathy,[3,4] breast cancer,[5,6] pulmonary nodules diagnosis,[7] and lung cancer [8]. Deep learning methods reveal very subtle features in images that are not visible otherwise. Specifically, the ability of convolutional neural networks (CNN) in deep feature extraction and learning has made them the leading choice among researchers for classificationrelated tasks in medical imaging problems [9]. Both pre-trained deep CNNs and CNNs trained from scratch can produce very high results if trained and fine-tuned robustly.
This study aims to apply deep transfer learning capabilities from pre-trained deep learning models to classify COVID-19 infections and viral pneumonia cases. In this study, we engineered and trained a deep CNN model based on the VGG16 model with custom layers. The model is trained and validated on an open public dataset. The dataset contains images for COVID-19, viral pneumonia, and typical cases discussed in the next section.
2. Methods
Deep architectures in CNN models allow for robust feature extraction, leading to high performance in image classification. Since pneumonia frequently appears foggy on X-rays, radiologists may have trouble diagnosing it correctly. It may also be a waste of time because the traits may coincide with those of other harmless oddities. As a result of these divergences of opinion, radiologists may arrive at different pneumonia diagnoses for different patients [10]. For this research, we create deep CNN models. Inputs to these models include frontal chest X-ray images, and outputs include binary and multiclass classifications indicating the presence or absence of pneumonia and COVID-19 abnormalities.
A. Data Source
After the COVID-19 pandemic broke out, several scientists and doctors began releasing publicly available datasets comprising X-ray, CT, and ultrasound images of lung diseases and their corresponding labels. We used X-ray images of COVID-19, viral pneumonia, and regular patients from a prize-winning dataset compiled by researchers and healthcare practitioners [11,12]. The photos included in the collection were culled from numerous open-access databases, websites, and previously published studies [13]. Our group used various images from the updated version of this dataset, including those of COVID-19, viral pneumonia, and regular chest X-rays. There are a total of 15,153 images throughout the three different types. The collection also contains images depicting lung opacity. However, we have decided against using them. There are 10,192 photographs of healthy individuals, 1345 photographs of individuals with viral pneumonia, and 3616 photographs of individuals who test positive for COVID-19. The PNG format is used for all the images in the collection, and each has an exact width and height of 299 pixels.
The images are available on the Kaggle website. The pictures used for Figure 1 were randomly picked from the entire set. Before training the model, the entire dataset was split 80/20 between a training set and a validation set. The images were solely utilized for the test. Thus, the model did not have access to them during training. To assist a dispassionate evaluation of the model, these images were first isolated from one another and stored separately. Afterward, a ratio of 80:20 was applied to further partition the train set into train and validation sets. In conclusion, are 9697 images in the training set, 2425 in the validation set, and 3031 in the test set.
B. Image Preprocessing
Some offline preprocessing operations and online image augmentation methods enhanced crucial image features and lessened unwanted distortions in the training set. Preprocessing required reducing the size of each image to 224 by 224 pixels, the default input size for the VGG16 model. We also employed a VGG16-specific preprocess input function on both the training and validation sets before feeding the data to the model. This technique converts the photos from RGB to BGR and centers each color channel at zero about the images in the ImageNet database. In this procedure, scaling is not used at any point. To fine-tune the VGG16 model, which had been trained on ImageNet, we converted single-channel chest X-ray images to multi-channel ones with three colors. Image augmentation was also used to expand the quantity of photos and the variety of those photos by randomly rotating each image in the training set by an angle between 0 and 5 degrees. Multiple versions of a post-production-enhanced image are shown in Figure 2.
C. Model Architecture
Deep convolutional neural network (CNN) models are the best alternative for advancing healthcare research because of their ability to extract complex lower-level information in images from the original training dataset. By examining X-rays of the lungs, we proposed a deep CNN model for distinguishing between COVID-19, viral pneumonia, and healthy individuals. As part of that work, we came up with this model. The proposed model is built with pre-trained weights for the ImageNet database and the VGG16 underlying architecture. The model's degree of detail was improved by using extra custom layers. Simonyan and Zisserman developed the VGG16 convolutional neural network (CNN), and it is a simple and widely used CNN. VGG16 earns an accuracy score of 92.7% on the ImageNet dataset, which contains over 14 million images from 1000 categories. The presented model can be used as a diagnostic tool for primary screening and distinguishing between COVID-19, viral pneumonia, and healthy patients. Figure 3 depicts the overall design of the provided model.
The provided deep CNN model is based on the VGG16 pre-trained model. At first, we made the entire model trainable to retrain the network's pre-trained parameters. However, this did not lead to the expected outcomes. Then, we began methodically removing preconceptions and assessing the results. We found that the model performed best when the last four layers were left open (trainable) and the remaining ones were frozen (pre-trained). We built a few layers of original code on top of this framework. These extra layers allowed the model to generate far better results that were more specific to our objective.
Figure 3 demonstrates the five specific layers applied to the base model. After that, we used the AveragePooling2D technique with a pool size of (4, 4) to down-sample the image. The flattened layer produced a 1D array of elements, eliminating all dimensions. Next, a dense layer was applied with 64 output neurons, followed by a dropout layer to ignore half of the neurons in a random sample, and finally, a third dense layer was applied with three output neurons. The final classification result was generated using the softmax activation function. The model weights were first assigned randomly, and subsequent updates were made according to the gradient of the loss as it was computed about the truth. It was intended that the loss function be minimized optimally. Because the model does not acquire knowledge from this information, the validation set has only a secondary effect on the model's training. We used a validation set to reduce the likelihood of the model being overfit and to fine-tune its hyperparameters. The optimal final weight was recorded and used for further evaluation in the test set that followed model training. Since it was created independently of the original dataset and used for testing purposes alone, the test set contains images that the model has never seen before (during training or validation). In Table 1, we show our chosen values for the model's hyperparameters.
D. Performance Metric
Accuracy, sensitivity, specificity, precision, recall, F1 score, and confusion matrix are the commonly used metrics for measuring the performance of classification models. These metrics are derived using four values: true positive, true negative, false positive, and false negative. We used precision, recall, and F1 scores to measure the performance of our model. We also plotted the receiver operating characteristic (ROC) curve, considered the de facto standard for classification tasks in medical images.
The following equations show the formula of accuracy, precision, recall, and F1 score to measure the model's performance for multiclass classification.
Where
𝑇𝑃𝑐: COVID-19 positive patients predicted to be positive
𝑇𝑃𝑝: Viral pneumonia-positive patients predicted to be pneumonia positive 𝑇𝑃𝑛: Normal patients expected to be normal
𝐹𝑃𝑐: Normal patients expected to be COVID-19 positive
𝐹𝑃𝑝: Normal patients expected to be viral pneumonia positive
𝐹𝑁𝑐: COVID-19 patients expected to be normal
𝐹𝑁𝑝: Viral pneumonia-positive patients expected to be regular patients
E. Experimental Setup
Training a deep neural network is highly resource-intensive due to the need to perform matrix multiplication on the input and weight arrays. The graphics processing unit (GPU) is increasingly replacing CPUs as the go-to piece of hardware for deep learning model training because of its larger memory bandwidth and more significant number of cores. More traditional approaches utilizing central processing units (CPUs) could achieve this, but it would take too long, especially for models with billions of parameters. In this investigation, we use GPU nodes from the Kshitij-5 highperformance computing cluster to conduct our training, validation, and testing.
3. Results
The proposed model is verified by applying it to a test set consisting of 317 images. These images are never utilized in the model's training and have never been seen by it before. A CNN model is created with 49339 parameters as shown in figure 4.
6. Conclusion
In this study, we sought to automate the process of classifying chest X-ray pictures for the presence of COVID-19 and other viral pneumonia using a deep CNN model built on top of the popular deep learning framework VGG16. The proposed methodology could aid clinicians in making rapid, preliminary diagnoses of COVID-19 and viral pneumonia. The model's results are noteworthy because it successfully classifies the three cases with high recall and precision. The model can also perform this function. The next step of this research will involve adding hospital images to the training dataset to make the model more accurate and dependable. Furthermore, one of our objectives is to identify the infectious parts of the images by creating class activation maps.
Funding: “This research received no external funding”
Conflicts of Interest: “The authors declare no conflict of interest.”