/covid19ct3d

COVID-19 Classification from 3D CT Images

Primary LanguagePythonMIT LicenseMIT

COVID-19 Classification from 3D CT Images

Tutorial on COVID-19 Classification from 3D CT Images.

An example of COVID-19 infected lung 3D CT image.

Install

Install covid19ct3d using pip `(for Python >=3.6)`
git clone https://github.com/reshalfahsi/covid19ct3d
cd covid19ct3d
pip install .

Use from Python

Training
import covid19ct3d
  
# set training parameters
epoch = 30  # epoch number
lr = 1e-2  # learning rate
augmentation = True # choose to do data augmentation
batchsize = 2 # training batch size
trainsize = "128 128 64" # training dataset size
train_path = "./dataset" # path to train dataset
train_save = "./model" # path to saved model
step_lr = 2 # set the epoch to drop learning rate

# perform training
covid19ct3d.train(epoch=epoch,
                  lr=lr,
                  augmentation=augmentation,
                  batchsize=batchsize,
                  trainsize=trainsize,
                  train_path=train_path,
                  train_save=train_save,
                  step_lr=step_lr
                  )
Prediction
import covid19ct3d
  
# set prediction parameters
predict_size = "128 128 64" # predict size
pth_path = './model/COVID19CT3D.pth' # path to the trained model
data_path = './dataset/CT-0/study_0100.nii.gz' # path to the dataset

# perform prediction
covid19ct3d.predict(predict_size=predict_size,
                    pth_path=pth_path,
                    data_path=data_path
                    )
Model Information
import covid19ct3d
  
covid19ct3d.info()

Use from CLI

Training
covid19ct3d train \
--epoch 30 \
--lr 1e-2 \
--batchsize 2 \
--trainsize "128 128 64" \
--train_path "./dataset" \
--train_save "./model" \
--augmentation

Prediction
covid19ct3d predict \
--predict_size "128 128 64" \
--pth_path "./model/COVID19CT3D.pth" \
--data_path "./dataset/CT-23/study_0982.nii.gz"

Model Information
covid19ct3d info

Credits