adapt to BundleWorkflow interface
Browse files- README.md +6 -6
- configs/evaluate.json +4 -2
- configs/inference.json +5 -3
- configs/metadata.json +4 -3
- configs/multi_gpu_train.json +8 -4
- configs/train.json +5 -3
- docs/README.md +6 -6
README.md
CHANGED
|
@@ -95,13 +95,13 @@ Execute training:
|
|
| 95 |
- Run first stage
|
| 96 |
|
| 97 |
```
|
| 98 |
-
python -m monai.bundle run
|
| 99 |
```
|
| 100 |
|
| 101 |
- Run second stage
|
| 102 |
|
| 103 |
```
|
| 104 |
-
python -m monai.bundle run
|
| 105 |
```
|
| 106 |
|
| 107 |
Override the `train` config to execute multi-GPU training:
|
|
@@ -109,25 +109,25 @@ Override the `train` config to execute multi-GPU training:
|
|
| 109 |
- Run first stage
|
| 110 |
|
| 111 |
```
|
| 112 |
-
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run
|
| 113 |
```
|
| 114 |
|
| 115 |
- Run second stage
|
| 116 |
|
| 117 |
```
|
| 118 |
-
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run
|
| 119 |
```
|
| 120 |
|
| 121 |
Override the `train` config to execute evaluation with the trained model:
|
| 122 |
|
| 123 |
```
|
| 124 |
-
python -m monai.bundle run
|
| 125 |
```
|
| 126 |
|
| 127 |
### Execute inference
|
| 128 |
|
| 129 |
```
|
| 130 |
-
python -m monai.bundle run
|
| 131 |
```
|
| 132 |
|
| 133 |
# Disclaimer
|
|
|
|
| 95 |
- Run first stage
|
| 96 |
|
| 97 |
```
|
| 98 |
+
python -m monai.bundle run --config_file configs/train.json --network_def#pretrained_url `PRETRAIN_MODEL_URL` --stage 0
|
| 99 |
```
|
| 100 |
|
| 101 |
- Run second stage
|
| 102 |
|
| 103 |
```
|
| 104 |
+
python -m monai.bundle run --config_file configs/train.json --network_def#freeze_encoder false --network_def#pretrained_url None --stage 1
|
| 105 |
```
|
| 106 |
|
| 107 |
Override the `train` config to execute multi-GPU training:
|
|
|
|
| 109 |
- Run first stage
|
| 110 |
|
| 111 |
```
|
| 112 |
+
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run --config_file "['configs/train.json','configs/multi_gpu_train.json']" --train#dataloader#batch_size 8 --network_def#freeze_encoder true --network_def#pretrained_url `PRETRAIN_MODEL_URL` --stage 0
|
| 113 |
```
|
| 114 |
|
| 115 |
- Run second stage
|
| 116 |
|
| 117 |
```
|
| 118 |
+
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run --config_file "['configs/train.json','configs/multi_gpu_train.json']" --train#dataloader#batch_size 4 --network_def#freeze_encoder false --network_def#pretrained_url None --stage 1
|
| 119 |
```
|
| 120 |
|
| 121 |
Override the `train` config to execute evaluation with the trained model:
|
| 122 |
|
| 123 |
```
|
| 124 |
+
python -m monai.bundle run --config_file "['configs/train.json','configs/evaluate.json']"
|
| 125 |
```
|
| 126 |
|
| 127 |
### Execute inference
|
| 128 |
|
| 129 |
```
|
| 130 |
+
python -m monai.bundle run --config_file configs/inference.json
|
| 131 |
```
|
| 132 |
|
| 133 |
# Disclaimer
|
configs/evaluate.json
CHANGED
|
@@ -31,8 +31,10 @@
|
|
| 31 |
"summary_ops": "*"
|
| 32 |
}
|
| 33 |
],
|
| 34 |
-
"
|
| 35 |
-
"$setattr(torch.backends.cudnn, 'benchmark', True)"
|
|
|
|
|
|
|
| 36 |
"$@validate#evaluator.run()"
|
| 37 |
]
|
| 38 |
}
|
|
|
|
| 31 |
"summary_ops": "*"
|
| 32 |
}
|
| 33 |
],
|
| 34 |
+
"initialize": [
|
| 35 |
+
"$setattr(torch.backends.cudnn, 'benchmark', True)"
|
| 36 |
+
],
|
| 37 |
+
"run": [
|
| 38 |
"$@validate#evaluator.run()"
|
| 39 |
]
|
| 40 |
}
|
configs/inference.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
"$import glob",
|
| 4 |
"$import os"
|
| 5 |
],
|
| 6 |
-
"bundle_root": "
|
| 7 |
"output_dir": "$os.path.join(@bundle_root, 'eval')",
|
| 8 |
"dataset_dir": "/workspace/Data/Pathology/CoNSeP/Test/Images",
|
| 9 |
"num_cpus": 2,
|
|
@@ -144,8 +144,10 @@
|
|
| 144 |
"inferer": "@inferer",
|
| 145 |
"amp": true
|
| 146 |
},
|
| 147 |
-
"
|
| 148 |
-
"$setattr(torch.backends.cudnn, 'benchmark', True)"
|
|
|
|
|
|
|
| 149 | |
| 150 |
]
|
| 151 |
}
|
|
|
|
| 3 |
"$import glob",
|
| 4 |
"$import os"
|
| 5 |
],
|
| 6 |
+
"bundle_root": ".",
|
| 7 |
"output_dir": "$os.path.join(@bundle_root, 'eval')",
|
| 8 |
"dataset_dir": "/workspace/Data/Pathology/CoNSeP/Test/Images",
|
| 9 |
"num_cpus": 2,
|
|
|
|
| 144 |
"inferer": "@inferer",
|
| 145 |
"amp": true
|
| 146 |
},
|
| 147 |
+
"initialize": [
|
| 148 |
+
"$setattr(torch.backends.cudnn, 'benchmark', True)"
|
| 149 |
+
],
|
| 150 |
+
"run": [
|
| 151 | |
| 152 |
]
|
| 153 |
}
|
configs/metadata.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
| 1 |
{
|
| 2 |
"schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_hovernet_20221124.json",
|
| 3 |
-
"version": "0.1.
|
| 4 |
"changelog": {
|
|
|
|
| 5 |
"0.1.3": "add name tag",
|
| 6 |
"0.1.2": "update the workflow figure",
|
| 7 |
"0.1.1": "update to use monai 1.1.0",
|
| 8 |
"0.1.0": "complete the model package"
|
| 9 |
},
|
| 10 |
-
"monai_version": "1.
|
| 11 |
-
"pytorch_version": "1.13.
|
| 12 |
"numpy_version": "1.22.2",
|
| 13 |
"optional_packages_version": {
|
| 14 |
"scikit-image": "0.19.3",
|
|
|
|
| 1 |
{
|
| 2 |
"schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_hovernet_20221124.json",
|
| 3 |
+
"version": "0.1.4",
|
| 4 |
"changelog": {
|
| 5 |
+
"0.1.4": "adapt to BundleWorkflow interface",
|
| 6 |
"0.1.3": "add name tag",
|
| 7 |
"0.1.2": "update the workflow figure",
|
| 8 |
"0.1.1": "update to use monai 1.1.0",
|
| 9 |
"0.1.0": "complete the model package"
|
| 10 |
},
|
| 11 |
+
"monai_version": "1.2.0rc3",
|
| 12 |
+
"pytorch_version": "1.13.1",
|
| 13 |
"numpy_version": "1.22.2",
|
| 14 |
"optional_packages_version": {
|
| 15 |
"scikit-image": "0.19.3",
|
configs/multi_gpu_train.json
CHANGED
|
@@ -24,13 +24,17 @@
|
|
| 24 |
},
|
| 25 |
"validate#dataloader#sampler": "@validate#sampler",
|
| 26 |
"validate#evaluator#val_handlers": "$None if dist.get_rank() > 0 else @validate#handlers",
|
| 27 |
-
"
|
| 28 |
"$import torch.distributed as dist",
|
| 29 |
-
"$dist.init_process_group(backend='nccl')",
|
| 30 |
"$torch.cuda.set_device(@device)",
|
| 31 |
"$monai.utils.set_determinism(seed=321)",
|
| 32 |
-
"$setattr(torch.backends.cudnn, 'benchmark', True)"
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
"$dist.destroy_process_group()"
|
| 35 |
]
|
| 36 |
}
|
|
|
|
| 24 |
},
|
| 25 |
"validate#dataloader#sampler": "@validate#sampler",
|
| 26 |
"validate#evaluator#val_handlers": "$None if dist.get_rank() > 0 else @validate#handlers",
|
| 27 |
+
"initialize": [
|
| 28 |
"$import torch.distributed as dist",
|
| 29 |
+
"$dist.is_initialized() or dist.init_process_group(backend='nccl')",
|
| 30 |
"$torch.cuda.set_device(@device)",
|
| 31 |
"$monai.utils.set_determinism(seed=321)",
|
| 32 |
+
"$setattr(torch.backends.cudnn, 'benchmark', True)"
|
| 33 |
+
],
|
| 34 |
+
"run": [
|
| 35 |
+
"$@train#trainer.run()"
|
| 36 |
+
],
|
| 37 |
+
"finalize": [
|
| 38 |
"$dist.destroy_process_group()"
|
| 39 |
]
|
| 40 |
}
|
configs/train.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
"$import os",
|
| 5 |
"$import skimage"
|
| 6 |
],
|
| 7 |
-
"bundle_root": "
|
| 8 |
"ckpt_dir_stage0": "$os.path.join(@bundle_root, 'models', 'stage0')",
|
| 9 |
"ckpt_dir_stage1": "$os.path.join(@bundle_root, 'models')",
|
| 10 |
"ckpt_path_stage0": "$os.path.join(@ckpt_dir_stage0, 'model.pt')",
|
|
@@ -517,9 +517,11 @@
|
|
| 517 |
"amp": "@amp"
|
| 518 |
}
|
| 519 |
},
|
| 520 |
-
"
|
| 521 |
"$monai.utils.set_determinism(seed=321)",
|
| 522 |
-
"$setattr(torch.backends.cudnn, 'benchmark', True)"
|
|
|
|
|
|
|
| 523 |
"$@train#trainer.run()"
|
| 524 |
]
|
| 525 |
}
|
|
|
|
| 4 |
"$import os",
|
| 5 |
"$import skimage"
|
| 6 |
],
|
| 7 |
+
"bundle_root": ".",
|
| 8 |
"ckpt_dir_stage0": "$os.path.join(@bundle_root, 'models', 'stage0')",
|
| 9 |
"ckpt_dir_stage1": "$os.path.join(@bundle_root, 'models')",
|
| 10 |
"ckpt_path_stage0": "$os.path.join(@ckpt_dir_stage0, 'model.pt')",
|
|
|
|
| 517 |
"amp": "@amp"
|
| 518 |
}
|
| 519 |
},
|
| 520 |
+
"initialize": [
|
| 521 |
"$monai.utils.set_determinism(seed=321)",
|
| 522 |
+
"$setattr(torch.backends.cudnn, 'benchmark', True)"
|
| 523 |
+
],
|
| 524 |
+
"run": [
|
| 525 |
"$@train#trainer.run()"
|
| 526 |
]
|
| 527 |
}
|
docs/README.md
CHANGED
|
@@ -88,13 +88,13 @@ Execute training:
|
|
| 88 |
- Run first stage
|
| 89 |
|
| 90 |
```
|
| 91 |
-
python -m monai.bundle run
|
| 92 |
```
|
| 93 |
|
| 94 |
- Run second stage
|
| 95 |
|
| 96 |
```
|
| 97 |
-
python -m monai.bundle run
|
| 98 |
```
|
| 99 |
|
| 100 |
Override the `train` config to execute multi-GPU training:
|
|
@@ -102,25 +102,25 @@ Override the `train` config to execute multi-GPU training:
|
|
| 102 |
- Run first stage
|
| 103 |
|
| 104 |
```
|
| 105 |
-
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run
|
| 106 |
```
|
| 107 |
|
| 108 |
- Run second stage
|
| 109 |
|
| 110 |
```
|
| 111 |
-
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run
|
| 112 |
```
|
| 113 |
|
| 114 |
Override the `train` config to execute evaluation with the trained model:
|
| 115 |
|
| 116 |
```
|
| 117 |
-
python -m monai.bundle run
|
| 118 |
```
|
| 119 |
|
| 120 |
### Execute inference
|
| 121 |
|
| 122 |
```
|
| 123 |
-
python -m monai.bundle run
|
| 124 |
```
|
| 125 |
|
| 126 |
# Disclaimer
|
|
|
|
| 88 |
- Run first stage
|
| 89 |
|
| 90 |
```
|
| 91 |
+
python -m monai.bundle run --config_file configs/train.json --network_def#pretrained_url `PRETRAIN_MODEL_URL` --stage 0
|
| 92 |
```
|
| 93 |
|
| 94 |
- Run second stage
|
| 95 |
|
| 96 |
```
|
| 97 |
+
python -m monai.bundle run --config_file configs/train.json --network_def#freeze_encoder false --network_def#pretrained_url None --stage 1
|
| 98 |
```
|
| 99 |
|
| 100 |
Override the `train` config to execute multi-GPU training:
|
|
|
|
| 102 |
- Run first stage
|
| 103 |
|
| 104 |
```
|
| 105 |
+
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run --config_file "['configs/train.json','configs/multi_gpu_train.json']" --train#dataloader#batch_size 8 --network_def#freeze_encoder true --network_def#pretrained_url `PRETRAIN_MODEL_URL` --stage 0
|
| 106 |
```
|
| 107 |
|
| 108 |
- Run second stage
|
| 109 |
|
| 110 |
```
|
| 111 |
+
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run --config_file "['configs/train.json','configs/multi_gpu_train.json']" --train#dataloader#batch_size 4 --network_def#freeze_encoder false --network_def#pretrained_url None --stage 1
|
| 112 |
```
|
| 113 |
|
| 114 |
Override the `train` config to execute evaluation with the trained model:
|
| 115 |
|
| 116 |
```
|
| 117 |
+
python -m monai.bundle run --config_file "['configs/train.json','configs/evaluate.json']"
|
| 118 |
```
|
| 119 |
|
| 120 |
### Execute inference
|
| 121 |
|
| 122 |
```
|
| 123 |
+
python -m monai.bundle run --config_file configs/inference.json
|
| 124 |
```
|
| 125 |
|
| 126 |
# Disclaimer
|