Skip to content

initial dints tutorials #449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 48 commits into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
163a008
initialize dints tutorials
Nov 19, 2021
ddf8392
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 19, 2021
1a1a58d
update scripts
Nov 22, 2021
f7473d0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 22, 2021
1ba684e
update scripts
Nov 22, 2021
85ee1a0
Merge branch 'master' of https://github.com/dongyang0122/tutorials
Nov 22, 2021
db1cafe
update scripts
Nov 22, 2021
981b303
Update README.md
dongyang0122 Nov 22, 2021
d98ca94
Update README.md
dongyang0122 Nov 22, 2021
3e820fd
update scripts
Nov 22, 2021
dcd4e10
Merge branch 'master' of https://github.com/dongyang0122/tutorials
Nov 22, 2021
0d3c8e7
Change Dints interface
heyufan1995 Nov 22, 2021
b8a3101
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 22, 2021
1981544
Merge branch 'master' of github.com:dongyang0122/tutorials
heyufan1995 Nov 22, 2021
2a5bb06
Modify scripts for new Dints interface
heyufan1995 Nov 22, 2021
fc2f277
Merge branch 'master' of github.com:dongyang0122/tutorials
heyufan1995 Nov 22, 2021
698a9a0
update scripts
Nov 23, 2021
4a44993
update scripts
Nov 24, 2021
8da5dc3
update scripts
Nov 30, 2021
2260ce2
update scripts
Nov 30, 2021
396c1ae
Test push
heyufan1995 Nov 30, 2021
5669d7b
update scripts
Nov 30, 2021
0a1cc78
update scripts
Nov 30, 2021
ee20f21
update scripts
Nov 30, 2021
3122caf
update readme
Nov 30, 2021
6ccdd50
Add readme
heyufan1995 Nov 30, 2021
51f3127
Merge branch 'master' of github.com:dongyang0122/tutorials
heyufan1995 Nov 30, 2021
79c9aab
Update readme
heyufan1995 Nov 30, 2021
d29f086
Change lr in search
heyufan1995 Dec 1, 2021
bdc759e
update readme
Dec 1, 2021
b2b1170
Enable single GPU
heyufan1995 Dec 1, 2021
1c72524
update readme
Dec 1, 2021
cf20e1d
Add visualization tutorial transform image (#448)
Nic-Ma Nov 22, 2021
03990f9
Update spleen_segmentation_3d.ipynb (#455)
nvahmadi Nov 24, 2021
1cb5a90
Figures added, pretrained weights link added, minor fixes (#456)
finalelement Nov 24, 2021
f573bec
Add itkwidgets example in notebook (#454)
Nic-Ma Nov 25, 2021
3f540b4
MIL example (#431)
myron Nov 25, 2021
829b8d5
450 update AsDiscrete (#451)
yiheng-wang-nv Nov 26, 2021
4422cab
459 update nvidia flare 2.0 example (#460)
yiheng-wang-nv Nov 30, 2021
cfbd3d2
Weights Link Updated (#465)
finalelement Dec 1, 2021
f3ea3c9
Merge remote-tracking branch 'upstream/master'
wyli Dec 1, 2021
a845545
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 1, 2021
e69a472
fixes readme typos
wyli Dec 1, 2021
cf5594e
Merge remote-tracking branch 'dong/master'
wyli Dec 1, 2021
6fb6b3e
update readmes
wyli Dec 1, 2021
76120b6
update readme
wyli Dec 1, 2021
7d82859
qa commit
wyli Dec 1, 2021
5cebe49
link
wyli Dec 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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