Distinguishing COVID-19 from Pneumonia of Other Origin at Chest CT Scan a Deep Learning approach.


Original Source Here

Distinguishing COVID-19 from Pneumonia of Other Origin at Chest CT Scan a Deep Learning approach.

Using CNN and Transfer Learning to classify CT Scan of COVID-19 Pneumonia and pneumonia of other origin in chest CT Scan.

Photo by Fusion Medical Animation on Unsplash

The corona virus disease is an infectious that primarily affects lungs. The COVID-19 and pneumonia of other etiology share similar CT scan characteristics, contributing to the challenges in differentiating them with high accuracy. Purpose is to establish and evaluate an artificial intelligence (AI) system in differentiating COVID-19 and other pneumonia on chest CT with AI assistance.

The use of AI and deep learning can help the radiologist in better diagnosis of the COVID-19.This can support the health care system and make the process run smoothly.

This AI assistance can help in area where there is unavailability of better radiologist and doctors.


● Distinguishing COVID-19 from normal lung or other lung diseases, such as lungs cancer, bacterial pneumonia, may be a major hurdle in controlling the current pandemic.

● Manual radiologist interpretation of chest CT for recognizing COVID-19 by its characteristic patterns that include peripheral ground-glass opacities, but unfortunately this measure often has low specificity.

● Therefore, an efficient classification method using neural network and transfer learning can give us better accuracy in classification of CT scan.

Dataset details

The dataset is obtained from kaggle and other open source platform and a proper combination of image and labels are created.

The data is having 4044 CT Scan images in .png format of covid-19 patient which is given a label of 1 and the CT – Scan of non-covid-19 patients given a label 0.

Class imbalance

● Data is imbalance and as it will give biased results so before model building we have to treat the imbalance of the data set. Using over Sampling technique called SMOTE.

● It is used to adjust the class distribution of data set and reduce the number of data point which will tend to produce biased training process.

Before SMOTE

Visualization of COVID and NON-COVID

From the image we can see that covid-19 ct scan has round glass opacities which is not seen in the non- covid patient ct.

From the image we can see that covid-19 ct scan has round glass opacities which is not seen in the non- covid patient ct.

Image transformation or data augmentation

Data Augmentation is very important to regularize our network and increase the size of our training set.

Data transformation techniques (rotation, flip, crop, etc…) that can change the images pixel values and bring more information from the images for better classification.

This forces the model to be more flexible with the large variation of object inside the image, regarding less of position, orientation, size and color.

Transformation done on training data

Division of data into training validation and testing

●The dataset is divided into training validation and testing.

●Number of images for training : 1488

●Number of images for validation : 496

●Number of images for testing :496

Convolution neural network (cnn)

  • CNN’s were first developed and used around the 1980s. The most that a CNN could do at that time was recognize handwritten digits. But now it has its application even in healthcare sector and saving lives.
  • Convolution neural network is a class of artificial neural network which mainly use convolution layers for generating feature map which can be used for image classification.
  • Image classification is the task of taking an input image and outputting a class or a probability of classes that best describes the image.
  • An image is nothing but a matrix of pixel values ranging from 0–255 where 0 means zero intensity (black) and 255 means high intensity or white.
  • There are mainly 2 types of image- gray scale, rgb image made from these pixel intensity value.
gray scale
rgb image

• Image which is given to a neural network for training is nothing but a matrix of number.

  • Different color in image is generated by combination of different pixel intensity values in R,B,G channel of an image.

How cnn works

Input Layer

convolution layer

  • The convolution layer that gives the network its name performs an operation called “convolution
  • A dot product is performed in this convolution between input and filter, which is then summed.
  • This operation gives feature map which highlight edges and corners of the image.
  • This convolved image is passed to an activation function.


Activation function

• The activation function is a non-linear transformation that we do over the convolved image.

• The purpose of the activation function is to introduce non-linearity into the output of a neuron .

• There are many types of activation functions like sigmoid, softmax, relu which help to learn complex pattern in the data.

Pooling layer

  • The relu feature map goes to the pooling layer. Pooling is a down sampling operation that reduces the dimensionality of the feature map.
  • Pooling layer uses different filters to indentify different parts of image like edges, corners, body, eye etc.


•The pooled feature map is flattened into a single long continuous linear vectors of dimension n x 1.

  • The value of n depend on the dimension of the pooled feature map. Here 2×2 matrix is convert 4×1 matrix.

Fully connected layer

●There are multiple convolution, Relu and Pooling layers connected one after other that carry out feature extraction in every layer.

●The pooled feature map is flattened into a single long continuous linear vectors of dimension 1xn.

●The flattened matrix is fed as an input to a fully connected layer to classify the image.

Model architecture

Transfer Learning Model

Training deep learning model

●The training of the model is done at a learning rate of 0.001 and the cross entropy loss function is used for calculating loss.

●The optimizer used in the training is Adam optimizer and dataset is divided in no of batches for increasing the speed of the training process.

●The training is done for 20 and 40 epochs and loss is calculated for each epochs.

Training loss

●It can be seen from the below plot that the mean of training loss tend to decrease in the initial stage of training and then the loss values becomes constant after 20 epochs.

●So for final model the training is done for 20 epochs and model is given to the validation.

Training loss for 40 epoch
Training loss for 20 epochs


● Compared with results from both the model the model with 20 epochs has accuracy of 67% whereas the model with 40 epochs has accuracy of 73%.

●So, for the model which is trained for 20 epoch is chosen as the final model and can be further used for classification of covid and non covid ct scan images of patient.

●Assisted by the probabilities of the model, the radiologists achieved a higher average accuracy in classifiaction.


❏ Artificial intelligence (AI) has shown efficacy in differentiating COVID-19 from pneumonia of other origin at chest CT, yet the practical application of AI to radiologists COVID-19 diagnostic workflow has not been explored.

❏ The diagnostic accuracy produced by manual interpretation of COVID-19 chest CT scans is good but needs to be improved to make resource allocation and disease management during the current pandemic less strenuous on health care systems and economies worldwide.

❏ In poor country like India where 60% of its population lives in village with lack of good radiological lab and good doctors this AI system can be used to give a help to people and save lives.

❏ This model is prepared with less amount of data and we can collaborate with the union/state government to give us the data of CT-scan and improve the model performance and decrease the load on doctors and health care system of our country.



Trending AI/ML Article Identified & Digested via Granola by Ramsey Elbasheer; a Machine-Driven RSS Bot

%d bloggers like this: