adapt to BundleWorkflow interface
Browse files- README.md +5 -5
- configs/evaluate.json +4 -2
- configs/inference.json +5 -3
- configs/metadata.json +4 -3
- configs/multi_gpu_evaluate.json +8 -4
- configs/multi_gpu_train.json +8 -4
- configs/train.json +6 -4
- docs/README.md +5 -5
README.md
CHANGED
|
@@ -72,13 +72,13 @@ For more details usage instructions, visit the [MONAI Bundle Configuration Page]
|
|
| 72 |
#### Execute training:
|
| 73 |
|
| 74 |
```
|
| 75 |
-
python -m monai.bundle run
|
| 76 |
```
|
| 77 |
|
| 78 |
#### Override the `train` config to execute multi-GPU training:
|
| 79 |
|
| 80 |
```
|
| 81 |
-
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run
|
| 82 |
```
|
| 83 |
|
| 84 |
Please note that the distributed training-related options depend on the actual running environment; thus, users may need to remove `--standalone`, modify `--nnodes`, or do some other necessary changes according to the machine used. For more details, please refer to [pytorch's official tutorial](https://pytorch.org/tutorials/intermediate/ddp_tutorial.html).
|
|
@@ -86,19 +86,19 @@ Please note that the distributed training-related options depend on the actual r
|
|
| 86 |
#### Override the `train` config to execute evaluation with the trained model:
|
| 87 |
|
| 88 |
```
|
| 89 |
-
python -m monai.bundle run
|
| 90 |
```
|
| 91 |
|
| 92 |
#### Override the `train` config and `evaluate` config to execute multi-GPU evaluation:
|
| 93 |
|
| 94 |
```
|
| 95 |
-
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run
|
| 96 |
```
|
| 97 |
|
| 98 |
#### Execute inference:
|
| 99 |
|
| 100 |
```
|
| 101 |
-
python -m monai.bundle run
|
| 102 |
```
|
| 103 |
|
| 104 |
#### Export checkpoint to TorchScript file:
|
|
|
|
| 72 |
#### Execute training:
|
| 73 |
|
| 74 |
```
|
| 75 |
+
python -m monai.bundle run --config_file configs/train.json
|
| 76 |
```
|
| 77 |
|
| 78 |
#### Override the `train` config to execute multi-GPU training:
|
| 79 |
|
| 80 |
```
|
| 81 |
+
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run --config_file "['configs/train.json','configs/multi_gpu_train.json']"
|
| 82 |
```
|
| 83 |
|
| 84 |
Please note that the distributed training-related options depend on the actual running environment; thus, users may need to remove `--standalone`, modify `--nnodes`, or do some other necessary changes according to the machine used. For more details, please refer to [pytorch's official tutorial](https://pytorch.org/tutorials/intermediate/ddp_tutorial.html).
|
|
|
|
| 86 |
#### Override the `train` config to execute evaluation with the trained model:
|
| 87 |
|
| 88 |
```
|
| 89 |
+
python -m monai.bundle run --config_file "['configs/train.json','configs/evaluate.json']"
|
| 90 |
```
|
| 91 |
|
| 92 |
#### Override the `train` config and `evaluate` config to execute multi-GPU evaluation:
|
| 93 |
|
| 94 |
```
|
| 95 |
+
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run --config_file "['configs/train.json','configs/evaluate.json','configs/multi_gpu_evaluate.json']"
|
| 96 |
```
|
| 97 |
|
| 98 |
#### Execute inference:
|
| 99 |
|
| 100 |
```
|
| 101 |
+
python -m monai.bundle run --config_file configs/inference.json
|
| 102 |
```
|
| 103 |
|
| 104 |
#### Export checkpoint to TorchScript file:
|
configs/evaluate.json
CHANGED
|
@@ -68,8 +68,10 @@
|
|
| 68 |
"summary_ops": "*"
|
| 69 |
}
|
| 70 |
],
|
| 71 |
-
"
|
| 72 |
-
"$setattr(torch.backends.cudnn, 'benchmark', True)"
|
|
|
|
|
|
|
| 73 |
"$@validate#evaluator.run()"
|
| 74 |
]
|
| 75 |
}
|
|
|
|
| 68 |
"summary_ops": "*"
|
| 69 |
}
|
| 70 |
],
|
| 71 |
+
"initialize": [
|
| 72 |
+
"$setattr(torch.backends.cudnn, 'benchmark', True)"
|
| 73 |
+
],
|
| 74 |
+
"run": [
|
| 75 |
"$@validate#evaluator.run()"
|
| 76 |
]
|
| 77 |
}
|
configs/inference.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
"$import glob",
|
| 4 |
"$import os"
|
| 5 |
],
|
| 6 |
-
"bundle_root": "
|
| 7 |
"output_dir": "$@bundle_root + '/eval'",
|
| 8 |
"dataset_dir": "/workspace/data/endoscopic_tool_dataset",
|
| 9 |
"datalist": "$list(sorted(glob.glob(os.path.join(@dataset_dir,'test', '*', '*[!seg].jpg'))))",
|
|
@@ -130,8 +130,10 @@
|
|
| 130 |
"postprocessing": "@postprocessing",
|
| 131 |
"val_handlers": "@handlers"
|
| 132 |
},
|
| 133 |
-
"
|
| 134 |
-
"$setattr(torch.backends.cudnn, 'benchmark', True)"
|
|
|
|
|
|
|
| 135 | |
| 136 |
]
|
| 137 |
}
|
|
|
|
| 3 |
"$import glob",
|
| 4 |
"$import os"
|
| 5 |
],
|
| 6 |
+
"bundle_root": ".",
|
| 7 |
"output_dir": "$@bundle_root + '/eval'",
|
| 8 |
"dataset_dir": "/workspace/data/endoscopic_tool_dataset",
|
| 9 |
"datalist": "$list(sorted(glob.glob(os.path.join(@dataset_dir,'test', '*', '*[!seg].jpg'))))",
|
|
|
|
| 130 |
"postprocessing": "@postprocessing",
|
| 131 |
"val_handlers": "@handlers"
|
| 132 |
},
|
| 133 |
+
"initialize": [
|
| 134 |
+
"$setattr(torch.backends.cudnn, 'benchmark', True)"
|
| 135 |
+
],
|
| 136 |
+
"run": [
|
| 137 | |
| 138 |
]
|
| 139 |
}
|
configs/metadata.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
| 1 |
{
|
| 2 |
"schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json",
|
| 3 |
-
"version": "0.4.
|
| 4 |
"changelog": {
|
|
|
|
| 5 |
"0.4.3": "update this bundle to support TensorRT convert",
|
| 6 |
"0.4.2": "support monai 1.2 new FlexibleUNet",
|
| 7 |
"0.4.1": "add name tag",
|
|
@@ -15,8 +16,8 @@
|
|
| 15 |
"0.0.1": "initialize the model package structure"
|
| 16 |
},
|
| 17 |
"monai_version": "1.2.0rc3",
|
| 18 |
-
"pytorch_version": "1.13.
|
| 19 |
-
"numpy_version": "1.22.
|
| 20 |
"optional_packages_version": {
|
| 21 |
"nibabel": "4.0.1",
|
| 22 |
"pytorch-ignite": "0.4.9"
|
|
|
|
| 1 |
{
|
| 2 |
"schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json",
|
| 3 |
+
"version": "0.4.4",
|
| 4 |
"changelog": {
|
| 5 |
+
"0.4.4": "adapt to BundleWorkflow interface",
|
| 6 |
"0.4.3": "update this bundle to support TensorRT convert",
|
| 7 |
"0.4.2": "support monai 1.2 new FlexibleUNet",
|
| 8 |
"0.4.1": "add name tag",
|
|
|
|
| 16 |
"0.0.1": "initialize the model package structure"
|
| 17 |
},
|
| 18 |
"monai_version": "1.2.0rc3",
|
| 19 |
+
"pytorch_version": "1.13.1",
|
| 20 |
+
"numpy_version": "1.22.2",
|
| 21 |
"optional_packages_version": {
|
| 22 |
"nibabel": "4.0.1",
|
| 23 |
"pytorch-ignite": "0.4.9"
|
configs/multi_gpu_evaluate.json
CHANGED
|
@@ -15,14 +15,18 @@
|
|
| 15 |
},
|
| 16 |
"validate#dataloader#sampler": "@validate#sampler",
|
| 17 |
"validate#handlers#1#_disabled_": "$dist.get_rank() > 0",
|
| 18 |
-
"
|
| 19 |
"$import torch.distributed as dist",
|
| 20 |
-
"$dist.init_process_group(backend='nccl')",
|
| 21 |
"$torch.cuda.set_device(@device)",
|
| 22 |
"$setattr(torch.backends.cudnn, 'benchmark', True)",
|
| 23 |
"$import logging",
|
| 24 |
-
"$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)"
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
"$dist.destroy_process_group()"
|
| 27 |
]
|
| 28 |
}
|
|
|
|
| 15 |
},
|
| 16 |
"validate#dataloader#sampler": "@validate#sampler",
|
| 17 |
"validate#handlers#1#_disabled_": "$dist.get_rank() > 0",
|
| 18 |
+
"initialize": [
|
| 19 |
"$import torch.distributed as dist",
|
| 20 |
+
"$dist.is_initialized() or dist.init_process_group(backend='nccl')",
|
| 21 |
"$torch.cuda.set_device(@device)",
|
| 22 |
"$setattr(torch.backends.cudnn, 'benchmark', True)",
|
| 23 |
"$import logging",
|
| 24 |
+
"$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)"
|
| 25 |
+
],
|
| 26 |
+
"run": [
|
| 27 |
+
"$@validate#evaluator.run()"
|
| 28 |
+
],
|
| 29 |
+
"finalize": [
|
| 30 |
"$dist.destroy_process_group()"
|
| 31 |
]
|
| 32 |
}
|
configs/multi_gpu_train.json
CHANGED
|
@@ -25,16 +25,20 @@
|
|
| 25 |
},
|
| 26 |
"validate#dataloader#sampler": "@validate#sampler",
|
| 27 |
"validate#evaluator#val_handlers": "$None if dist.get_rank() > 0 else @validate#handlers",
|
| 28 |
-
"
|
| 29 |
"$import torch.distributed as dist",
|
| 30 |
-
"$dist.init_process_group(backend='nccl')",
|
| 31 |
"$torch.cuda.set_device(@device)",
|
| 32 |
"$monai.utils.set_determinism(seed=123)",
|
| 33 |
"$setattr(torch.backends.cudnn, 'benchmark', True)",
|
| 34 |
"$import logging",
|
| 35 |
"$@train#trainer.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)",
|
| 36 |
-
"$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)"
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
"$dist.destroy_process_group()"
|
| 39 |
]
|
| 40 |
}
|
|
|
|
| 25 |
},
|
| 26 |
"validate#dataloader#sampler": "@validate#sampler",
|
| 27 |
"validate#evaluator#val_handlers": "$None if dist.get_rank() > 0 else @validate#handlers",
|
| 28 |
+
"initialize": [
|
| 29 |
"$import torch.distributed as dist",
|
| 30 |
+
"$dist.is_initialized() or dist.init_process_group(backend='nccl')",
|
| 31 |
"$torch.cuda.set_device(@device)",
|
| 32 |
"$monai.utils.set_determinism(seed=123)",
|
| 33 |
"$setattr(torch.backends.cudnn, 'benchmark', True)",
|
| 34 |
"$import logging",
|
| 35 |
"$@train#trainer.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)",
|
| 36 |
+
"$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)"
|
| 37 |
+
],
|
| 38 |
+
"run": [
|
| 39 |
+
"$@train#trainer.run()"
|
| 40 |
+
],
|
| 41 |
+
"finalize": [
|
| 42 |
"$dist.destroy_process_group()"
|
| 43 |
]
|
| 44 |
}
|
configs/train.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
| 5 |
"$import torch",
|
| 6 |
"$import numpy as np"
|
| 7 |
],
|
| 8 |
-
"bundle_root": "
|
| 9 |
"ckpt_dir": "$@bundle_root + '/models'",
|
| 10 |
"output_dir": "$@bundle_root + '/eval'",
|
| 11 |
"dataset_dir": "/workspace/data/endoscopic_tool_dataset",
|
|
@@ -274,9 +274,11 @@
|
|
| 274 |
"val_handlers": "@validate#handlers"
|
| 275 |
}
|
| 276 |
},
|
| 277 |
-
"
|
| 278 |
-
"$monai.utils.set_determinism(seed=
|
| 279 |
-
"$setattr(torch.backends.cudnn, 'benchmark', True)"
|
|
|
|
|
|
|
| 280 |
"$@train#trainer.run()"
|
| 281 |
]
|
| 282 |
}
|
|
|
|
| 5 |
"$import torch",
|
| 6 |
"$import numpy as np"
|
| 7 |
],
|
| 8 |
+
"bundle_root": ".",
|
| 9 |
"ckpt_dir": "$@bundle_root + '/models'",
|
| 10 |
"output_dir": "$@bundle_root + '/eval'",
|
| 11 |
"dataset_dir": "/workspace/data/endoscopic_tool_dataset",
|
|
|
|
| 274 |
"val_handlers": "@validate#handlers"
|
| 275 |
}
|
| 276 |
},
|
| 277 |
+
"initialize": [
|
| 278 |
+
"$monai.utils.set_determinism(seed=123)",
|
| 279 |
+
"$setattr(torch.backends.cudnn, 'benchmark', True)"
|
| 280 |
+
],
|
| 281 |
+
"run": [
|
| 282 |
"$@train#trainer.run()"
|
| 283 |
]
|
| 284 |
}
|
docs/README.md
CHANGED
|
@@ -65,13 +65,13 @@ For more details usage instructions, visit the [MONAI Bundle Configuration Page]
|
|
| 65 |
#### Execute training:
|
| 66 |
|
| 67 |
```
|
| 68 |
-
python -m monai.bundle run
|
| 69 |
```
|
| 70 |
|
| 71 |
#### Override the `train` config to execute multi-GPU training:
|
| 72 |
|
| 73 |
```
|
| 74 |
-
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run
|
| 75 |
```
|
| 76 |
|
| 77 |
Please note that the distributed training-related options depend on the actual running environment; thus, users may need to remove `--standalone`, modify `--nnodes`, or do some other necessary changes according to the machine used. For more details, please refer to [pytorch's official tutorial](https://pytorch.org/tutorials/intermediate/ddp_tutorial.html).
|
|
@@ -79,19 +79,19 @@ Please note that the distributed training-related options depend on the actual r
|
|
| 79 |
#### Override the `train` config to execute evaluation with the trained model:
|
| 80 |
|
| 81 |
```
|
| 82 |
-
python -m monai.bundle run
|
| 83 |
```
|
| 84 |
|
| 85 |
#### Override the `train` config and `evaluate` config to execute multi-GPU evaluation:
|
| 86 |
|
| 87 |
```
|
| 88 |
-
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run
|
| 89 |
```
|
| 90 |
|
| 91 |
#### Execute inference:
|
| 92 |
|
| 93 |
```
|
| 94 |
-
python -m monai.bundle run
|
| 95 |
```
|
| 96 |
|
| 97 |
#### Export checkpoint to TorchScript file:
|
|
|
|
| 65 |
#### Execute training:
|
| 66 |
|
| 67 |
```
|
| 68 |
+
python -m monai.bundle run --config_file configs/train.json
|
| 69 |
```
|
| 70 |
|
| 71 |
#### Override the `train` config to execute multi-GPU training:
|
| 72 |
|
| 73 |
```
|
| 74 |
+
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run --config_file "['configs/train.json','configs/multi_gpu_train.json']"
|
| 75 |
```
|
| 76 |
|
| 77 |
Please note that the distributed training-related options depend on the actual running environment; thus, users may need to remove `--standalone`, modify `--nnodes`, or do some other necessary changes according to the machine used. For more details, please refer to [pytorch's official tutorial](https://pytorch.org/tutorials/intermediate/ddp_tutorial.html).
|
|
|
|
| 79 |
#### Override the `train` config to execute evaluation with the trained model:
|
| 80 |
|
| 81 |
```
|
| 82 |
+
python -m monai.bundle run --config_file "['configs/train.json','configs/evaluate.json']"
|
| 83 |
```
|
| 84 |
|
| 85 |
#### Override the `train` config and `evaluate` config to execute multi-GPU evaluation:
|
| 86 |
|
| 87 |
```
|
| 88 |
+
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run --config_file "['configs/train.json','configs/evaluate.json','configs/multi_gpu_evaluate.json']"
|
| 89 |
```
|
| 90 |
|
| 91 |
#### Execute inference:
|
| 92 |
|
| 93 |
```
|
| 94 |
+
python -m monai.bundle run --config_file configs/inference.json
|
| 95 |
```
|
| 96 |
|
| 97 |
#### Export checkpoint to TorchScript file:
|