Skip to content

Implementation of a pre-trained CNN for recognizing the covid-19 from chest X-Ray images with PyTorch library

Notifications You must be signed in to change notification settings

parham1998/Covid-19_Recognition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Covid-19_Recognition

Implementation of a pre-trained CNN for recognizing the covid-19 from chest X-Ray images with PyTorch library

coronaviruses

COVID-19
Coronaviruses are a large family of viruses that were discovered in the 1960s.
these diseases are naturally present in birds and mammals.
But so far, seven types of coronaviruses have been discovered that can be transmitted from person to person.
One of these coronaviruses that have recently affected the lives of the world is an acute respiratory syndrome or Covid-19.
The outbreak of the virus started in December 2019 in Wuhan, China, and within a few months, it became a global epidemic.

chest dataset

chest_dataset
One way to diagnose the disease is to have a chest scan. That is, the chest is photographed and the health of the lungs is carefully monitored. Naturally, we need data to diagnose corona with deep learning.
The corona-positive CT scan data set that we will use for this training was collected by Joseph Cohen, Ph.D., University of Montreal. For corona-negative data or normal samples, we use the Chest X-Ray Images database from the Kaggle site.
Eventually, we will have a database in which we can train a deep network.

code explanation

Prepare data:

At this part, I downloaded the dataset from kaggle site and Joseph Cohen's GitHub and separated them into train and test parts. I also made train.csv and test.csv to record images names and their corresponding labels. (if you don't want to change your train or test images, you can comment on this part)

Load data:

I wrote a ChestDataset class to load the images in the tensor format and used DataLoader to separate images into batches. (see image bellow)

sample

CNN model:

I've used the pre-trained VGG-16 network and changed the classifier part of the model for the binary classification problem. then trained the model on the aforementioned dataset. (see image bellow)

Screenshot (408)

hyperparameters:

loss function: binary cross entropy
optimizer: stochastic gradient descent

parameter value
batch-size 16
epoch 50
learning rate 0.01
momentum 0.9
weight_decay 0.0005

About

Implementation of a pre-trained CNN for recognizing the covid-19 from chest X-Ray images with PyTorch library

Topics

Resources

Stars

Watchers

Forks

Languages