deephealthproject / use-case-pipelines

Use case pipelines based on EDDL and ECVL libraries. Different tasks (e.g. classification and segmentation) and datasets (e.g. MNIST, ISIC, and PNEUMOTHORAX) are taken into account.
Other
2 stars 5 forks source link
classification cpp ecvl eddl pneumothorax-segmentation python pytorch segmentation tensorflow

DH USE CASE Pipeline

Pipeline that uses EDDL and ECVL to train a CNN on five different datasets (MNIST, ISIC, PNEUMOTHORAX, MSSEG and DHUC11), applying different image augmentations, for both the classification and the segmentation task.

ECVL EDDL
1.0.3 1.0.4b

Requirements

Datasets

The YAML datasets format is described here. Each dataset listed below contains both the data and the YAML description format, but they can also be downloaded separately: ISIC classification, ISIC segmentation, Pneumothorax segmentation, Kidney segmentation, Kidney classification, Multiple Sclerosis Segmentation.

MNIST

Automatically downloaded and extracted by CMake.

ISIC - isic-archive.com

Classification: Download it from here and extract it. To run skin_lesion_classification you must provide the --dataset_path as /path/to/isic_classification.yml (section Training options list other settings). See Pretrained models section to download checkpoints.

_Classification2018: Download it from here and extract it. To run skin_lesion_classification_2018 you must provide the --dataset_path as /path/to/isic_classification_2018.yml.

Segmentation: Download it from here and extract it. To run skin_lesion_segmentation you must provide the the --dataset_path as /path/to/isic_segmentation.yml (section Training options list other settings). See Pretrained models section to download checkpoints.

PNEUMOTHORAX

Dataset taken from a kaggle challenge (more details here).

  1. Download training and test images here.
  2. Download from here ground truth masks and the YAML dataset file.
  3. In order to copy the ground truth masks in the directory of the corresponding images, edit the cpp/copy_ground_truth_pneumothorax.cpp file with the path to the downloaded dataset and ground truth directory and run it. Move the YAML file in the siim dataset folder.

    Short video in which these steps are shown.

From the 2669 distinct training images with mask, 200 are randomly sampled as validation set.

KIDNEY SEGMENTATION AND CLASSIFICATION

UC11 dataset, images cannot be provided publicly.

MULTIPLE SCLEROSIS LESION SEGMENTATION

Dataset of the MSSEG challenge which took place during MICCAI 2016 (https://portal.fli-iam.irisa.fr/msseg-challenge).

  1. Subscribe the challenge in order to dowload data here.
    1. Create the MSSEG directory (mkdir MSSEG)
    2. Download the Unprocessed training dataset from here and place the zip inside MSSEG.
    3. Download the Pre-processed training dataset from here and place the zip inside MSSEG.
  2. Download the script at https://raw.githubusercontent.com/deephealthproject/use_case_pipeline/3rd_hackathon/dataset/extract_data.sh, save it in MSSEG folder, and run it.
    cd ~
    mkdir MSSEG && cd MSSEG
    wget https://raw.githubusercontent.com/deephealthproject/use_case_pipeline/3rd_hackathon/dataset/extract_data.sh
    chmod +x extract_data.sh
    ./extract_data.sh
  3. Place the ms_segmentation.yaml and put it inside MSSEG directory.
    wget https://raw.githubusercontent.com/deephealthproject/use_case_pipeline/3rd_hackathon/dataset/ms_segmentation.yml

CUDA

On Linux systems, starting from CUDA 10.1, cuBLAS libraries are installed in the /usr/lib/<arch>-linux-gnu/ or /usr/lib64/. Create a symlink to resolve the issue:

sudo ln -s /usr/lib/<arch>-linux-gnu/libcublas.so /usr/local/cuda-10.1/lib64/libcublas.so

Building

N.B. EDDL is built for GPU by default.

Training and inference

The project creates different executables: MNIST_BATCH, MNIST_BATCH_FASTER, SKIN_LESION_CLASSIFICATION, SKIN_LESION_SEGMENTATION, PNEUMOTHORAX_SEGMENTATION, KIDNEY_SEGMENTATION, KIDNEY_CLASSIFICATION, MS_SEGMENTATION.

C++ Training options

-e, --epochs            Number of training epochs
-b, --batch_size        Number of images for each batch
-n, --num_classes       Number of output classes
-s, --size              Size to which resize the input images
--loss                  Loss function
-l, --learning_rate     Learning rate
--momentum              Momentum (default: 0.9)
--model                 Model of the network
-g, --gpu               Which GPUs to use. If not given, the network will run on CPU. (examples: --gpu 1 or --gpu=0,1 or --gpu=1,1)
--lsb                   How many batches are processed before synchronizing the model weights (default: 1)
-m, --mem               CS memory usage configuration (default: low_mem, other possibilities: mid_mem, full_mem)
--save_images           Save validation images or not (default: false)
-r, --result_dir        Directory where the output images will be stored (default: ../output_images)
--checkpoint_dir        Directory where the checkpoints will be stored (default: ../checkpoints)
-d, --dataset_path      Dataset path (mandatory - except for the mnist pipelines)
-c, --checkpoint        Path to the onnx checkpoint file
--exp_name              Experiment name
-i, --input_channels    Number of the network input channels
-w --workers            Number of parallel threads which produce tensors from images and labels
-q, --queue_ratio       Maximum queue size in which producers store samples will be: batch_size\*workers\*queue_ratio
--resume                Resume training from this epoch
-t, --skip_train        Skip training and perform only test (default: false)
--ensemble              Perform ensemble (only available for skin_lesion_segmentation)
-h, --help              Print usage

Pretrained models

Model Metric Validation Test ONNX
ISIC classification ResNet50 Accuracy 0.854 0.8394 download
ISIC classification 2018 ResNet152 Accuracy 0.887 0.896 download
Kidney segmentation UNet Dice 0.8786 0.8634 download
Kidney classification ResNet101 Accuracy 0.5545 0.6489 download
MS segmentation Nabla Dice 0.83 0.81 download
Model Metric Validation Test ONNX
ISIC segmentation DeepLabV3Plus MIoU 0.746 0.746 download
ISIC segmentation SegNet (BCE) MIoU 0.750 0.770 download
ISIC segmentation SegNet (Dice) MIoU 0.756 0.768 download
ISIC segmentation UNet++ MIoU 0.782 0.771 download
ISIC segmentation UNet MIoU 0.770 0.763 download
ISIC segmentation LinkNet (VGG) MIoU 0.770 0.752 download
ISIC segmentation LinkNet (ResNet101) MIoU 0.762 0.763 download
Ensemble ISIC segmentation MIoU 0.794 0.800