From 61f295d201421c84c0650966486f74d83f57c378 Mon Sep 17 00:00:00 2001 From: Soumik Rakshit <19soumik.rakshit96@gmail.com> Date: Tue, 16 Jan 2024 12:00:25 +0000 Subject: [PATCH] update: add setup and intro --- .../monai/3d_brain_tumor_segmentation.ipynb | 58 ++++++++++++++++++- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/colabs/monai/3d_brain_tumor_segmentation.ipynb b/colabs/monai/3d_brain_tumor_segmentation.ipynb index c553b3e2..b0a6149f 100644 --- a/colabs/monai/3d_brain_tumor_segmentation.ipynb +++ b/colabs/monai/3d_brain_tumor_segmentation.ipynb @@ -1,12 +1,47 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Brain tumor 3D segmentation with MONAI and Weights & Biases\n", + "\n", + "This tutorial shows how to construct a training workflow of multi-labels segmentation task using [MONAI](https://github.com/Project-MONAI/MONAI) and use experiment tracking and data visualization features of [Weights & Biases](https://wandb.ai/site). The tutorial contains the following features:\n", + "\n", + "1. Initialize a Weights & Biases run and synchrozize all configs associated with the run for reproducibility.\n", + "2. MONAI transform API:\n", + " 1. MONAI Transforms for dictionary format data.\n", + " 2. How to define a new transform according to MONAI transform API.\n", + " 3. How to randomly adjust intensity for data augmentation.\n", + "3. Data Loading and Visualization:\n", + " 1. Load Nifti image with metadata, load a list of images and stack them.\n", + " 2. Cache IO and transforms to accelerate training and validation.\n", + " 3. Visualize the data using `wandb.Table` and interactive segmentation overlay on Weights & Biases.\n", + "4. Training a 3D `SegResNet` model\n", + " 1. Using the `networks`, `losses`, and `metrics` APIs from MONAI.\n", + " 2. Training the 3D `SegResNet` model using a PyTorch training loop.\n", + " 3. Track the training experiment using Weights & Biases.\n", + " 4. Log and version model checkpoints as model artifacts on Weights & Biases.\n", + "5. Visualize and compare the predictions on the validation dataset using `wandb.Table` and interactive segmentation overlay on Weights & Biases." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Setup and Installation\n", + "\n", + "First, let us install the latest version of both MONAI and Weights and Biases." + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "!pip install -q \"monai-weekly[nibabel, tqdm]\" wandb" + "!python -c \"import monai\" || pip install -q -U \"monai[nibabel, tqdm]\"\n", + "!python -c \"import wandb\" || pip install -q -U wandb" ] }, { @@ -24,6 +59,7 @@ "from monai.apps import DecathlonDataset\n", "from monai.data import DataLoader, decollate_batch\n", "from monai.losses import DiceLoss\n", + "from monai.config import print_config\n", "from monai.inferers import sliding_window_inference\n", "from monai.metrics import DiceMetric\n", "from monai.networks.nets import SegResNet\n", @@ -45,7 +81,25 @@ ")\n", "from monai.utils import set_determinism\n", "\n", - "import torch" + "import torch\n", + "\n", + "print_config()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We will then authenticate this colab instance to use W&B." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "wandb.login()" ] }, {