Keywords

1 Introduction

The world should establish a fast, reliable recovery to be prepared to act the next time a pandemic strikes [1] reliably. Using different computer science areas as Artificial intelligence (AI), machine learning, deep learning, and big data can help overcome the crises caused by COVID-19. Deep learning proved its efficiency in the detection of diseases from medical images as Magnetic resonance Imaging (MRI), Computerized Tomography (CT), and X-ray [2]. In COVID-19 case, radiologic images contain useful diagnostic information [1].

People suspected of coronavirus are required to make tests of the real-time reverse transcription-polymerase chain reaction (RT-PCR) and chest imaging as the CT or X-ray [3]. Using RT-PCR only is not enough due to its low sensitivity. Therefore, CT is an important screening tool with RT-PCR. Recent studies are conducted towards the detection of COVID-19 from chest radiology images as CT [4] and X-ray [5] images. This gave rise to the need to develop fast, accurate, and reliable Computer-Aided Diagnosis (CAD) systems based on AI technologies [3].

CNN is widely used for feature extraction and also the classification of medical images. In [4], the authors used the Convolutional Neural Network (CNN) to analyze the CT slices of COVID-19 patients and non-COVID-19 patients. Other researchers directed their studies for the detection of COVID-19 from X-ray images. Toğaçar et al. [5] preprocessed the images by using a fuzzy color approach to restructure classes. They used MobileNetV2 and SqueezeNet deep learning models for feature extraction. The extracted feature set was then classified using the support vector machine. Ozturk et al. [2] used the Darknet-19 classifier model. This model can extract features of a real-time object known as YOLO (You only look once). Their model achieved 98.08% for binary classes (COVID and No-Findings) and 87.02% for multi-class (COVID, No-Findings, and Pneumonia).

In [6], the authors compared different deep learning models for the detection of cases suffering from pneumonia in COVID-19 patients from both CT and X-ray images. Their results showed that the inception_Resnet_V2 and Densnet201 models achieved an accuracy of 92.18% and 88.09% respectively. Wang and Wong [7] developed the COVID-Net model that achieved 92.4% accuracy to classify three classes; normal, COVID-19, and non-COVID pneumonia. Fine-tuning of the deep neural network was proposed by Babenko et al. [8]. They instantiated the idea of neural codes and how this technique can obtain high performance when CNN is pre-trained with different classification tasks. All these studies suggest new medical research that has to be clinically evaluated before being used as a guide in diagnosis and treatment.

The objective of this study is to assist medical professionals with their initial screening, overcome the problem of lack of specialized medical professionals in remote villages, overcome the insufficient number of test kits, reduce test cost, and waiting time for test results. The main contribution of the proposed approach can be summarized as follows:

  • This study proposes a fast detection approach to detect COVID-19 from X-ray images.

  • X-ray images are aggregated from three public datasets (500 normal and 500 COVID).

  • CNN extracts features from chest X-ray images to classify input image to either infected or normal class.

  • Seven different deep learning models with their variants are examined which are DenseNet, Inception_Resnet, MobileNet, NASNet, ResNet, VGG, and Xception.

  • Transfer learning is used to overcome the small size dataset available for COVID-19.

  • Fine-tuning approach is applied to improve network generalization and enhance model accuracy.

  • Several measurements are used in order to evaluate the performance of the proposed approach, and these measurements are accuracy, sensitivity, specificity, and computation time.

  • Employing MobileNet deep model in our proposed approach achieved 98% accuracy with the least computation time compared to other models.

The rest of the paper is organized as follows: Sect. 2 illustrates the methodology of the proposed approach. The experimental results and discussion are presented in Sect. 3. Finally, Sect. 4 concludes the paper.

2 Methodology

Deep learning approaches gave remarkable results in the detection of pneumonia from chest X-rays. The advances in this field can contribute in the analysis of COVID-19 as it affects the human lungs.

2.1 Dataset

This study tries to detect COVID-19 by differentiating between two classes COVID versus No-finding (normal) from front chest X-ray images. Three publically available chest X-ray datasets are combined together (500 No-findings and 500 COVID-19). The normal images are selected randomly from the ChestX-ray8 database provided by Wang et al. [9]. Due to the leakage of COVID-19 images and also to prevent the problem of unbalanced data, the COVID images are aggregated from two datasets. The Cohen database [10] is updated frequently. Currently, this database contains 439 front chest images diagnosed with COVID-19. The rest of the COVID-19 images are obtained from the COVID-19 dataset available on the Mendeley Data website [11].

2.2 Data Pre-processing

The used X-ray images are not uniform as they are of different dimensions. Therefore, all images are resized to 224 × 224 pixels or 299 × 299 according to the used model. The images are further converted from RGB to BGR. Each image is then normalized based on the mean and standard deviation with respect to the ImageNet of the training dataset.

2.3 Convolutional Neural Network (CNN)

CNN is known for its popularity in many medical image applications [12]. It consists of multiple layers that are capable of achieving high accuracy with a high volume of data. The initial layers can detect edges and colors, while deeper layers can detect complicated features. Finally, deeper layers combine features of earlier layers [13]. The main components of CNN are convolution, pooling, flattening, and fully-connected layers. The input data is gone under two main phases; feature extraction and classification [12]. The pooling layer reduces the spatial dimension by considering the convolved features. This can help in reducing computation costs and also control the overfitting problem. The last part of the network is built up of fully-connected layers that perform the classification process. To avoid the overfitting problem, a dropout layer is used [14].

Activation Function.

It is a function that calculates the weighted sum of biases together with input to determine whether to fire the neuron or not. The non-linear transformation of the activation function, allows the network to learn complex operations [15]. This study uses ReLU for hidden layers, while Softmax is used in the output layer.

Rectified Linear Unit (ReLU).

It is a non-linear activation function that is commonly used in the deep neural network. If the input is negative ReLU outputs zero, otherwise it outputs the input value as shown in Eqs. (1) and (2).

$$f\left(x\right)=\mathrm{max}\left(0, x\right)$$
(1)
$$f\left(x\right)= \left\{\begin{array}{c}0, x<0\\ x, x\ge 0\end{array}\right.$$
(2)

where \(x\) represents the input value.

Softmax.

It is an activation function that calculates the probability distribution of each class, where the highest probability indicates the target class of the given input. It outputs a value in the range between [0, 1], where the sum of all probabilities is equal to 1 [13]. It is commonly used in output layers of deep learning networks.

$$\upsigma\left({x}_{i}\right)= \frac{{e}^{{x}_{i}}}{{\sum }_{j=1}^{K}{e}^{{x}_{j}}}$$
(3)

for \(i=1, \dots , K\,and\,x=\left({x}_{1},\dots , {x}_{K}\right)\in {\mathbb{R}}^{K}\) where the standard exponential is applied to each element \({x}_{i}\) in the vector \(x\) and the output is normalized by dividing it by summation of all exponentials.

Dropout.

Deep networks suffer from having too many parameters. These networks though powerful, are slow and are subject to the overfitting problem. The dropout technique is one of the ways to address this overfitting problem. In the training phase, some units are dropped randomly between two layers that are fully-connected. Dropout ensures that no network node is entirely responsible for the activation when given a particular pattern. This can help the network to generalize and to reduce co-adaptation that results in overfitting [14].

Fine-Tuning.

It uses a network model that was trained for a specific job to perform a similar job. Using a pre-trained model allows us to use the features extracted from the front layers without having to re-train the network from scratch. The initially trained output layer is replaced with another new shallow network that uses the features resulting from lower-level layers and mapping them to reach the target output classes [16]. The network-tuning helps to improve network generalization and thus, achieving higher accuracy.

2.4 Optimization

The most popular and common techniques for optimizing deep learning models are gradient decent algorithms. Given a large-scale dataset and the limited memory especially on GPUs, an efficient and effective training cannot be performed by the conventional batch gradient decent and the stochastic gradient decent techniques [17]. In this study, the Adam optimization algorithm is used to optimize parameters of the network.

Adam Optimizer.

Adam is an efficient optimization technique that has been widely used in deep learning applications. It can replace the stochastic gradient descent in the training of deep learning models. Unlike other techniques, it does not require too much memory. It is based on the first-order gradients, where it calculates the learning rates adaptively for various parameters from the first and second approximations of the gradient moments [17].

2.5 Proposed Approach

The existing COVID datasets are still not mature and suffer from a low number of COVID X-rays images. A common practice in deep learning is to use the features obtained from learning a larger dataset in a similar problem [1]. Thus, using a pre-trained model can overcome the problem of having a small dataset. The ImageNet is considered the biggest challenge for segmentation and classification in the field of image analysis [18]. The weights obtained from training the network on the ImageNet dataset are used in transfer learning.

As presented in Fig. 1, the network of the proposed approach consists of a pre-trained model (base-model) for feature learning followed by a classifier (top-model) consisting of a number of fully-connected layers. Seven different deep learning models were examined with their variants as pre-trained models; DenseNet, Inception_Resnet, MobileNet, NASNet, ResNet, VGG, and Xception. These seven models are selected due to their popularity in similar medical applications. All convolutional layers use ReLU for activation. The weights of the pre-trained model are frozen, allowing only the weights of the classifier to be updated during training. The obtained feature matrix from the pre-trained models is converted from two-dimensional to one-dimensional vector by applying the flattening transformation. This vector will be input to the newly added fully-connected network of the classifier.

The classifier is trained to differentiate between the two classes; COVID and normal. It consists of two fully-connected layers. The activation function of the first layer is ReLU, while Softmax is used in the output layer. To obtain better results, the network is fine-tuned to get a higher level of feature representation by adapting the network to the COVID X-ray dataset. This is done by unfreezing the convolutional layers (base-model) and setting the learning rate to a small value. Finally, train the whole network (convolutional model and the classifier) [16]. Thus, obtaining weights more tuned to match our dataset. The model is optimized using the Adam optimization algorithm [17]. Dropout is applied to the first fully connected layer where it reduces overfitting and helps in achieving higher performance and faster optimization [14].

Fig. 1.
figure 1

Proposed Methodology

2.6 Performance Metrics

To measure the performance of the proposed approach, accuracy, sensitivity and specificity are calculated using the following metrics [19]:

  1. 1.

    True Positives (TP) is the number of correctly classified COVID cases

  2. 2.

    False Negatives (FN) is the number of incorrectly classified COVID cases

  3. 3.

    True Negatives (TN) is the number of correctly classified normal cases

  4. 4.

    False Positives (FP) is the number of incorrectly classified normal cases

Accuracy is the ability of the network to differentiate between COVID and normal cases by calculating the total number of correctly classified cases. The sensitivity measures the ability of the network to correctly classify COVID cases, while the specificity measures the ability of the network to correctly classify normal cases [19].

3 Experimental Results

This study aims to differentiate between the front chest X-ray images of normal people and images of patients suffering from COVID-19 (500 images each) using deep learning approaches. The data are randomly divided into 80% for training and 20% for evaluation. The images are resized to 299 × 299 for models InceptionResNet and Xception while the images are resized to 224 × 224 for the rest of the models. The original front convolutional layers of the pre-trained model are frozen so that the weights are not updated during the training of the new layers [13]. The transfer learning is employed by using the features obtained from training the network on the ImageNet dataset. The learning rate is set to a small value (0.0001) so that the new network starts learning from the pre-trained network.

The network is tuned to conclude new classes that it was not trained on by adding a classifier of two fully-connected layers, which are randomly initialized. The size of the first fully dense layer is 64 units with a ReLU activation function. To prevent overfitting, dropout is used to disconnect between the fully-connected layers randomly. A dropout layer with a rate of 0.25 is added after ReLU. The output layer of the classifier is a Softmax layer that has the same number of desired output classes (two units). The training of the model is done with 25 epochs and a batch normalization layer (mini-batch) of size 8. The model is optimized using Adam optimizer.

3.1 Results

This study compared the performance of seven different pre-trained CNN models with their variants which are: DenseNet, InceptionResNet, MobileNet, NASNet, ResNet, VGG, and Xception. Figure 2 presents the accuracy versus the loss of each model when applied on both training and validation datasets. Table 1 shows the performance of the examined models in terms of accuracy, sensitivity, specificity, and run-time. The best accuracy is obtained by MobileNet followed by InceptionResNet, NASNetMobile, and ResNet. The minimum computation time is given by MobileNet followed by both VGG models. As observed from obtained results, MobileNet outperformed all other models in terms of both accuracy and time.

Fig. 2.
figure 2

The accuracy and loss of different models for training and validation sets

Table 1. Performance metrics of deep learning models on validation set of COVID-19 dataset

We couldn’t compare our work with others as there is no fixed benchmark dataset. Also, existing datasets are updated frequently. As observed from results, the deep learning models can detect COVID-19 efficiently from chest X-ray. They achieved accuracy greater than 95% for all models, as shown in Fig. 3. MobileNet has an advantage over other deep models is that it is characterized of being a light weight network with low latency [20]. This clarifies the lower computation time consumed by this model compared to others. MobileNet model outperformed the rest of the models as they gave the best accuracy with minimum run-time. The proposed model offers a fast, efficient, reliable, and low-cost model for the diagnosis of COVID-19.

Fig. 3.
figure 3

Accuracies and run-time of models applied on validation set of COVID-19 data

4 Conclusion

This study aims to detect the COVID-19 from chest X-ray images. It compares seven different deep learning models with transfer learning in terms of accuracy and computation time. These models are; DenseNet, InceptionResNet, MobileNet, NASNet, ResNet, VGG, and Xception. They are examined on images obtained from three public datasets. The proposed methodology with the MobileNet model achieved 98% accuracy with minimum computation time. Thus, this study recommends using the MobileNet model in the detection of COVID-19 from chest X-Ray images.

Results showed that developing Computer-Aided Diagnosis tools using deep learning models for the detection of COVID-19 can be reliable, promising, and speed up the diagnosis process. Yet, we cannot depend on them solely, as any error may affect people’s life. These tools can assist radiologists in their first screening, but will never replace them. The final decision should always be for radiologists. One of the main challenges that faced this study is the limited number of images available for COVID-19. In the future, more data will be used to validate the recommended network. Sometimes the X-ray images suffer from poor quality that may affect the diagnosis process. Therefore, removing artifacts in images and segmenting the infected part in the lung will also be tackled.