{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# MONAI Label with nnUNet-MONAI Bundle\n", "\n", "This notebook demonstrates how to use the MONAI Label with nnUNet-MONAI Bundle to perform active learning and Auto-Segmentation with the nnUNet-MONAI Bundle.\n", "\n", "## Start MONAI Label\n", "\n", "To start MONAI Label with the nnUNet-MONAI Bundle App, run the following command:\n", "\n", "```bash\n", " monailabel start_server --app nnunetmonaibundle --studies /home/maia-user/Tutorials/MAIA/Task09_Spleen/imagesTr --conf models Task09_Spleen_Bundle\n", "```\n", "\n", "and access the MONAI Label App at http://localhost:8000\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Train Task\n", "\n", "The Train Task requires the following parameters:\n", "\n", "- `max_epochs`: Total number of epochs to run\n", "- `tracking_uri`: MLFlow Tracking URI to monitor the training\n", "- `nnunet_plans_identifier`: nnUNet plans identifier, specific for the experiment (e.g. nnUNetPlans, nnUNetResEncUNetLPlans, nnUNetResEncUNetPlans)\n", "- `nnunet_planner_name`: nnUNet planner name, specific for the experiment (e.g. nnUNetPlanner, nnUNetPlannerResEnc, nnUNetPlannerResEncL)\n", "- `nnunet_root_folder`: Root folder where the nnUNet experiments are stored\n", "- `task_name`: nnUNet Task Name\n", "- `task_id`: nnUNet Task ID\n", "- `pymaia_config_file`: PyMaia configuration file (see [Prepare nnUNet ResEnc Training](MAIA.ipynb#Prepare-nnUNet-ResEnc-Training))\n", "\n", "Internally, the nnUNetBundle Train Task will run the following steps:\n", "\n", "1. [Prepare nnUNet Experiment](MAIA.ipynb#Prepare-nnUNet-Experiment)\n", "2. [nnUNet Plan and Preprocessing](MAIA.ipynb#nnUNet-Plan-and-Preprocessing)\n", "3. [nnUNet Training](MAIA.ipynb#nnUNet-Training)\n", "4. [Convert nnUNet MONAI Bundle to native nnUNet for Inference](MAIA.ipynb#Validation)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Inference Task\n", "\n", "\n", "The Auto-Segmentation action can be performed when a valid model is available in the MONAI Bundle `models` folder.\n", "\n", "A valid `model_folder` parameter should be specified in the `inference.yaml`file, referring to the nnUNet model folder directory (``), inside which the folds subdirectories with the model checkpoint are located:\n", "\n", "```plaintext\n", "model_folder/\n", "├── fold_0/\n", "│ ├── checkpoint_final.pth\n", "│ └── checkpoint_best.pth\n", "├── fold_1/\n", "│ ├── checkpoint_final.pth\n", "│ └── checkpoint_best.pth\n", "├── plans.json\n", "└── dataset.json\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Load existing nnUNet Model into nnUNet-MONAI Bundle\n", "\n", "\n", "To load an existing nnUNet trained model into the nnUNet-MONAI Bundle:\n", "\n", "```bash\n", "nnUNetv2_install_pretrained_model_from_zip --zip /path/to/nnUNet_pretrained_model.zip\n", "```\n", "and modify the corresponding `model_folder` parameter in the `inference.yaml` file.\n", "\n", "By default, the pretrained model will be extracted under the `$nnUNet_results` directory." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.12" } }, "nbformat": 4, "nbformat_minor": 4 }