monai
medical
katielink commited on
Commit
0238d7d
·
1 Parent(s): bd4bc85

adapt to BundleWorkflow interface

Browse files
README.md CHANGED
@@ -76,24 +76,24 @@ For more details usage instructions, visit the [MONAI Bundle Configuration Page]
76
 
77
  #### Execute training:
78
  ```
79
- python -m monai.bundle run training --meta_file configs/metadata.json --config_file configs/train.json --logging_file configs/logging.conf
80
  ```
81
 
82
  #### Override the `train` config to execute multi-GPU training:
83
  ```
84
- torchrun --standalone --nnodes=1 --nproc_per_node=8 -m monai.bundle run training --meta_file configs/metadata.json --config_file "['configs/train.json','configs/multi_gpu_train.json']" --logging_file configs/logging.conf
85
  ```
86
 
87
  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).
88
 
89
  #### Override the `train` config to execute evaluation with the trained model:
90
  ```
91
- python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file "['configs/train.json','configs/evaluate.json']" --logging_file configs/logging.conf
92
  ```
93
 
94
  #### Execute inference:
95
  ```
96
- python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file configs/inference.json --logging_file configs/logging.conf
97
  ```
98
 
99
  # References
 
76
 
77
  #### Execute training:
78
  ```
79
+ python -m monai.bundle run --config_file configs/train.json
80
  ```
81
 
82
  #### Override the `train` config to execute multi-GPU training:
83
  ```
84
+ torchrun --standalone --nnodes=1 --nproc_per_node=8 -m monai.bundle run --config_file "['configs/train.json','configs/multi_gpu_train.json']"
85
  ```
86
 
87
  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).
88
 
89
  #### Override the `train` config to execute evaluation with the trained model:
90
  ```
91
+ python -m monai.bundle run --config_file "['configs/train.json','configs/evaluate.json']"
92
  ```
93
 
94
  #### Execute inference:
95
  ```
96
+ python -m monai.bundle run --config_file configs/inference.json
97
  ```
98
 
99
  # References
configs/evaluate.json CHANGED
@@ -85,8 +85,10 @@
85
  "summary_ops": "*"
86
  }
87
  ],
88
- "evaluating": [
89
- "$setattr(torch.backends.cudnn, 'benchmark', True)",
 
 
90
  "$@validate#evaluator.run()"
91
  ]
92
  }
 
85
  "summary_ops": "*"
86
  }
87
  ],
88
+ "initialize": [
89
+ "$setattr(torch.backends.cudnn, 'benchmark', True)"
90
+ ],
91
+ "run": [
92
  "$@validate#evaluator.run()"
93
  ]
94
  }
configs/inference.json CHANGED
@@ -35,7 +35,8 @@
35
  "transforms": [
36
  {
37
  "_target_": "LoadImaged",
38
- "keys": "image"
 
39
  },
40
  {
41
  "_target_": "NormalizeIntensityd",
@@ -129,8 +130,10 @@
129
  "val_handlers": "@handlers",
130
  "amp": true
131
  },
132
- "evaluating": [
133
- "$setattr(torch.backends.cudnn, 'benchmark', True)",
 
 
134
135
  ]
136
  }
 
35
  "transforms": [
36
  {
37
  "_target_": "LoadImaged",
38
+ "keys": "image",
39
+ "image_only": false
40
  },
41
  {
42
  "_target_": "NormalizeIntensityd",
 
130
  "val_handlers": "@handlers",
131
  "amp": true
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.3.9",
4
  "changelog": {
 
5
  "0.3.9": "black autofix format and add name tag",
6
  "0.3.8": "modify dataset key name",
7
  "0.3.7": "restructure readme to match updated template",
@@ -17,9 +18,9 @@
17
  "0.1.1": "update for MetaTensor",
18
  "0.1.0": "complete the model package"
19
  },
20
- "monai_version": "1.0.1",
21
- "pytorch_version": "1.13.0",
22
- "numpy_version": "1.22.4",
23
  "optional_packages_version": {
24
  "nibabel": "4.0.1",
25
  "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.0",
4
  "changelog": {
5
+ "0.4.0": "adapt to BundleWorkflow interface",
6
  "0.3.9": "black autofix format and add name tag",
7
  "0.3.8": "modify dataset key name",
8
  "0.3.7": "restructure readme to match updated template",
 
18
  "0.1.1": "update for MetaTensor",
19
  "0.1.0": "complete the model package"
20
  },
21
+ "monai_version": "1.2.0rc3",
22
+ "pytorch_version": "1.13.1",
23
+ "numpy_version": "1.22.2",
24
  "optional_packages_version": {
25
  "nibabel": "4.0.1",
26
  "pytorch-ignite": "0.4.9",
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
- "training": [
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=123)",
32
- "$setattr(torch.backends.cudnn, 'benchmark', True)",
33
- "$@train#trainer.run()",
 
 
 
 
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=123)",
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
@@ -60,7 +60,8 @@
60
  "keys": [
61
  "image",
62
  "label"
63
- ]
 
64
  },
65
  {
66
  "_target_": "ConvertToMultiChannelBasedOnBratsClassesd",
@@ -318,9 +319,11 @@
318
  "amp": "@amp"
319
  }
320
  },
321
- "training": [
322
  "$monai.utils.set_determinism(seed=123)",
323
- "$setattr(torch.backends.cudnn, 'benchmark', True)",
 
 
324
  "$@train#trainer.run()"
325
  ]
326
  }
 
60
  "keys": [
61
  "image",
62
  "label"
63
+ ],
64
+ "image_only": false
65
  },
66
  {
67
  "_target_": "ConvertToMultiChannelBasedOnBratsClassesd",
 
319
  "amp": "@amp"
320
  }
321
  },
322
+ "initialize": [
323
  "$monai.utils.set_determinism(seed=123)",
324
+ "$setattr(torch.backends.cudnn, 'benchmark', True)"
325
+ ],
326
+ "run": [
327
  "$@train#trainer.run()"
328
  ]
329
  }
docs/README.md CHANGED
@@ -69,24 +69,24 @@ For more details usage instructions, visit the [MONAI Bundle Configuration Page]
69
 
70
  #### Execute training:
71
  ```
72
- python -m monai.bundle run training --meta_file configs/metadata.json --config_file configs/train.json --logging_file configs/logging.conf
73
  ```
74
 
75
  #### Override the `train` config to execute multi-GPU training:
76
  ```
77
- torchrun --standalone --nnodes=1 --nproc_per_node=8 -m monai.bundle run training --meta_file configs/metadata.json --config_file "['configs/train.json','configs/multi_gpu_train.json']" --logging_file configs/logging.conf
78
  ```
79
 
80
  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).
81
 
82
  #### Override the `train` config to execute evaluation with the trained model:
83
  ```
84
- python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file "['configs/train.json','configs/evaluate.json']" --logging_file configs/logging.conf
85
  ```
86
 
87
  #### Execute inference:
88
  ```
89
- python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file configs/inference.json --logging_file configs/logging.conf
90
  ```
91
 
92
  # References
 
69
 
70
  #### Execute training:
71
  ```
72
+ python -m monai.bundle run --config_file configs/train.json
73
  ```
74
 
75
  #### Override the `train` config to execute multi-GPU training:
76
  ```
77
+ torchrun --standalone --nnodes=1 --nproc_per_node=8 -m monai.bundle run --config_file "['configs/train.json','configs/multi_gpu_train.json']"
78
  ```
79
 
80
  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).
81
 
82
  #### Override the `train` config to execute evaluation with the trained model:
83
  ```
84
+ python -m monai.bundle run --config_file "['configs/train.json','configs/evaluate.json']"
85
  ```
86
 
87
  #### Execute inference:
88
  ```
89
+ python -m monai.bundle run --config_file configs/inference.json
90
  ```
91
 
92
  # References