Journal of Artificial Intelligence and Metaheuristics cover
Journal of Artificial Intelligence and Metaheuristics

Online ISSN 2833-5597

Full Length Article

Volume 6 • Issue 1 • PP: 48-55 • 2023

CNN-Based Multiclass Classification for COVID-19 in Chest X-ray Images

S.K.Towfek 1*
1Computer Science and Intelligent Systems Research Center, Blacksburg 24060, Virginia, USA
* Corresponding Author.
verified

Open Access & Copyright

© 2023 The Author(s). Published by ASPG. This article is licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0).

Abstract

Managing the increasing number of patients requiring first screening can be significantly aided by real-time automated detection of COVID-19. It's feasible that Deep CNN models that have been trained on sufficiently large datasets will emerge as the most promising options for achieving the goal. This study aims to automatically detect and classify COVID-19 and viral pneumonia infections in chest X-ray images using a deep CNN model. Our proposed model relies on multiclass labeling to accomplish our aims. Design and Organization: Using the ImageNet pre-trained weights, the proposed model is built on top of the VGG16 framework. Additional custom layers were used to fine-tune the model and produce a better overall performance that is more specific to the goal. In terms of its subjects and methods, this study uses 15,153 samples in total. There are X-rays of the lungs from patients with COVID-19, those with viral pneumonia, and healthy volunteers. The entire dataset was split into an 80:20 split for the train and test sets before the model was trained. Image preprocessing and augmentation were used to enhance crucial parts of the photos before they were sent to the model in batches. We measure the model's efficacy with accuracy, precision, recall, and the F1 score. The analysis that was performed statistically was. The model's output is compared to the results of other recent research that have set the standard in the field. The proposed model has a 98% accuracy in multiclass classification on the test dataset, as measured by 98% precision, 96% recall, and 97% F1 score. Receiver operating characteristic curve area scores of 0.99 were achieved in all three multiclass classification situations. Finally, the proposed categorization model may show to be highly useful in the first diagnosis of COVID-19 and viral pneumonia patients, especially when dealing with heavy workloads and large volumes.

Full Text

This HTML version is generated from the article PDF. The PDF remains the version of record.

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.

Figure 1. Sample X‑ray images from dataset: (a) COVID‑19, (b) viral pneumonia, (c) normal
Figure 1. Sample X‑ray images from dataset: (a) COVID‑19, (b) viral pneumonia, (c) normal

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.

Figure 2. Image variants after augmentation
Figure 2. Image variants after augmentation

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.

Figure 3. Architecture of proposed deep convolutional neural network model
Figure 3. Architecture of proposed deep convolutional neural network 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.

Table 1. Parameters during the training
Table 1. Parameters during the training

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.

𝑇𝑃𝑛+𝑇𝑃𝑐+𝑇𝑃𝑝 𝑇𝑜𝑡𝑎𝑙 𝑆𝑎𝑚𝑝𝑙𝑒𝑠                                                                                                            (1) 𝐴𝑐𝑐𝑢𝑟𝑎𝑐𝑟𝑦=
𝑇𝑃𝑐+𝑇𝑃𝑝 𝑇𝑃𝑐+𝐹𝑃𝑐+𝑇𝑃𝑝+𝐹𝑃𝑝                                                                                                       (2) 𝑃𝑒𝑟𝑐𝑖𝑠𝑖𝑜𝑛=
𝑇𝑃𝑐+𝑇𝑃𝑝 𝑇𝑃𝑐+𝑇𝑃𝑝+𝐹𝑁𝑐+𝐹𝑁𝑝                                                                                                            (3) 𝑅𝑒𝑐𝑎𝑙𝑙=
2 𝑃𝑟𝑒𝑐𝑖𝑠𝑖𝑜𝑛×𝑅𝑒𝑐𝑎𝑙𝑙 𝑃𝑟𝑒𝑐𝑖𝑠𝑖𝑜𝑛+𝑅𝑒𝑐𝑎𝑙𝑙                                                                                                        (4) 𝐹1 𝑆𝑐𝑜𝑟𝑒=

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.

Figure 4. Model parameters
Figure 4. Model parameters
Figure 5. The training accuracy and the validation accuracy
Figure 5. The training accuracy and the validation accuracy
Figure 6. The training loss and the validation loss
Figure 6. The training loss and the validation loss
Table 2. The performance of cnn model
Table 2. The performance of cnn model
Figure 7. The confusion matrix CNN model
Figure 7. The confusion matrix CNN model

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.”

References

 

[1]    Pneumonia. Available from: https://www.who.int/news-room/ fact-sheets/detail/pneumonia.

[2]    Seladi-Schulman J. What to Know About COVID-19 and Pneumonia. Healthline.  Available  from:  https://www.healthline.com/health/ coronavirus-pneumonia#vs-regular-pneumonia.

[3]    Gulshan V, Peng L, Coram M, Stumpe MC, Wu D, Narayanaswamy A, et al. Development and validation of a deep learning algorithm for detection of diabetic retinopathy in retinal fundus photographs. JAMA, 316(22), 2402-2410, 2016.

[4]    Gargeya R, Leng T, Automated identification of diabetic retinopathy using deep learning. Ophthalmology, 124(7), 962-969, 2017.

[5]    Amrane M, Oukid S, Gagaoua I, Ensari T, Breast Cancer Classification Using Machine Learning. 2018 Electric Electronics, Computer Science, Biomedical Engineerings’ Meeting (EBBT), Istanbul, 1-4, 2018.

[6]    Hussain L, Aziz W,  Saeed S,  Rathore S,  Rafique M. Automated Breast  Cancer  Detection  Using  Machine  Learning  Techniques  by Extracting  Different  Feature  Extracting  Strategies. 2018 17th IEEE International Conference on Trust, Security and Privacy in Computing and Communications/12 IEEE International Conference on Big Data Science and Engineering (TrustCom/BigDataSE), 327-31, 2018.

[7]    Xie Y,  Xia Y,  Zhang J,  Song Y,  Feng D,  Fulham M, et al,  Knowledge-based  collaborative  deep  learning  for  benign-malignant lung  nodule  classification  on  chest  CT.  IEEE  Trans  Med  Imaging, 38(4), 991-1004, 2019.

[8]    Wu Q, Zhao W., Small-Cell Lung Cancer Detection Using a Supervised Machine Learning  Algorithm. 2017 International Symposium on Computer Science and Intelligent Controls (ISCSIC), Budapest, 88-91, 2017.

[9]    Krizhevsky  A,  Sutskever I,  Hinton GE., Imagenet  Classification with Deep Convolutional Neural Networks. In Advances in Neural Information Processing Systems, 1097-105, 2012.

[10]  Neuman MI, Lee EY, Bixby S, Diperna S, Hellinger J, Markowitz R, et al,  Variability  in  the  interpretation  of  chest  radiographs  for  the diagnosis of pneumonia in children. J Hosp Med, 7, 294-298, 2012.

[11]  Chowdhury ME,  Rahman T,  Khandakar A,  Mazhar R,  Kadir MA, Mahbub  ZB,  et  al,  Can  AI  help  in  screening  viral  and  covid-19 pneumonia?,  IEEE Access, 8, 65-76, 2020.

[12]  Rahman T, Khandakar A, Qiblawey Y, Tahir A, Kiranyaz S, Kashem SB, et al, Exploring the effect of image enhancement techniques on covid-19 detection using chest X-ray images. Computers in Biology and Medicine, 132, 2021.

[13]  BIMCV-COVID19, Datasets Related to COVID19’s Pathology Course. Available from: https://bimcv.cipf.es/bimcv-projects/bimcv-covid19/#1 590858128006-9e640421-6711. [Last accessed on 2021 Mar 06].

[14]  COVID-19-image-repository.    Available    from:    https://github.com/ ml-workgroup/covid-19-image-repository/tree/master/png.

[15]   COVID-19    Database.   Available    from:    https://sirm.org/category/ senza-categoria/covid-19/.

[16]  “Eurorad.org.” Eurorad. Available from: http://www.eurorad.org/. [Last accessed on 2021 Mar 06].

[17]  “COVID-19 Image Data Collection.” Cohen2020covid, 2020. Available from: http://github.com/ieee8023/covid-chestxray-dataset.

[18]  Arman H,  Mahdiyar MM,  Seokbum K.  COVID-19  Chest  X-Ray Image Repository. Figshare Dataset; 2020. Available from: https://doi. org/10.6084/m9.figshare. 12580328.

[19]  “Armiro/COVID-CXNet.”  Armiro,   2020.  Available   from:   https:// github.com/armiro/COVID-CXNet.

[20]  RSNA Pneumonia Detection Challenge. Available from: https://www. kaggle.com/c/rsna-pneumonia-detection-challenge/overview.  [Last accessed on 2021 Mar 06].

 

Continue Reading

View the full issue arrow_forward

Cite This Article

Choose your preferred format

format_quote
S.K.Towfek. “CNN-Based Multiclass Classification for COVID-19 in Chest X-ray Images.” Journal of Artificial Intelligence and Metaheuristics, vol. 6, no. 1, 2023, pp. 48–55. https://doi.org/10.54216/JAIM.060105.
S.K.Towfek (2023). CNN-Based Multiclass Classification for COVID-19 in Chest X-ray Images. Journal of Artificial Intelligence and Metaheuristics, 6(1), 48–55. https://doi.org/10.54216/JAIM.060105
S.K.Towfek. “CNN-Based Multiclass Classification for COVID-19 in Chest X-ray Images.” Journal of Artificial Intelligence and Metaheuristics 6, no. 1 (2023): 48–55. https://doi.org/10.54216/JAIM.060105.
S.K.Towfek (2023) ‘CNN-Based Multiclass Classification for COVID-19 in Chest X-ray Images’, Journal of Artificial Intelligence and Metaheuristics, 6(1), pp. 48–55. Available at: https://doi.org/10.54216/JAIM.060105.
S.K.Towfek. CNN-Based Multiclass Classification for COVID-19 in Chest X-ray Images. Journal of Artificial Intelligence and Metaheuristics. 2023;6(1):48-55. doi:10.54216/JAIM.060105
S.K.Towfek, “CNN-Based Multiclass Classification for COVID-19 in Chest X-ray Images,” Journal of Artificial Intelligence and Metaheuristics, vol. 6, no. 1, pp. 48–55, 2023, doi: 10.54216/JAIM.060105.
policy

Publisher's Note

The statements, opinions, and data presented in this article are solely those of the author(s) and do not necessarily represent those of ASPG, the journal, or its editors. ASPG and the editors disclaim responsibility for any harm arising from the use of any ideas, methods, instructions, or products described in this article, to the fullest extent permitted by applicable law.

Digital Archive Ready