Covid-19 Detection using Deep Learning Algorithms

Download Full-Text PDF Cite this Publication

Text Only Version

Covid-19 Detection using Deep Learning Algorithms

Lalith Kumar Gali


Computer Science and Engineering Mahindra Ecole Centrale, Hyderabad

Charith Gunadala Student, ECE SRM, AP

Rudra Varun


Computer Science and Engineering GRIET, Hyderabad

Abstract Today the pandemic COVID-19, has resulted across the world which is called as which infected millions of people. It is producing a massive outbreak in over 150 nations around the world, with serious health consequences. As a result, to diagnose 20 severe acute respiratory syndrome coronavirus 2, named as SARS CoV-2, which is responsible for coronavirus disease is crucial for both patients and doctors. In the nations where the laboratory kits are unavailable for testing, it is becoming even more critical. So, in order to detect COVID- 19 disease we have investigated a model that is built based on image processing and deep learning techniques. A COVID-19 infection can progress to pneumonia, which can be identified with a chest X-ray exam and treated according to that. As, the number of COVID-19 victims are increasing day by day this needs to be done very quickly. Here, we created a model with X-rays. The chest Computed Tomography (CT) COVID-19 images are collected first, and then the dataset [1] is loaded. We present point processing approaches, apply Image Augmentation, and then use CT scans to determine COVID-19 positivity or negativity (chest x-ray images). Image processing and deep learning approaches and implementations are used to achieve this.

KeywordsCovid, Deep learning, X-RAYS


    Humankind was confronted with an epidemic at the end of 2019, a severe acute respiratory syndrome coronavirus 2 which is named as SARS CoV-2, related to pneumonia, also known as coronavirus has impacted the lives of millions of people. First, the major COVID-19 disease originated from Wuhan, China and later spread to different parts of the world resulting in an epidemic. There were more than millions of people infected with COVID and confirmed deaths are in lakhs across the world. So, the research has begun in order to treat this virus accordingly and to detect it to start the treatment. Keeping in mind about the availability of the laboratory kits that are needed to test the disease i.e., it is not so easy to test everyone as we are lacking in the test kits, so we are introducing a model based on image processing and deep learning which aims to detect the patients whether they are infected with corona virus or not using the chest X-ray images. Although hospitals are expected to do rapid COVID-19 testing at the point of treatment, every country will not have access to the test kits that produce findings promptly. The cost of laboratory kits

    required for diagnosis is a significant concern while fighting the disease, especially in developing and undeveloped countries. We use chest x-ray images in order to detect the COVID-19, which is useful for many countries and hospitals which does not have the access to the laboratory kits. This is important because now we don't have any effective treatment, therefore accurate identification is essential. We anticipated that deep learning techniques may be used to automate the CT scan picture classification process. To identify CT scan pictures based on their attributes, we created a CNN model. This will assist shorten the time it takes to diagnose COVID- 19.


    People who are suspected of being infected with the COVID- 19 virus should find out if they are affected with covid as soon as possible so that they may get a proper treatment, isolate themselves, and warn their close connections. For a formal diagnosis of COVID-19, a laboratory test i.e., RT- PCR of nose and throat samples is necessary. This test needs to have specialized equipment and this test takes minimum of 24 hours to complete. It is not so accurate and we may need re-take another RT-PCR test in order to confirm the diagnosis. Because covid-19 is a respiratory disease, we can diagnose or a give an overview to the persons regarding COVID-19 symptoms using chest imaging rather than waiting for RT-PTR results. To identify CT scan pictures based on their attributes, we created a CNN model. This will assist shorten the time it takes to diagnose COVID-19. With an accuracy of 90 percent, a chest X-ray may correctly identify patients. Not every country and every person will have access to fast-turnaround test Kits. Taking into consideration the time it takes to diagnose and the cost of the laboratory kits used in the diagnosis of covid-19, we have constructed a model that uses image processing and deep learning to assess whether patients are infected with corona or not. Our main objective is to create a model to detect covid-19


    1. Data Augmentation

      By injecting random vibrations and perturbations to the original training samples, data augmentation comprises a wide range of strategies for generating "new" training samples. When we use data augmentation, we want to boost the model's generalizability. Our network may learn more robust characteristics since it is continually exposed to new copies of the input data that which has been significantly changed. We don't use data augmentation during testing and instead in most cases, you'll see a boost in testing accuracy at the price of a small loss in training accuracy. when you assess our trained network on raw testing data

      Fig.3.1- Sample Image Augmentation

      As data seldom follows such a beautiful, pure distribution in real-world applications, building a machine learning model on it might result in us reproducing the distribution perfectly. Instead, we may add some random values from a random distribution to jitter locations throughout the distribution to increase the generalizability of our classifier. This plot is not as flawless as the one on the left, despite the fact that it follows a fairly normal distribution. A model which is trained on this is improved, more recent data that is more likely to generalize to all data points not included in the training set. In the framework of computer vision, data augmentation makes sense. Using basic geometric transformations, we can extract augmented data from the original images Data augmentation is a highly natural and straightforward approach to employ for computer vision problems since a small amount of the alterations applied to an input image alters its appearance but has no effect on the class labels.

    2. Types of Data Augmentation

3.2.(1) The creation of a dataset and the expansion of an existing dataset.

Dataset generation or expansion is the first form of Data Augmentation. A significant quantity of training data may be required for machine learning algorithms, particularly neural networks. When the dataset is small and contains only a few photos. Then, from disc, load the original input image. Use a series of random translations, rotations, and other effects to transform the original picture at random. After the image has been transformed. Following this method, we will create a directory full of "new" images that are changed randomly to train with, all based on that one input image, it is a very simplistic example. Typically, there would be more than one image with tens or hundreds of them, and the aim now is to

convert the smaller batch into tens of thousands of pictures for training. It may be useful to study dataset expansion and dataset development in such circumstances. CNN cannot be trained on a small data and thn it is generalized to data it's never seen before or trained on.

Fig.3.2- Sample Image Augmentation type 1

3.2(2) In-place/on-the-fly Data Augmentation

In-place data augmentation, also known as on-the-fly data augmentation, is the second form of data augmentation. Keras specializes in Data Augmentation like this. Using this type of data augmentation, we want to ensure that the network which is once trained, encounters fresh variations of the data at each and every epoch.

There are only a few steps to take. The method of using in-place data augmentation is depicted in the diagram above

  1. The Image Data Generator is given a batch of photos to work with.

  2. To each image in the batch, the Image Data Generator performs a random sequence of translations, rotations, and other effects,

    3: After being randomly changed, the batch is returned to the caller function.

    When the model is being trained, the original input is intercepted by ImageDataGenerator class, which then randomly modifies it before returning it to the neural network for training.

    Image Data Generator accepts a batch of photos as input, randomly changes the batch of photos, and then in the example above, the Keras ImageDataGenerator does not deliver both the original batch and the modified data. But ImageDataGenerator class only returns data once it has been randomly modified.

    Fig.3- Sample Image Augmentation type 2


      Machine learning has a branch called deep learning that is rapidly changing our world. Deep learning is enabling

      everything from self-driving vehicles to speech recognition, it has become a prominent topic in both industry and academia, influencing practically all industries that deal with Machine Learning and Artificial Intelligence. "Deep learning (sometimes referred to as deep structured learning or hierarchical laming) is a type of machine learning method that is based on learning data representations rather than task- specific algorithms. There are three types of learning: supervised, semi-supervised, and unsupervised' Artificial Neural Networks with More Than 100 Layers are used to implement this field of Machine Learning. To train ANNs, deep learning needs a large amount of labelled data and a lot of computing power. Hundreds of hidden layers of Artificial Neural Networks are used in deep learning (ANN). There are various forms of ANNs for various contexts, which will be addressed further below. Over the years, deep learning has made significant progress in terms of accuracy, and it continues to do so. It will benefit us all if we can grasp its subtleties.

        1. Deep Learning's Evolution in HealthCare

          Healthcare: Deep learning is being increasingly frequently utilized in healthcare, and it is assisting in the resolution of a variety of issues for patients, hospitals, and the whole healthcare sector. Using data from millions of patient scans gathered by healthcare systems, Deep Neural Networks may be trained to provide radiological findings with high reliability, according to research. These developments will soon change the health-care environment, with Al-enabled expert systems and autonomous robot surgeons taking the place of doctors.

        2. Artificial Neural Network

          Artificial Neural Network describes a system where all the nodes called artificial neurons are interconnected, in which each of the node represents a single information processing unit. The nodes which are interconnected communicate with one another. The nodes communicate with one another and share data, each node receives data and processes it before sending it on to the next node. The operation is carried out using a function known as the Activation function. It converts input into output, where these can then be used as input for further

          Fig.4.1- Neural Networks Layers Example

        3. Convolutional Neural Networks (CNN)

      Deep learning models are a sort of computer system that can generate high-level characteristics from low-level attributes to learn a hierarchy of data, thus automating the feature development process. CNN is a machine learning technique that consists of numerous layers of processing including both linear and non-linear operators that are learnable, allowing it to

      automatically train and create high-level knowledge from low- level inputs. To mimic variants of multilayer perceptrons, a CNN employs a feed-forward artificial neural network, in which the neurons thar are individual are got tiled in such a way that they respond in the visual speed to overlapping regions, as seen in biological vision processes. As a result, these networks are commonly used in the identification of images and videos. CNNs have proved to be a useful class of models for understanding visual data in particular. In picture recognition, segmentation, detection, and retrieval, we provide cutting-edge outcomes. In other words, CNNs may beat hand-crafted features like SIFT and SURF on visual object identification tests when properly trained. Furthermore, changes in the inputs have been shown to be rather insensitive to CNNs. Computer hardware advancements in recent years (e.g., the Graphics Processing Unit have facilitated the use of convolutional neural networks in picture representation.

      Transfer Learning is the technique where the model learns from one type of problem and then learning is applied to solve a different problem but related one. We are transferring the knowledge of already existing model (which have 1000's of classes) to our current model. Here the features of each image i.e., the pixels are extracted by the pre-trained weights. They are fine tuned in the last layer that is how we get the maximum accuracy.

      Fig.4.2- Transfer Learning Example


        1. Use Case Diagram

          A use case diagram gives the graphical representation of how system will work which consists of actors, goals of actors expressed as use cases.

          Fig.5.1- Use Case Diagram

        2. Activity diagram

          An activity diagram looks like a flowchart that illustrates the action of information from one action to the next. It depicts the dynamic behavior of the system.

          Fig.5.2- Activity Diagram

        3. Class diagram

          A class diagram shows the structure of the system in terms of classes, attributes, operations and relationships among the classes.

          Fig.5.3- Activity Diagram

        4. Sequence diagram

          Sequence diagram specifies how and in what sequence each system process interacts with one another.

          Fig.5.4- Sequence Diagram

        5. Component diagram

          Component diagrams are used to represent a system's physical artefacts. This artefact does not include files, executables, libraries, or other similar items. Component diagrams are utilized throughout the implementation phase of application therefore their purpose is different. The component diagram depicts the general operation and other components of the theme detection process.

          Fig.5.5- Component Diagram

        6. Architecture

      Fig.5.6- Architecture Diagram

      We'll start by gathering the covid and normal datasets. Those X-ray pictures should be used as input layers. With ImageNet, we may utilize any of the three Pre-trained Models: ResNet50, VGG-16[2], and VGG-19. We're utilizing the VGG-16 architecture here. Pooling is done by 2*2 max pooling layers, which come after some of the conv. layers and are then followed by max pooling. ReLU is applied after the fully connected layer and the dropout layer. As a result, the model has been trained, and the X-ray has been categorized as normal or covid.

      Fig.5.7 Block Diagram


Our project is written in the Python programming language. We have used google Collab for our code's execution. Google Collab allows anyone to create, run and execute any python code We found googleCollab is easier on running with python technology.

6.1 Tech and Tools Used 6.1(1) Python

Python has an automatic memory management and a dynamic system type. Python interpreters are present in many operating systems. C Python and Python's leading implementation, is software open source and features a community-based development process along with virtually all its variants. C Python is run by the Python Software Foundation for nonprofit purposes. Python's science packages are abundant for data viewing, machine learning. Linguistic processing, complicated data analysis and more. All these qualities make Python a powerful scientific tool and a strong alternative for tools such as MATLAB As our project deals with the detection of covid using the deep learning techniques we are going to import the popular libraries and tools.

6.1.(2) Pandas

Pandas name derives from the phrase panel data,' a multidimensional structured data set econometric term. It is a library for processing and analyzing data. It is also known as "Python Data Analysis Library

6.1.(3) NumPy

NumPy is a software for general use. It provides high- performance. This is a critical package for python scientific computing, supported by massive multi-dimensional arrays and matrices, as well as an extensive library of high-level mathematical features

6.1.(4) Matplotlib

Matplotlib is a 2D plotting toolkit with a variety of hardcopy and interactive environments producing quality figures platforms

You can create plots, histograms, spectrums of power, bars, error charts, scatter plots and more using Matplotlib.

    1. Data Exploration and Pre-Processing

      Fig.6.1 Data Exploration and Pre-Processing

    2. Model Training

      Fig.6.2 Model Training

    3. CNN Model Construction

6.1.(5) TensorFlow

For all developers, TensorFlow is a framework for open-source ml which is easy to use. It's utilized in deep learning and profound learning. It has been developed to be a simple to grasp framework in Python programming language.

6.2 Modules

  1. Dataset Preparation: We have to collect datasets (nearly 100-150). We have to identify data sources, data could be in various formats.

  2. Understanding the Dataset: It includes classifying the datasets into different classes. The various formats of data must be classified.

  3. Building CNN:

  4. This design outperforms a fully connected feed forward neural network when it comes to picture categorization.

  5. Model Training: Deep learning and image processing models can be trained to benefit manufacturing processes in several ways. It as a dataset that is used to train an algorithm.

    6.6 Test Accuracy

    Fig.6.3 CNN Construction

    Fig.6.4 Test Accuracy


      Fig.7.1 Epochs and Accuracy

        1. Model Accuracy

          Confusion Matrix

          Predicted Positive

          Predicted Negative

          Actual Positive



          Actual Negative



          Accuracy- 90%


We created a model with a deep learning algorithm and image processing approach from CNN in this project. This model can categorize the images of the X-ray CT chest scans into covid positive or negative. The dataset is one of the issues we confront in this project. As we said, our dataset is small and we could not obtain a lot of pictures. We have therefore applied the picture enhancement idea to enhance model efficiency. This was done with the help of the Keras module image data generator. This project is primarily aimed at building a model which will detect automatically whether or not a person has a corona-virus with greater precision. The model's accuracy is great, and can be improved by getting more pictures. As we see now there is a situation in which not everyone can be tested since there is a lack of kits and the requirements are not sufficient. In some circumstances, although kits are available, Covid-19 testing are still extensive waiting periods. This will aid hospitals and many countries that cannot buy a test kit for testing. For this particular issue we have addressed with the proposed model in this paper.

    1. Results

Fig.7.2 Accuracy at each epoch


  1. Ba7o5crP?usp=sharing

  2. model/amp/

  3. nvlayersygg16.jpg&imgrefurl=https%63A%2F%2Fwww.geeksforgeek cnnmodel%2F&tbnid=CX;912BkUyHG6M&vet=12ahUKEwiryYnxk8 LxAhWvQ30KHbubBM EQMygAegUIARC8AQ.i&docid=KU&miKOYNamY9M&W=1501& h=660&q=vgg%2016&ved=2ahUKEwjryYnxk&LxAhWvQ30KHbub BMEQMygAegUIARCSAQ

Fig.7.3 Sample Test

Leave a Reply

Your email address will not be published. Required fields are marked *