katielink commited on
Commit
9b64c65
1 Parent(s): b1772e8

adapt to BundleWorkflow interface

Browse files
README.md CHANGED
@@ -92,13 +92,13 @@ For more details usage instructions, visit the [MONAI Bundle Configuration Page]
92
  #### Execute training
93
 
94
  ```
95
- python -m monai.bundle run training --meta_file configs/metadata.json --config_file configs/train.json --logging_file configs/logging.conf
96
  ```
97
 
98
  #### Override the `train` config to execute multi-GPU training
99
 
100
  ```
101
- torchrun --standalone --nnodes=1 --nproc_per_node=2 -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
102
  ```
103
 
104
  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).
@@ -106,7 +106,7 @@ Please note that the distributed training-related options depend on the actual r
106
  #### Execute inference
107
 
108
  ```
109
- CUDA_LAUNCH_BLOCKING=1 python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file configs/inference.json --logging_file configs/logging.conf
110
  ```
111
 
112
  #### Evaluate FROC metric
 
92
  #### Execute training
93
 
94
  ```
95
+ python -m monai.bundle run --config_file configs/train.json
96
  ```
97
 
98
  #### Override the `train` config to execute multi-GPU training
99
 
100
  ```
101
+ torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run --config_file "['configs/train.json','configs/multi_gpu_train.json']"
102
  ```
103
 
104
  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).
 
106
  #### Execute inference
107
 
108
  ```
109
+ CUDA_LAUNCH_BLOCKING=1 python -m monai.bundle run --config_file configs/inference.json
110
  ```
111
 
112
  #### Evaluate FROC metric
configs/inference.json CHANGED
@@ -125,8 +125,10 @@
125
  "amp": true,
126
  "decollate": false
127
  },
128
- "evaluating": [
129
- "$setattr(torch.backends.cudnn, 'benchmark', True)",
 
 
130
131
  ]
132
  }
 
125
  "amp": true,
126
  "decollate": false
127
  },
128
+ "initialize": [
129
+ "$setattr(torch.backends.cudnn, 'benchmark', True)"
130
+ ],
131
+ "run": [
132
133
  ]
134
  }
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.8",
4
  "changelog": {
 
5
  "0.4.8": "update the readme file with TensorRT convert",
6
  "0.4.7": "add name tag",
7
  "0.4.6": "modify dataset key name",
@@ -20,12 +21,12 @@
20
  "0.1.0": "initialize release of the bundle"
21
  },
22
  "monai_version": "1.2.0rc3",
23
- "pytorch_version": "1.13.0",
24
- "numpy_version": "1.21.2",
25
  "optional_packages_version": {
26
- "cucim": "22.04",
27
  "pandas": "1.3.5",
28
- "torchvision": "0.14.0"
29
  },
30
  "name": "Pathology tumor detection",
31
  "task": "Pathology metastasis detection",
 
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.9",
4
  "changelog": {
5
+ "0.4.9": "adapt to BundleWorkflow interface",
6
  "0.4.8": "update the readme file with TensorRT convert",
7
  "0.4.7": "add name tag",
8
  "0.4.6": "modify dataset key name",
 
21
  "0.1.0": "initialize release of the bundle"
22
  },
23
  "monai_version": "1.2.0rc3",
24
+ "pytorch_version": "1.13.1",
25
+ "numpy_version": "1.22.2",
26
  "optional_packages_version": {
27
+ "cucim": "22.8.1",
28
  "pandas": "1.3.5",
29
+ "torchvision": "0.14.1"
30
  },
31
  "name": "Pathology tumor detection",
32
  "task": "Pathology metastasis detection",
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
@@ -371,9 +371,11 @@
371
  "amp": true
372
  }
373
  },
374
- "training": [
375
  "$monai.utils.set_determinism(seed=15)",
376
- "$setattr(torch.backends.cudnn, 'benchmark', True)",
 
 
377
  "$@train#trainer.run()"
378
  ]
379
  }
 
371
  "amp": true
372
  }
373
  },
374
+ "initialize": [
375
  "$monai.utils.set_determinism(seed=15)",
376
+ "$setattr(torch.backends.cudnn, 'benchmark', True)"
377
+ ],
378
+ "run": [
379
  "$@train#trainer.run()"
380
  ]
381
  }
docs/README.md CHANGED
@@ -85,13 +85,13 @@ For more details usage instructions, visit the [MONAI Bundle Configuration Page]
85
  #### Execute training
86
 
87
  ```
88
- python -m monai.bundle run training --meta_file configs/metadata.json --config_file configs/train.json --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 --meta_file configs/metadata.json --config_file "['configs/train.json','configs/multi_gpu_train.json']" --logging_file configs/logging.conf
95
  ```
96
 
97
  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,7 +99,7 @@ Please note that the distributed training-related options depend on the actual r
99
  #### Execute inference
100
 
101
  ```
102
- CUDA_LAUNCH_BLOCKING=1 python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file configs/inference.json --logging_file configs/logging.conf
103
  ```
104
 
105
  #### Evaluate FROC metric
 
85
  #### Execute training
86
 
87
  ```
88
+ python -m monai.bundle run --config_file configs/train.json
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 --config_file "['configs/train.json','configs/multi_gpu_train.json']"
95
  ```
96
 
97
  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
  #### Execute inference
100
 
101
  ```
102
+ CUDA_LAUNCH_BLOCKING=1 python -m monai.bundle run --config_file configs/inference.json
103
  ```
104
 
105
  #### Evaluate FROC metric
scripts/lesion_froc.py CHANGED
@@ -17,7 +17,7 @@ def load_data(ground_truth_dir: str, eval_dir: str, level: int, spacing: float):
17
  for prob_name in prob_files:
18
  if prob_name.endswith(".npy"):
19
  sample = {
20
- "tumor_mask": full_path(ground_truth_dir, prob_name[:-4]),
21
  "prob_map": full_path(eval_dir, prob_name),
22
  "level": level,
23
  "pixel_spacing": spacing,
 
17
  for prob_name in prob_files:
18
  if prob_name.endswith(".npy"):
19
  sample = {
20
+ "tumor_mask": full_path(ground_truth_dir, prob_name.replace("npy", "tif")),
21
  "prob_map": full_path(eval_dir, prob_name),
22
  "level": level,
23
  "pixel_spacing": spacing,