Brain Tumor Segmentation

Training and evaluation code for brain tumor segmentation on Flair MRI images

tumor_seg_example1 tumor_seg_example2

Recommended way of project installation is below.

Installation

  1. Install requirements

pip install -r requirements.txt

  1. Use it!

Data

You can download dataset from here.

Weights

You can download weights from Google Drive link. Also, you can convert this model to ONNX using transform_to_onnx.py script.

Weights&Biases logging

To use Weights&Biases you need to change train config file in trainer section. Example:

...
logger:
  - class_path: pytorch_lightning.loggers.WandbLogger
    init_args:
      name: tumor-segmentation-densevnet
      project: tumor-segmentation
      log_model: True
...

You need to change name to your own. During first setup wandb will ask you to insert your own credentials. You can get those from here.

Usage

Config

To train models you need to have only one config file:

Scripts

Script for training:

python train.py --config configs/train_config.yaml

IMPORTANT: all folders should be accessible to the user, which executes scripts.

If you want to disable logging. And to leave only standart TensorBoardLogger. Use this script:

python train.py --config configs/train_config.yaml --trainer.logger true

IMPORTANT: argument --trainer.logger must be set after --config.

Script for app evaluation:

python evalualte.py \
    --checkpoint-path /checkpoints/best_checkpoint.ckpt \
    --ct-path /data/ct_image.nii.gz \
    --device-type cuda

This scripts starts simple OpenCV app. In this app you can interactively check model result.

Built With

Authors