Keywords

1 Introduction

COVID-19(SARS COV2) is a form of pneumonia. First emerged at Wuhan Seafood Wholesale Market (Huanan Market) in Wuhan, China. The cases were identified from 2019. It is a positive-stranded RNA virus belongs to Coronaviridae, a subgroup B beta corona virus. It is also a 96.2% sequence of RATG13 virus. It infects endothelial cells living in blood vessels. The symptoms are fever, cough, short breathing, fatigue, headache, smell lose, sour throat and running nose. The total confirmed cases are 1165,772,430 and the total deaths are 3,437,545 as per 22 which is worldwide.

The most affected countries are the USA, India and Brazil respectively. The initial days, there are no test kits available readily to test the patients. The tests used to detect the corona virus are RT-PCR test, Antigen test and Antibody test. RT-PCR test is a gene detection method. It collects samples from nasal and throat. It requires high laboratory and takes 48 h to know whether a person is infected with COVID or not. The accuracy of this test is 97%. Antibody test takes blood samples to detect the antibodies against the COVID-19. It is fast but the accuracy is low and can be misleading. Rapid antigen test takes samples from nose to test the viral proteins. It takes 15 min and is not recommended for COVID detection. So as the RT-PCR test takes nearly 48 h which is time-consuming process, deep learning comes in place to support the doctors in detection of COVID-19 by performing convolution neural networks on x-rays. Nowadays, artificial intelligence produces a stable and accurate results, and it also plays an important role in the health industries. There are many techniques used to detect the COVID-19 such as using networks likeVGGNet16, Alex Net, InceptionV3 and MobileNetV2. In this work, we are using ResNet50 for classification of pneumonia and corona virus (Figs. 1 and 2).

Fig. 1
figure 1

The total corona cases worldwide

Fig. 2
figure 2

The total deaths worldwide

2 Related Works

In paper [1], Amit Kumar has taken a total of 771 images. They have used various neural networks such as DenseNet201, ResNet50 and InceptionV3 and achieved an accuracy of 93.6%, 95.3%, 94%, respectively, and sensitivity of 92%, 98% and 93%, respectively. They classified two types which are COVID +ve and COVID −ve. The total images for training are 771 images and for testing, the images are 235. They have used a sigmoid function in fully connected layer.

In paper [2], Linda Wang proposed a model of COVID-Net architecture. This is an open source available in [3]. The model was pretrained on the ImageNet model and achieved an accuracy of 93.3% and sensitivity of 95%. In this model, the classification is multi-classification and the classified types are normal, non-COVID-19 pneumonia and COVID-19. The data set contains a total of 1975 images. The data source is available here [3].

In paper [4], Afshar has proposed a model of COVID-caps architecture. This model has four convolutional layers and three capsule layers. This model classifies COVID +ve and COVID –ve with an accuracy of 98.3%. The fully connected layer uses sigmoid function.

In paper [5], Ahishali proposed a Chex Net architecture. This model has DenseNet-121 and a COVID-19Net architecture. It uses SoftMax function for multi-classification in output layer. This model classifies normal, viral pneumonia, bacterial pneumonia and COVID-19. The data set used is COVID Family data set. The accuracy obtained is 88.9%.

In paper [6], Qin used a CovNet model. This model is a 3D deep learning model. This model uses ResNet as a base model. The SoftMax function is used in fully connected layer. This model classifies a multi-classification. The classified types are COVID-19, CAP and non-COVID-19 pneumonia. The accuracy achieved is 90%.

In paper [7], Rachna made a comparison between different neural networks. The model used in this paper are Xception, InceptionV3 and ResNeXt. The accuracy achieved by this model are 97.97%, 96% and 93%, respectively. The total images used for classification is 6432 images. In these, 5467 images are used for training and 965 images for validation. The classification is multi-classification and the classified types are COVID-19, pneumonia and normal. The data set can be accessed here [8].

In paper [9], a deep learning convolution neural network with seven layers is used. The results of image processing and feature analysing COVID-19 gives 91.67% accuracy. Again, the data is further classified and trained using CNN for feature extraction. It achieves 100% accuracy.

3 Methods and Materials

3.1 Proposed Approach

The following model shows the proposed approach in this paper. The steps included in this model are Data Collection, Data Pre-processing, Training the model and results analysis (Fig. 3).

Fig. 3
figure 3

Proposed approach

3.2 Data sets

The data sets used for this model are collected from Kaggle repository. The data sets are openly accessible to everyone and can be accessed here [10]. The bacterial data set can be accessed here [11]. A total of 5365 images have taken for model validation. The data set contains 1341 normal images, 1345 viral images, 1200 COVID images and 1478 bacterial images. The data set distribution is shown in Table 1.

Table 1 Data set distribution

Some of the examples of chest X-rays are: (Figs. 4, 5, 6 and 7)

Fig. 4
figure 4

Bacterial pneumonia

Fig. 5
figure 5

Normal

Fig. 6
figure 6

COVID-19

Fig. 7
figure 7

Viral pneumonia

3.3 Data Pre-processing

All the images in the data set have undergone by the following steps: (10 The images are reshaped into (224,224,3) (2) The flip used here is RandomHorizontalFlip. (3) The Zoom range is 0.5 and Sheer range is 0.5. The framework used here is Py torch.

Then, the images are applied to the trained model. By using Random_Split method, the data set is divided into 80% for training purpose and 20% for validation.

3.4 Proposed Neural Networks

3.4.1 ResNet18

ResNet18 is a residual network having 18 layers. This model has identity connection block and convolution block. The convolution block will be applied if the input size and output size are not matched and identity connection block is applied if the input and output sizes are matched. The loss function used in this model is categorical entropy loss, and the SoftMax function is used since it is a multi-classification. The total trainable parameters are 11,178,564. The model used here is pre-trained model. The model architecture is shown below.

To train this model Google Colab and Pytorch framework is used (Figs. 8 and 9).

Fig. 8
figure 8

Resnet-18 architecture

Fig. 9
figure 9

Basic building block of residual network

3.4.2 ResNet50

ResNet50 is a residual Network having 50 layers. This model has identity connection block and convolution block. The convolution block will be applied if the input size and output size are not matched and identity connection block is applied if the input and output sizes are matched. The loss function used in this model is categorical entropy loss, and the SoftMax function is used since it is a multi-classification. The total trainable parameters are 31,956,868. The model used here is pretrained model. The model architecture is shown in Fig. 10.

Fig. 10
figure 10

Resnet50 architecture

To train this model, Google Colab and Keras Framework is used.

4 Result Analysis

The proposed models are evaluated using confusion matrix and by using following parameters such as sensitivity, specificity, accuracy, F1 score and precision.

$${\text{Accuracy}} = \left( {{\text{TP}} + {\text{TN}}} \right)*{1}00/\left( {{\text{TP}} + {\text{TN}} + {\text{FP}} + {\text{FN}}} \right)$$
$${\text{Sensitivity}}\,{\text{or}}\,{\text{Recall}} = {\text{TP}}/\left( {{\text{TP}} + {\text{FN}}} \right)$$
$${\text{Precision}} = {\text{TP}}/\left( {{\text{TP}} + {\text{FP}}} \right)$$
$${\text{Specificity}} = {\text{TN}}/\left( {{\text{TN}} + {\text{FP}}} \right)$$
$${\text{F1}}\,{\text{Score}} = {2}*\left( {{\text{Recall}}*{\text{Precision}}} \right)/\left( {{\text{Recall}} + {\text{Precision}}} \right)$$

4.1 ResNet-18 Result Analysis—Confusion Matrix

To get the confusion matrix and classification report import confusion matrix from sklearn (Figs. 11 and 12).

Fig. 11
figure 11

Confusion matrix with normalization

Fig. 12
figure 12

Confusion matrix without normalization

Classification Report

See Table 2.

Table 2 Testing data report

4.2 Resnet-50 Result Analysis—Confusion Matrix

See Figs. 13 and 14.

Fig. 13
figure 13

Confusion matrix with normalization

Fig. 14
figure 14

Confusion matrix without normalization

Classification Report

See Table 3.

Table 3 Testing data report

4.3 Comparison Between Two Models

See Table 4.

Table 4 Comparison between ResNet-18 and ResNet-50

5 Conclusion

In this paper, two models are proposed and compared for detection of COVID-19 along with different classes of pneumonia in order to have more accurate results. The proposed models are ResNet-18 and ResNet-50. The data sets are pre-processed in order to avoid the over fitting and under fitting problems. The ResNet-18 model achieved an accuracy of 91% and ResNet-50 model achieved an accuracy of 75% for same data set. By comparing these two, ResNet-18 model classifies more accurately.