adapt to BundleWorkflow interface
Browse files- README.md +5 -5
- configs/evaluate.json +4 -2
- configs/inference.json +5 -3
- configs/metadata.json +7 -5
- configs/multi_gpu_evaluate.json +8 -4
- configs/multi_gpu_train.json +8 -4
- configs/train.json +5 -3
- docs/README.md +5 -5
README.md
CHANGED
@@ -148,13 +148,13 @@ A graph showing the validation F1-score over 50 epochs.
|
|
148 |
Execute training:
|
149 |
|
150 |
```
|
151 |
-
python -m monai.bundle run
|
152 |
```
|
153 |
|
154 |
Override the `train` config to execute multi-GPU training:
|
155 |
|
156 |
```
|
157 |
-
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run
|
158 |
```
|
159 |
|
160 |
Please note that the distributed training related options depend on the actual running environment, thus you may need to remove `--standalone`, modify `--nnodes` or do some other necessary changes according to the machine you used.
|
@@ -163,19 +163,19 @@ Please refer to [pytorch's official tutorial](https://pytorch.org/tutorials/inte
|
|
163 |
Override the `train` config to execute evaluation with the trained model:
|
164 |
|
165 |
```
|
166 |
-
python -m monai.bundle run
|
167 |
```
|
168 |
|
169 |
Override the `train` config and `evaluate` config to execute multi-GPU evaluation:
|
170 |
|
171 |
```
|
172 |
-
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run
|
173 |
```
|
174 |
|
175 |
Execute inference:
|
176 |
|
177 |
```
|
178 |
-
python -m monai.bundle run
|
179 |
```
|
180 |
|
181 |
# Disclaimer
|
|
|
148 |
Execute training:
|
149 |
|
150 |
```
|
151 |
+
python -m monai.bundle run --config_file configs/train.json
|
152 |
```
|
153 |
|
154 |
Override the `train` config to execute multi-GPU training:
|
155 |
|
156 |
```
|
157 |
+
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run --config_file "['configs/train.json','configs/multi_gpu_train.json']"
|
158 |
```
|
159 |
|
160 |
Please note that the distributed training related options depend on the actual running environment, thus you may need to remove `--standalone`, modify `--nnodes` or do some other necessary changes according to the machine you used.
|
|
|
163 |
Override the `train` config to execute evaluation with the trained model:
|
164 |
|
165 |
```
|
166 |
+
python -m monai.bundle run --config_file "['configs/train.json','configs/evaluate.json']"
|
167 |
```
|
168 |
|
169 |
Override the `train` config and `evaluate` config to execute multi-GPU evaluation:
|
170 |
|
171 |
```
|
172 |
+
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']"
|
173 |
```
|
174 |
|
175 |
Execute inference:
|
176 |
|
177 |
```
|
178 |
+
python -m monai.bundle run --config_file configs/inference.json
|
179 |
```
|
180 |
|
181 |
# Disclaimer
|
configs/evaluate.json
CHANGED
@@ -64,12 +64,14 @@
|
|
64 |
"summary_ops": "*"
|
65 |
}
|
66 |
],
|
67 |
-
"
|
68 |
"$import sys",
|
69 |
"$sys.path.append(@bundle_root)",
|
70 |
"$setattr(torch.backends.cudnn, 'benchmark', True)",
|
71 |
"$import scripts",
|
72 |
-
"$monai.data.register_writer('json', scripts.ClassificationWriter)"
|
|
|
|
|
73 |
"$@validate#evaluator.run()"
|
74 |
]
|
75 |
}
|
|
|
64 |
"summary_ops": "*"
|
65 |
}
|
66 |
],
|
67 |
+
"initialize": [
|
68 |
"$import sys",
|
69 |
"$sys.path.append(@bundle_root)",
|
70 |
"$setattr(torch.backends.cudnn, 'benchmark', True)",
|
71 |
"$import scripts",
|
72 |
+
"$monai.data.register_writer('json', scripts.ClassificationWriter)"
|
73 |
+
],
|
74 |
+
"run": [
|
75 |
"$@validate#evaluator.run()"
|
76 |
]
|
77 |
}
|
configs/inference.json
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
"$import pathlib",
|
6 |
"$import os"
|
7 |
],
|
8 |
-
"bundle_root": "
|
9 |
"output_dir": "$@bundle_root + '/eval'",
|
10 |
"dataset_dir": "/workspace/data/CoNSePNuclei",
|
11 |
"images": "$list(sorted(glob.glob(@dataset_dir + '/Test/Images/*.png')))[:1]",
|
@@ -107,10 +107,12 @@
|
|
107 |
"val_handlers": "@handlers",
|
108 |
"amp": true
|
109 |
},
|
110 |
-
"
|
111 |
"$setattr(torch.backends.cudnn, 'benchmark', True)",
|
112 |
"$import scripts",
|
113 |
-
"$monai.data.register_writer('json', scripts.ClassificationWriter)"
|
|
|
|
|
114 | |
115 |
]
|
116 |
}
|
|
|
5 |
"$import pathlib",
|
6 |
"$import os"
|
7 |
],
|
8 |
+
"bundle_root": ".",
|
9 |
"output_dir": "$@bundle_root + '/eval'",
|
10 |
"dataset_dir": "/workspace/data/CoNSePNuclei",
|
11 |
"images": "$list(sorted(glob.glob(@dataset_dir + '/Test/Images/*.png')))[:1]",
|
|
|
107 |
"val_handlers": "@handlers",
|
108 |
"amp": true
|
109 |
},
|
110 |
+
"initialize": [
|
111 |
"$setattr(torch.backends.cudnn, 'benchmark', True)",
|
112 |
"$import scripts",
|
113 |
+
"$monai.data.register_writer('json', scripts.ClassificationWriter)"
|
114 |
+
],
|
115 |
+
"run": [
|
116 | |
117 |
]
|
118 |
}
|
configs/metadata.json
CHANGED
@@ -1,19 +1,21 @@
|
|
1 |
{
|
2 |
"schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json",
|
3 |
-
"version": "0.0.
|
4 |
"changelog": {
|
|
|
5 |
"0.0.5": "add name tag",
|
6 |
"0.0.4": "Fix evaluation",
|
7 |
"0.0.3": "Update to use MONAI 1.1.0",
|
8 |
"0.0.2": "Update The Torch Vision Transform",
|
9 |
"0.0.1": "initialize the model package structure"
|
10 |
},
|
11 |
-
"monai_version": "1.
|
12 |
-
"pytorch_version": "1.13.
|
13 |
-
"numpy_version": "1.
|
14 |
"optional_packages_version": {
|
15 |
"nibabel": "4.0.1",
|
16 |
-
"pytorch-ignite": "0.4.9"
|
|
|
17 |
},
|
18 |
"name": "Pathology nuclei classification",
|
19 |
"task": "Pathology Nuclei classification",
|
|
|
1 |
{
|
2 |
"schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json",
|
3 |
+
"version": "0.0.6",
|
4 |
"changelog": {
|
5 |
+
"0.0.6": "adapt to BundleWorkflow interface",
|
6 |
"0.0.5": "add name tag",
|
7 |
"0.0.4": "Fix evaluation",
|
8 |
"0.0.3": "Update to use MONAI 1.1.0",
|
9 |
"0.0.2": "Update The Torch Vision Transform",
|
10 |
"0.0.1": "initialize the model package structure"
|
11 |
},
|
12 |
+
"monai_version": "1.2.0rc3",
|
13 |
+
"pytorch_version": "1.13.1",
|
14 |
+
"numpy_version": "1.22.2",
|
15 |
"optional_packages_version": {
|
16 |
"nibabel": "4.0.1",
|
17 |
+
"pytorch-ignite": "0.4.9",
|
18 |
+
"torchvision": "0.14.1"
|
19 |
},
|
20 |
"name": "Pathology nuclei classification",
|
21 |
"task": "Pathology Nuclei classification",
|
configs/multi_gpu_evaluate.json
CHANGED
@@ -15,18 +15,22 @@
|
|
15 |
},
|
16 |
"validate#dataloader#sampler": "@validate#sampler",
|
17 |
"validate#handlers#1#_disabled_": "$dist.get_rank() > 0",
|
18 |
-
"
|
19 |
"$import sys",
|
20 |
"$sys.path.append(@bundle_root)",
|
21 |
"$import torch.distributed as dist",
|
22 |
-
"$dist.init_process_group(backend='nccl')",
|
23 |
"$torch.cuda.set_device(@device)",
|
24 |
"$setattr(torch.backends.cudnn, 'benchmark', True)",
|
25 |
"$import logging",
|
26 |
"$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)",
|
27 |
"$import scripts",
|
28 |
-
"$monai.data.register_writer('json', scripts.ClassificationWriter)"
|
29 |
-
|
|
|
|
|
|
|
|
|
30 |
"$dist.destroy_process_group()"
|
31 |
]
|
32 |
}
|
|
|
15 |
},
|
16 |
"validate#dataloader#sampler": "@validate#sampler",
|
17 |
"validate#handlers#1#_disabled_": "$dist.get_rank() > 0",
|
18 |
+
"initialize": [
|
19 |
"$import sys",
|
20 |
"$sys.path.append(@bundle_root)",
|
21 |
"$import torch.distributed as dist",
|
22 |
+
"$dist.is_initialized() or dist.init_process_group(backend='nccl')",
|
23 |
"$torch.cuda.set_device(@device)",
|
24 |
"$setattr(torch.backends.cudnn, 'benchmark', True)",
|
25 |
"$import logging",
|
26 |
"$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)",
|
27 |
"$import scripts",
|
28 |
+
"$monai.data.register_writer('json', scripts.ClassificationWriter)"
|
29 |
+
],
|
30 |
+
"run": [
|
31 |
+
"$@validate#evaluator.run()"
|
32 |
+
],
|
33 |
+
"finalize": [
|
34 |
"$dist.destroy_process_group()"
|
35 |
]
|
36 |
}
|
configs/multi_gpu_train.json
CHANGED
@@ -24,18 +24,22 @@
|
|
24 |
},
|
25 |
"validate#dataloader#sampler": "@validate#sampler",
|
26 |
"validate#evaluator#val_handlers": "$None if dist.get_rank() > 0 else @validate#handlers",
|
27 |
-
"
|
28 |
"$import sys",
|
29 |
"$sys.path.append(@bundle_root)",
|
30 |
"$import torch.distributed as dist",
|
31 |
-
"$dist.init_process_group(backend='nccl')",
|
32 |
"$torch.cuda.set_device(@device)",
|
33 |
"$monai.utils.set_determinism(seed=123)",
|
34 |
"$setattr(torch.backends.cudnn, 'benchmark', True)",
|
35 |
"$import logging",
|
36 |
"$@train#trainer.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)",
|
37 |
-
"$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)"
|
38 |
-
|
|
|
|
|
|
|
|
|
39 |
"$dist.destroy_process_group()"
|
40 |
]
|
41 |
}
|
|
|
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 sys",
|
29 |
"$sys.path.append(@bundle_root)",
|
30 |
"$import torch.distributed as dist",
|
31 |
+
"$dist.is_initialized() or dist.init_process_group(backend='nccl')",
|
32 |
"$torch.cuda.set_device(@device)",
|
33 |
"$monai.utils.set_determinism(seed=123)",
|
34 |
"$setattr(torch.backends.cudnn, 'benchmark', True)",
|
35 |
"$import logging",
|
36 |
"$@train#trainer.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)",
|
37 |
+
"$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)"
|
38 |
+
],
|
39 |
+
"run": [
|
40 |
+
"$@train#trainer.run()"
|
41 |
+
],
|
42 |
+
"finalize": [
|
43 |
"$dist.destroy_process_group()"
|
44 |
]
|
45 |
}
|
configs/train.json
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
"$import pathlib",
|
7 |
"$import os"
|
8 |
],
|
9 |
-
"bundle_root": "
|
10 |
"ckpt_dir": "$@bundle_root + '/models'",
|
11 |
"output_dir": "$@bundle_root + '/eval'",
|
12 |
"dataset_dir": "/workspace/data/CoNSePNuclei",
|
@@ -340,11 +340,13 @@
|
|
340 |
"amp": true
|
341 |
}
|
342 |
},
|
343 |
-
"
|
344 |
"$import sys",
|
345 |
"$sys.path.append(@bundle_root)",
|
346 |
"$monai.utils.set_determinism(seed=123)",
|
347 |
-
"$setattr(torch.backends.cudnn, 'benchmark', True)"
|
|
|
|
|
348 |
"$@train#trainer.run()"
|
349 |
]
|
350 |
}
|
|
|
6 |
"$import pathlib",
|
7 |
"$import os"
|
8 |
],
|
9 |
+
"bundle_root": ".",
|
10 |
"ckpt_dir": "$@bundle_root + '/models'",
|
11 |
"output_dir": "$@bundle_root + '/eval'",
|
12 |
"dataset_dir": "/workspace/data/CoNSePNuclei",
|
|
|
340 |
"amp": true
|
341 |
}
|
342 |
},
|
343 |
+
"initialize": [
|
344 |
"$import sys",
|
345 |
"$sys.path.append(@bundle_root)",
|
346 |
"$monai.utils.set_determinism(seed=123)",
|
347 |
+
"$setattr(torch.backends.cudnn, 'benchmark', True)"
|
348 |
+
],
|
349 |
+
"run": [
|
350 |
"$@train#trainer.run()"
|
351 |
]
|
352 |
}
|
docs/README.md
CHANGED
@@ -141,13 +141,13 @@ A graph showing the validation F1-score over 50 epochs.
|
|
141 |
Execute training:
|
142 |
|
143 |
```
|
144 |
-
python -m monai.bundle run
|
145 |
```
|
146 |
|
147 |
Override the `train` config to execute multi-GPU training:
|
148 |
|
149 |
```
|
150 |
-
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run
|
151 |
```
|
152 |
|
153 |
Please note that the distributed training related options depend on the actual running environment, thus you may need to remove `--standalone`, modify `--nnodes` or do some other necessary changes according to the machine you used.
|
@@ -156,19 +156,19 @@ Please refer to [pytorch's official tutorial](https://pytorch.org/tutorials/inte
|
|
156 |
Override the `train` config to execute evaluation with the trained model:
|
157 |
|
158 |
```
|
159 |
-
python -m monai.bundle run
|
160 |
```
|
161 |
|
162 |
Override the `train` config and `evaluate` config to execute multi-GPU evaluation:
|
163 |
|
164 |
```
|
165 |
-
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run
|
166 |
```
|
167 |
|
168 |
Execute inference:
|
169 |
|
170 |
```
|
171 |
-
python -m monai.bundle run
|
172 |
```
|
173 |
|
174 |
# Disclaimer
|
|
|
141 |
Execute training:
|
142 |
|
143 |
```
|
144 |
+
python -m monai.bundle run --config_file configs/train.json
|
145 |
```
|
146 |
|
147 |
Override the `train` config to execute multi-GPU training:
|
148 |
|
149 |
```
|
150 |
+
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run --config_file "['configs/train.json','configs/multi_gpu_train.json']"
|
151 |
```
|
152 |
|
153 |
Please note that the distributed training related options depend on the actual running environment, thus you may need to remove `--standalone`, modify `--nnodes` or do some other necessary changes according to the machine you used.
|
|
|
156 |
Override the `train` config to execute evaluation with the trained model:
|
157 |
|
158 |
```
|
159 |
+
python -m monai.bundle run --config_file "['configs/train.json','configs/evaluate.json']"
|
160 |
```
|
161 |
|
162 |
Override the `train` config and `evaluate` config to execute multi-GPU evaluation:
|
163 |
|
164 |
```
|
165 |
+
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']"
|
166 |
```
|
167 |
|
168 |
Execute inference:
|
169 |
|
170 |
```
|
171 |
+
python -m monai.bundle run --config_file configs/inference.json
|
172 |
```
|
173 |
|
174 |
# Disclaimer
|