Skip to content

Commit

Permalink
initial dints tutorials (Project-MONAI#449)
Browse files Browse the repository at this point in the history
* initialize dints tutorials

Signed-off-by: dongy <dongy@nvidia.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* update scripts

Signed-off-by: dongy <dongy@nvidia.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* update scripts

Signed-off-by: dongy <dongy@nvidia.com>

* update scripts

Signed-off-by: dongy <dongy@nvidia.com>

* Update README.md

* Update README.md

* update scripts

Signed-off-by: dongy <dongy@nvidia.com>

* Change Dints interface

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Modify scripts for new Dints interface

* update scripts

Signed-off-by: dongy <dongy@nvidia.com>

* update scripts

Signed-off-by: dongy <dongy@nvidia.com>

* update scripts

Signed-off-by: dongy <dongy@nvidia.com>

* update scripts

Signed-off-by: dongy <dongy@nvidia.com>

* Test push

* update scripts

Signed-off-by: dongy <dongy@nvidia.com>

* update scripts

Signed-off-by: dongy <dongy@nvidia.com>

* update scripts

Signed-off-by: dongy <dongy@nvidia.com>

* update readme

Signed-off-by: Dong Yang <dongy@dongy-mlt.client.nvidia.com>

* Add readme

* Update readme

* Change lr in search

* update readme

Signed-off-by: Dong Yang <dongy@dongy-mlt.client.nvidia.com>

* Enable single GPU

* update readme

Signed-off-by: Dong Yang <dongy@dongy-mlt.client.nvidia.com>

* Add visualization tutorial transform image  (Project-MONAI#448)

* [DLMED] add visualization tutorial

Signed-off-by: Nic Ma <nma@nvidia.com>

* [DLMED] add image

Signed-off-by: Nic Ma <nma@nvidia.com>

* [DLMED] update notebook

Signed-off-by: Nic Ma <nma@nvidia.com>

* [DLMED] update notebook

Signed-off-by: Nic Ma <nma@nvidia.com>

* [DLMED] add reference image

Signed-off-by: Nic Ma <nma@nvidia.com>

* [DLMED] fix PEP error

Signed-off-by: Nic Ma <nma@nvidia.com>

* Update spleen_segmentation_3d.ipynb (Project-MONAI#455)

The `pip install` statement is missing pytorch-ignite. Changing:
`!python -c "import monai" || pip install -q "monai-weekly[gdown, nibabel, tqdm]"`
to 
`!python -c "import monai" || pip install -q "monai-weekly[gdown, nibabel, tqdm, ignite]"`

* Figures added, pretrained weights link added, minor fixes (Project-MONAI#456)

* Figures added, pretrained weights link added, minor fixes

Signed-off-by: vnath <vnath@nvidia.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: vnath <vnath@nvidia.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Add itkwidgets example in notebook (Project-MONAI#454)

* [DLMED] add itkwidgets

Signed-off-by: Nic Ma <nma@nvidia.com>

* [DLMED] add reference screenshot

Signed-off-by: Nic Ma <nma@nvidia.com>

* [DLMED] update to PLS orientation

Signed-off-by: Nic Ma <nma@nvidia.com>

* MIL example (Project-MONAI#431)

* MIL example

Signed-off-by: myron <amyronenko@nvidia.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* mil tutorial update

Signed-off-by: myron <amyronenko@nvidia.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* mil tutorial update

Signed-off-by: myron <amyronenko@nvidia.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* small updates

Signed-off-by: myron <amyronenko@nvidia.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* updated images

Signed-off-by: myron <amyronenko@nvidia.com>

* gdown for json

Signed-off-by: myron <amyronenko@nvidia.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update README

Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>

* Fix formatting and typos

Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>

* small fixes

Signed-off-by: myron <amyronenko@nvidia.com>

* stats

Signed-off-by: myron <amyronenko@nvidia.com>

* pip install

Signed-off-by: myron <amyronenko@nvidia.com>

* README fixes

Signed-off-by: myron <amyronenko@nvidia.com>

Co-authored-by: am <am>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Co-authored-by: Nic Ma <nma@nvidia.com>

* 450 update AsDiscrete (Project-MONAI#451)

* update asdiscrete

Signed-off-by: Yiheng Wang <vennw@nvidia.com>

* update postprocessing figures

Signed-off-by: Yiheng Wang <vennw@nvidia.com>

* fix version error of mutual info

Signed-off-by: Yiheng Wang <vennw@nvidia.com>

* update to use include in torchin

Signed-off-by: Yiheng Wang <vennw@nvidia.com>

* 459 update nvidia flare 2.0 example (Project-MONAI#460)

* update nvidia flare 2.0 example

Signed-off-by: Yiheng Wang <vennw@nvidia.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* enhance code format

Signed-off-by: Yiheng Wang <vennw@nvidia.com>

* update folder and readme

Signed-off-by: Yiheng Wang <vennw@nvidia.com>

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Weights Link Updated (Project-MONAI#465)

Signed-off-by: vnath <vnath@nvidia.com>

Co-authored-by: vnath <vnath@nvidia.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fixes readme typos

Signed-off-by: Wenqi Li <wenqil@nvidia.com>

* update readmes

Signed-off-by: Wenqi Li <wenqil@nvidia.com>

* update readme

Signed-off-by: Wenqi Li <wenqil@nvidia.com>

* qa commit

Signed-off-by: Wenqi Li <wenqil@nvidia.com>

* link

Signed-off-by: Wenqi Li <wenqil@nvidia.com>

Co-authored-by: dongy <dongy@nvidia.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: heyufan1995 <heyufan1995@gmail.com>
Co-authored-by: Dong Yang <dongy@dongy-mlt.client.nvidia.com>
Co-authored-by: Nic Ma <nma@nvidia.com>
Co-authored-by: nvahmadi <85887144+nvahmadi@users.noreply.github.com>
Co-authored-by: Vishwesh <vishwesh.nath@gmail.com>
Co-authored-by: vnath <vnath@nvidia.com>
Co-authored-by: myron <myron@users.noreply.github.com>
Co-authored-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Co-authored-by: Yiheng Wang <68361391+yiheng-wang-nv@users.noreply.github.com>
Co-authored-by: Wenqi Li <wenqil@nvidia.com>
  • Loading branch information
13 people authored Dec 1, 2021
1 parent 38d1e47 commit 9b69852
Show file tree
Hide file tree
Showing 13 changed files with 1,514 additions and 3 deletions.
Binary file added automl/DiNTS/Figures/arch_ram-cost-0.8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added automl/DiNTS/Figures/search_space.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added automl/DiNTS/Figures/training_loss.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added automl/DiNTS/Figures/validation_metric.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 76 additions & 0 deletions automl/DiNTS/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Examples of DiNTS: Differentiable neural network topology search

In this tutorial, we present a novel neural architecture search algorithm for 3D medical image segmentation. The datasets used in this tutorial are Task07 Pancreas (CT images) and Task09 Spleen (CT images) from [Medical Segmentation Decathlon](http://medicaldecathlon.com/). The implementation is based on:

Yufan He, Dong Yang, Holger Roth, Can Zhao, Daguang Xu: "[DiNTS: Differentiable Neural Network Topology Search for 3D Medical Image Segmentation.](https://openaccess.thecvf.com/content/CVPR2021/papers/He_DiNTS_Differentiable_Neural_Network_Topology_Search_for_3D_Medical_Image_CVPR_2021_paper.pdf)" In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 5841-5850. 2021.

![0.8](./Figures/arch_ram-cost-0.8.png)
![space](./Figures/search_space.png)

## Requirements
The script is tested with:
- `Ubuntu 20.04` and `CUDA 11`
- The searching and training stage requires at least two 16GB GPUs.

## Dependencies and installation
### Download and install Nvidia PyTorch Docker
```bash
docker pull nvcr.io/nvidia/pytorch:21.10-py3
```
### Download the repository
```bash
git clone https://github.com/Project-MONAI/tutorials.git
```
### Run into Docker
```
sudo docker run -it --gpus all --pid=host --shm-size 16G -v /location/to/tutorials/automl/DiNTS/:/workspace/DiNTS/ nvcr.io/nvidia/pytorch:21.10-py3
```
### Install MONAI and dependencies
```bash
bash install.sh
```

## Data
[Spleen CT dataset](https://drive.google.com/drive/folders/1HqEgzS8BV2c7xYNrZdEAnrHk7osJJ--2) and [Pancreas MRI dataset](https://drive.google.com/drive/folders/1HqEgzS8BV2c7xYNrZdEAnrHk7osJJ--2)
from [Medical Segmentation Decathlon](http://medicaldecathlon.com/) is used. You can manually download it and save it to args.root. Otherwise, the script will automatic
download the dataset.

## Examples
The tutorial contains two stages: searching stage and training stage. An architecture is searched and saved into a `.pth` file using `search_dints.py`.
The searched architecture will be loaded by `train_dints.py` and re-trained for spleen segmentation.

Check all possible options:
```bash
cd ./DiNTS/
python search_dints.py -h
python train_dints.py -h
```

### Searching
- Add the following script to the commands of running into docker (optional)
```
-v /your_downloaded_data_root/Task07_Pancreas/:/workspace/data_msd/Task07_Pancreas/
```
- Change ``NUM_GPUS_PER_NODE`` to your number of GPUs.
- Run `bash search_dints.sh`

### Training
- Add the following script to the commands of running into docker (Optional)
```
-v /your_downloaded_data_root/Task09_Spleen/:/workspace/data_msd/Task09_Spleen/
```
- Change ``ARCH_CKPT`` to point to the architecture file (.pth) from the searching stage.
- Change ``NUM_GPUS_PER_NODE`` to your number of GPUs.
- Run `bash train_dints.sh`

Training loss and validation metric curves are shown as follows. The experiments utilized 8 NVIDIA A100 GPUs.

![training_loss](./Figures/training_loss.png)

![validation_metric](./Figures/validation_metric.png)

## Questions and bugs

- For questions relating to the use of MONAI, please use our [Discussions tab](https://github.com/Project-MONAI/MONAI/discussions) on the main repository of MONAI.
- For bugs relating to MONAI functionality, please create an issue on the [main repository](https://github.com/Project-MONAI/MONAI/issues).
- For bugs relating to the running of a tutorial, please create an issue in [this repository](https://github.com/Project-MONAI/Tutorials/issues).
Binary file added automl/DiNTS/arch_code.pth
Binary file not shown.
12 changes: 12 additions & 0 deletions automl/DiNTS/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
clear

pip install nibabel
pip install pandas

# Update pip
python -m pip install -U pip
# Install scikit-image
python -m pip install -U scikit-image

pip install git+https://github.com/Project-MONAI/MONAI#egg=monai
Loading

0 comments on commit 9b69852

Please sign in to comment.