monai
medical
katielink commited on
Commit
31d89d2
1 Parent(s): 28f3221

adapt to BundleWorkflow interface

Browse files
README.md CHANGED
@@ -82,19 +82,14 @@ For more details usage instructions, visit the [MONAI Bundle Configuration Page]
82
  #### Execute training:
83
 
84
  ```
85
- python -m monai.bundle run training \
86
- --meta_file configs/metadata.json \
87
- --config_file configs/train.json \
88
- --logging_file configs/logging.conf
89
  ```
90
 
91
  #### Override the `train` config to execute multi-GPU training:
92
 
93
  ```
94
- torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run training \
95
- --meta_file configs/metadata.json \
96
- --config_file "['configs/train.json','configs/multi_gpu_train.json']" \
97
- --logging_file configs/logging.conf
98
  ```
99
 
100
  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).
@@ -104,19 +99,13 @@ In addition, if using the 20 samples example dataset, the preprocessing script w
104
  #### Override the `train` config to execute evaluation with the trained model:
105
 
106
  ```
107
- python -m monai.bundle run evaluating \
108
- --meta_file configs/metadata.json \
109
- --config_file "['configs/train.json','configs/evaluate.json']" \
110
- --logging_file configs/logging.conf
111
  ```
112
 
113
  #### Execute inference:
114
 
115
  ```
116
- python -m monai.bundle run evaluating \
117
- --meta_file configs/metadata.json \
118
- --config_file configs/inference.json \
119
- --logging_file configs/logging.conf
120
  ```
121
  The classification result of every images in `test.json` will be printed to the screen.
122
 
 
82
  #### Execute training:
83
 
84
  ```
85
+ python -m monai.bundle run --config_file configs/train.json
 
 
 
86
  ```
87
 
88
  #### Override the `train` config to execute multi-GPU training:
89
 
90
  ```
91
+ torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run \
92
+ --config_file "['configs/train.json','configs/multi_gpu_train.json']"
 
 
93
  ```
94
 
95
  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).
 
99
  #### Override the `train` config to execute evaluation with the trained model:
100
 
101
  ```
102
+ python -m monai.bundle run --config_file "['configs/train.json','configs/evaluate.json']"
 
 
 
103
  ```
104
 
105
  #### Execute inference:
106
 
107
  ```
108
+ python -m monai.bundle run --config_file configs/inference.json
 
 
 
109
  ```
110
  The classification result of every images in `test.json` will be printed to the screen.
111
 
configs/evaluate.json CHANGED
@@ -41,8 +41,10 @@
41
  "summary_ops": "*"
42
  }
43
  ],
44
- "evaluating": [
45
- "$setattr(torch.backends.cudnn, 'benchmark', True)",
 
 
46
  "$@validate#evaluator.run()"
47
  ]
48
  }
 
41
  "summary_ops": "*"
42
  }
43
  ],
44
+ "initialize": [
45
+ "$setattr(torch.backends.cudnn, 'benchmark', True)"
46
+ ],
47
+ "run": [
48
  "$@validate#evaluator.run()"
49
  ]
50
  }
configs/inference.json CHANGED
@@ -4,7 +4,7 @@
4
  "$import os",
5
  "$import torch"
6
  ],
7
- "bundle_root": "/workspace/bundle/endoscopic_inbody_classification",
8
  "dataset_dir": "/workspace/data/endoscopic_inbody_classification",
9
  "test_json": "$@bundle_root+'/label/test_samples.json'",
10
  "test_fp": "$open(@test_json,'r', encoding='utf8')",
@@ -105,8 +105,10 @@
105
  "postprocessing": "@postprocessing",
106
  "val_handlers": "@handlers"
107
  },
108
- "evaluating": [
109
- "$setattr(torch.backends.cudnn, 'benchmark', True)",
 
 
110
  "$@evaluator.run()"
111
  ]
112
  }
 
4
  "$import os",
5
  "$import torch"
6
  ],
7
+ "bundle_root": ".",
8
  "dataset_dir": "/workspace/data/endoscopic_inbody_classification",
9
  "test_json": "$@bundle_root+'/label/test_samples.json'",
10
  "test_fp": "$open(@test_json,'r', encoding='utf8')",
 
105
  "postprocessing": "@postprocessing",
106
  "val_handlers": "@handlers"
107
  },
108
+ "initialize": [
109
+ "$setattr(torch.backends.cudnn, 'benchmark', True)"
110
+ ],
111
+ "run": [
112
  "$@evaluator.run()"
113
  ]
114
  }
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.6",
4
  "changelog": {
 
5
  "0.3.6": "add name tag",
6
  "0.3.5": "fix a comment issue in the data_process script",
7
  "0.3.4": "add note for multi-gpu training with example dataset",
@@ -15,9 +16,9 @@
15
  "0.1.0": "complete the first version model package",
16
  "0.0.1": "initialize the model package structure"
17
  },
18
- "monai_version": "1.0.1",
19
- "pytorch_version": "1.13.0",
20
- "numpy_version": "1.22.4",
21
  "optional_packages_version": {
22
  "nibabel": "4.0.1",
23
  "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.3.7",
4
  "changelog": {
5
+ "0.3.7": "adapt to BundleWorkflow interface",
6
  "0.3.6": "add name tag",
7
  "0.3.5": "fix a comment issue in the data_process script",
8
  "0.3.4": "add note for multi-gpu training with example dataset",
 
16
  "0.1.0": "complete the first version model package",
17
  "0.0.1": "initialize the model package structure"
18
  },
19
+ "monai_version": "1.2.0rc3",
20
+ "pytorch_version": "1.13.1",
21
+ "numpy_version": "1.22.2",
22
  "optional_packages_version": {
23
  "nibabel": "4.0.1",
24
  "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
@@ -4,7 +4,7 @@
4
  "$import json",
5
  "$import ignite"
6
  ],
7
- "bundle_root": "/workspace/bundle/endoscopic_inbody_classification",
8
  "ckpt_dir": "$@bundle_root + '/models'",
9
  "output_dir": "$@bundle_root + '/eval'",
10
  "dataset_dir": "/workspace/data/endoscopic_inbody_classification",
@@ -251,9 +251,11 @@
251
  "val_handlers": "@validate#handlers"
252
  }
253
  },
254
- "training": [
255
- "$monai.utils.set_determinism(seed=0)",
256
- "$setattr(torch.backends.cudnn, 'benchmark', True)",
 
 
257
  "$@train#trainer.run()"
258
  ]
259
  }
 
4
  "$import json",
5
  "$import ignite"
6
  ],
7
+ "bundle_root": ".",
8
  "ckpt_dir": "$@bundle_root + '/models'",
9
  "output_dir": "$@bundle_root + '/eval'",
10
  "dataset_dir": "/workspace/data/endoscopic_inbody_classification",
 
251
  "val_handlers": "@validate#handlers"
252
  }
253
  },
254
+ "initialize": [
255
+ "$monai.utils.set_determinism(seed=123)",
256
+ "$setattr(torch.backends.cudnn, 'benchmark', True)"
257
+ ],
258
+ "run": [
259
  "$@train#trainer.run()"
260
  ]
261
  }
docs/README.md CHANGED
@@ -75,19 +75,14 @@ For more details usage instructions, visit the [MONAI Bundle Configuration Page]
75
  #### Execute training:
76
 
77
  ```
78
- python -m monai.bundle run training \
79
- --meta_file configs/metadata.json \
80
- --config_file configs/train.json \
81
- --logging_file configs/logging.conf
82
  ```
83
 
84
  #### Override the `train` config to execute multi-GPU training:
85
 
86
  ```
87
- torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run training \
88
- --meta_file configs/metadata.json \
89
- --config_file "['configs/train.json','configs/multi_gpu_train.json']" \
90
- --logging_file configs/logging.conf
91
  ```
92
 
93
  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).
@@ -97,19 +92,13 @@ In addition, if using the 20 samples example dataset, the preprocessing script w
97
  #### Override the `train` config to execute evaluation with the trained model:
98
 
99
  ```
100
- python -m monai.bundle run evaluating \
101
- --meta_file configs/metadata.json \
102
- --config_file "['configs/train.json','configs/evaluate.json']" \
103
- --logging_file configs/logging.conf
104
  ```
105
 
106
  #### Execute inference:
107
 
108
  ```
109
- python -m monai.bundle run evaluating \
110
- --meta_file configs/metadata.json \
111
- --config_file configs/inference.json \
112
- --logging_file configs/logging.conf
113
  ```
114
  The classification result of every images in `test.json` will be printed to the screen.
115
 
 
75
  #### Execute training:
76
 
77
  ```
78
+ python -m monai.bundle run --config_file configs/train.json
 
 
 
79
  ```
80
 
81
  #### Override the `train` config to execute multi-GPU training:
82
 
83
  ```
84
+ torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run \
85
+ --config_file "['configs/train.json','configs/multi_gpu_train.json']"
 
 
86
  ```
87
 
88
  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).
 
92
  #### Override the `train` config to execute evaluation with the trained model:
93
 
94
  ```
95
+ python -m monai.bundle run --config_file "['configs/train.json','configs/evaluate.json']"
 
 
 
96
  ```
97
 
98
  #### Execute inference:
99
 
100
  ```
101
+ python -m monai.bundle run --config_file configs/inference.json
 
 
 
102
  ```
103
  The classification result of every images in `test.json` will be printed to the screen.
104