COVID -19 Detector with VGG-19 Convolutional Neural Network

Krishna Patel
Oct 11 · 5 min read

Know your lungs to attest of COVID!!! (A compact real world deep learning project for beginners.)

COVID-19 Detector is a web application that solves some part of the current problem faced by the world of pandemic COVID -19 virus. It helps users like doctors for checking their lungs X-ray images. For this, they need to upload the photocopy or an image of the X-ray and the web application, and they will get the result where there is COVID-19 effect still exists in the lungs or not. It will also help to predict when the person has chances of having coronavirus.

Pre-requisites :

The necessary library for this project are:

  • Keras
  • TensorFlow
  • Pillow
  • Numpy
  • Sklearn
  • Matplotlib
  • OpenCV

What is VGG-19 Convolutional Neural Network?

Convolutional Neural Networks are specific deep neural networks that can process data with an input shape like a 2D matrix. Images are commonly represented as a 2D matrix, and CNN is beneficial when working with images. It scans images from top to bottom and left to right to extract essential features from the image and combine the extracted features to identify the images. It can manage images that have been translated, rotated, scaled, and change in perspective.

For this particular project, VGG -19, a type of CNN model is used, which is 19 weight layers consisting of 16 convolutional layers with 3 fully connected layers and the same 5 pooling layers.

The input is a 224 * 224 RGB image to VGG based convNet. The pre-processing layer takes the RGB image with pixel values in the range 0–255 and subtracts the mean image values computed over the entire ImageNet training collection. After pre-processing, the input images are passed through layers of weight. The training images are processed through a stack of convolutional layers.

The architecture of VGG-19:

Image for post
Image for post
Flowchart of COVID-19 Detector
  • The first two layers are convolutional layers with 3*3 filters, and the first two layers use 64 filters that result in 224*224*64. The filters are always 3*3 with a stride of 1.
  • Next is the pooling layer with max-pool of 2*2 size and stride 2, which reduces image size from 224*224*64 to 112*112*64.
  • This is preceded by 2 more convolution layers with 128 filters, which results in the new dimension of 112*112*128. Again pooling layer is applied, which changes the size to 56*56*128.
  • Two more convolution layers are added with 256 filters, each followed by a down-sampling layer, which reduces the size to 28*28*256.
  • There are two more stacks, each with 3 convolution layer is separated by a max-pool layer with 7*7*512 volume, which is flattened into a Fully Connected (FC) layer and followed by a softmax layer as output.

Building the python based project:

  1. We need to create a juypter file and import all the necessary packages
Image for post
Image for post

2. Load the dataset for training and validation and after it performing normalisation on it.

Image for post
Image for post

3. Now perform label binarizer for the target class

Image for post
Image for post

4. Now create the model and add layers

Image for post
Image for post

5. Configure the optimizer and compiler

6. Check the change in accuracy and the loss function with graph of graph

Image for post
Image for post
Image for post
Image for post

7. Evaluating the network on basis of different parameters

Image for post
Image for post

8. Testing the model

Image for post
Image for post

9. Visualize the predicted result with the confusion matrix

Image for post
Image for post

10. Save the model

Image for post
Image for post

Now integrating the model with GUI with the help of Flask

  1. Create app.py and import the model inside the file.
Image for post
Image for post

2. Now create the required functions for normalizing the given image and to predict the class.

Image for post
Image for post

3. Create two HTML pages inside the template folder. And run the app.py file.

Image for post
Image for post
Image for post
Image for post

Summary:

In this COVID-19 spread, I have to build a web application using a flask and deep learning project using python. This model depends on the dataset, so it might not be accurate to the different situations. The same concept can be extended to a wide variety of objects with a lot of training data and an effective network. The same concept can be extended to a wide variety of objects with a lot of training data and an effective network.

References:

https://www.kaggle.com/nabeelsajid917/covid-19-x-ray-10000-images

https://www.youtube.com/watch?v=ArPaAX_PhIs&list=PLkDaE6sCZn6Gl29AoE31iwdVwSG-KnDzF

https://www.coursera.org/learn/neural-networks-deep-learning/home/welcome

https://machinelearningmastery.com/save-load-machine-learning-models-python-scikit-learn/

View the project :

https://coronadetectorapp.herokuapp.com

Project Code :

https://github.com/kri25shna99/Corona-Detector-Web-App

Analytics Vidhya

Analytics Vidhya is a community of Analytics and Data…

Sign up for Analytics Vidhya News Bytes

By Analytics Vidhya

Latest news from Analytics Vidhya on our Hackathons and some of our best articles! Take a look

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Krishna Patel

Written by

Machine Learning Enthusiast | Dotnet Developer | Computer Science Engineer

Analytics Vidhya

Analytics Vidhya is a community of Analytics and Data Science professionals. We are building the next-gen data science ecosystem https://www.analyticsvidhya.com

Krishna Patel

Written by

Machine Learning Enthusiast | Dotnet Developer | Computer Science Engineer

Analytics Vidhya

Analytics Vidhya is a community of Analytics and Data Science professionals. We are building the next-gen data science ecosystem https://www.analyticsvidhya.com

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app