diff --git a/ci/verify_tensorrt.py b/ci/verify_tensorrt.py index ac34c623..25c3d62a 100644 --- a/ci/verify_tensorrt.py +++ b/ci/verify_tensorrt.py @@ -28,7 +28,7 @@ def verify_tensorrt(bundle_path: str, net_id: str, config_file: str, precision: trt_export( net_id=net_id, filepath=trt_model_path, - ckpt_file=os.path.join(bundle_path, "models/models.pt"), + ckpt_file=os.path.join(bundle_path, "models/model.pt"), meta_file=os.path.join(bundle_path, "configs/metadata.json"), config_file=os.path.join(bundle_path, config_file), precision=precision, @@ -63,6 +63,7 @@ def verify_all_tensorrt_bundles(models_path="models"): except BaseException: print(f"verify bundle {bundle} with precision {precision} failed.") raise + print("all TensorRT supported bundles are verified correctly.") if __name__ == "__main__": diff --git a/models/brats_mri_segmentation/configs/evaluate.json b/models/brats_mri_segmentation/configs/evaluate.json index f4055182..52164d9c 100644 --- a/models/brats_mri_segmentation/configs/evaluate.json +++ b/models/brats_mri_segmentation/configs/evaluate.json @@ -85,8 +85,10 @@ "summary_ops": "*" } ], - "evaluating": [ - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "initialize": [ + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@validate#evaluator.run()" ] } diff --git a/models/brats_mri_segmentation/configs/inference.json b/models/brats_mri_segmentation/configs/inference.json index 02078b6b..e7dafc82 100644 --- a/models/brats_mri_segmentation/configs/inference.json +++ b/models/brats_mri_segmentation/configs/inference.json @@ -35,7 +35,8 @@ "transforms": [ { "_target_": "LoadImaged", - "keys": "image" + "keys": "image", + "image_only": false }, { "_target_": "NormalizeIntensityd", @@ -129,8 +130,10 @@ "val_handlers": "@handlers", "amp": true }, - "evaluating": [ - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "initialize": [ + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@evaluator.run()" ] } diff --git a/models/brats_mri_segmentation/configs/metadata.json b/models/brats_mri_segmentation/configs/metadata.json index 11ad2f17..3900be80 100644 --- a/models/brats_mri_segmentation/configs/metadata.json +++ b/models/brats_mri_segmentation/configs/metadata.json @@ -1,7 +1,8 @@ { "schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json", - "version": "0.3.9", + "version": "0.4.0", "changelog": { + "0.4.0": "adapt to BundleWorkflow interface", "0.3.9": "black autofix format and add name tag", "0.3.8": "modify dataset key name", "0.3.7": "restructure readme to match updated template", @@ -17,9 +18,9 @@ "0.1.1": "update for MetaTensor", "0.1.0": "complete the model package" }, - "monai_version": "1.0.1", - "pytorch_version": "1.13.0", - "numpy_version": "1.22.4", + "monai_version": "1.2.0rc3", + "pytorch_version": "1.13.1", + "numpy_version": "1.22.2", "optional_packages_version": { "nibabel": "4.0.1", "pytorch-ignite": "0.4.9", diff --git a/models/brats_mri_segmentation/configs/multi_gpu_train.json b/models/brats_mri_segmentation/configs/multi_gpu_train.json index 893815cd..fd55dbc0 100644 --- a/models/brats_mri_segmentation/configs/multi_gpu_train.json +++ b/models/brats_mri_segmentation/configs/multi_gpu_train.json @@ -24,13 +24,17 @@ }, "validate#dataloader#sampler": "@validate#sampler", "validate#evaluator#val_handlers": "$None if dist.get_rank() > 0 else @validate#handlers", - "training": [ + "initialize": [ "$import torch.distributed as dist", - "$dist.init_process_group(backend='nccl')", + "$dist.is_initialized() or dist.init_process_group(backend='nccl')", "$torch.cuda.set_device(@device)", "$monai.utils.set_determinism(seed=123)", - "$setattr(torch.backends.cudnn, 'benchmark', True)", - "$@train#trainer.run()", + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ + "$@train#trainer.run()" + ], + "finalize": [ "$dist.destroy_process_group()" ] } diff --git a/models/brats_mri_segmentation/configs/train.json b/models/brats_mri_segmentation/configs/train.json index 87fbd750..a543f2b0 100644 --- a/models/brats_mri_segmentation/configs/train.json +++ b/models/brats_mri_segmentation/configs/train.json @@ -60,7 +60,8 @@ "keys": [ "image", "label" - ] + ], + "image_only": false }, { "_target_": "ConvertToMultiChannelBasedOnBratsClassesd", @@ -318,9 +319,11 @@ "amp": "@amp" } }, - "training": [ + "initialize": [ "$monai.utils.set_determinism(seed=123)", - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@train#trainer.run()" ] } diff --git a/models/brats_mri_segmentation/docs/README.md b/models/brats_mri_segmentation/docs/README.md index a80dc224..53ae3ded 100644 --- a/models/brats_mri_segmentation/docs/README.md +++ b/models/brats_mri_segmentation/docs/README.md @@ -69,24 +69,24 @@ For more details usage instructions, visit the [MONAI Bundle Configuration Page] #### Execute training: ``` -python -m monai.bundle run training --meta_file configs/metadata.json --config_file configs/train.json --logging_file configs/logging.conf +python -m monai.bundle run --config_file configs/train.json ``` #### Override the `train` config to execute multi-GPU training: ``` -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 +torchrun --standalone --nnodes=1 --nproc_per_node=8 -m monai.bundle run --config_file "['configs/train.json','configs/multi_gpu_train.json']" ``` 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). #### Override the `train` config to execute evaluation with the trained model: ``` -python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file "['configs/train.json','configs/evaluate.json']" --logging_file configs/logging.conf +python -m monai.bundle run --config_file "['configs/train.json','configs/evaluate.json']" ``` #### Execute inference: ``` -python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file configs/inference.json --logging_file configs/logging.conf +python -m monai.bundle run --config_file configs/inference.json ``` # References diff --git a/models/endoscopic_inbody_classification/configs/evaluate.json b/models/endoscopic_inbody_classification/configs/evaluate.json index 1a7b8dc5..a6b34c09 100644 --- a/models/endoscopic_inbody_classification/configs/evaluate.json +++ b/models/endoscopic_inbody_classification/configs/evaluate.json @@ -41,8 +41,10 @@ "summary_ops": "*" } ], - "evaluating": [ - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "initialize": [ + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@validate#evaluator.run()" ] } diff --git a/models/endoscopic_inbody_classification/configs/inference.json b/models/endoscopic_inbody_classification/configs/inference.json index 99f9e33c..37ddefea 100644 --- a/models/endoscopic_inbody_classification/configs/inference.json +++ b/models/endoscopic_inbody_classification/configs/inference.json @@ -4,7 +4,7 @@ "$import os", "$import torch" ], - "bundle_root": "/workspace/bundle/endoscopic_inbody_classification", + "bundle_root": ".", "dataset_dir": "/workspace/data/endoscopic_inbody_classification", "test_json": "$@bundle_root+'/label/test_samples.json'", "test_fp": "$open(@test_json,'r', encoding='utf8')", @@ -105,8 +105,10 @@ "postprocessing": "@postprocessing", "val_handlers": "@handlers" }, - "evaluating": [ - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "initialize": [ + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@evaluator.run()" ] } diff --git a/models/endoscopic_inbody_classification/configs/metadata.json b/models/endoscopic_inbody_classification/configs/metadata.json index 5c27a59c..66a0ecaa 100644 --- a/models/endoscopic_inbody_classification/configs/metadata.json +++ b/models/endoscopic_inbody_classification/configs/metadata.json @@ -1,7 +1,8 @@ { "schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json", - "version": "0.3.6", + "version": "0.3.7", "changelog": { + "0.3.7": "adapt to BundleWorkflow interface", "0.3.6": "add name tag", "0.3.5": "fix a comment issue in the data_process script", "0.3.4": "add note for multi-gpu training with example dataset", @@ -15,9 +16,9 @@ "0.1.0": "complete the first version model package", "0.0.1": "initialize the model package structure" }, - "monai_version": "1.0.1", - "pytorch_version": "1.13.0", - "numpy_version": "1.22.4", + "monai_version": "1.2.0rc3", + "pytorch_version": "1.13.1", + "numpy_version": "1.22.2", "optional_packages_version": { "nibabel": "4.0.1", "pytorch-ignite": "0.4.9" diff --git a/models/endoscopic_inbody_classification/configs/multi_gpu_train.json b/models/endoscopic_inbody_classification/configs/multi_gpu_train.json index 893815cd..fd55dbc0 100644 --- a/models/endoscopic_inbody_classification/configs/multi_gpu_train.json +++ b/models/endoscopic_inbody_classification/configs/multi_gpu_train.json @@ -24,13 +24,17 @@ }, "validate#dataloader#sampler": "@validate#sampler", "validate#evaluator#val_handlers": "$None if dist.get_rank() > 0 else @validate#handlers", - "training": [ + "initialize": [ "$import torch.distributed as dist", - "$dist.init_process_group(backend='nccl')", + "$dist.is_initialized() or dist.init_process_group(backend='nccl')", "$torch.cuda.set_device(@device)", "$monai.utils.set_determinism(seed=123)", - "$setattr(torch.backends.cudnn, 'benchmark', True)", - "$@train#trainer.run()", + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ + "$@train#trainer.run()" + ], + "finalize": [ "$dist.destroy_process_group()" ] } diff --git a/models/endoscopic_inbody_classification/configs/train.json b/models/endoscopic_inbody_classification/configs/train.json index 43c99bd1..ead5921d 100644 --- a/models/endoscopic_inbody_classification/configs/train.json +++ b/models/endoscopic_inbody_classification/configs/train.json @@ -4,7 +4,7 @@ "$import json", "$import ignite" ], - "bundle_root": "/workspace/bundle/endoscopic_inbody_classification", + "bundle_root": ".", "ckpt_dir": "$@bundle_root + '/models'", "output_dir": "$@bundle_root + '/eval'", "dataset_dir": "/workspace/data/endoscopic_inbody_classification", @@ -251,9 +251,11 @@ "val_handlers": "@validate#handlers" } }, - "training": [ - "$monai.utils.set_determinism(seed=0)", - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "initialize": [ + "$monai.utils.set_determinism(seed=123)", + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@train#trainer.run()" ] } diff --git a/models/endoscopic_inbody_classification/docs/README.md b/models/endoscopic_inbody_classification/docs/README.md index c756d504..aaa001a6 100644 --- a/models/endoscopic_inbody_classification/docs/README.md +++ b/models/endoscopic_inbody_classification/docs/README.md @@ -75,19 +75,14 @@ For more details usage instructions, visit the [MONAI Bundle Configuration Page] #### Execute training: ``` -python -m monai.bundle run training \ - --meta_file configs/metadata.json \ - --config_file configs/train.json \ - --logging_file configs/logging.conf +python -m monai.bundle run --config_file configs/train.json ``` #### Override the `train` config to execute multi-GPU training: ``` -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 +torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run \ + --config_file "['configs/train.json','configs/multi_gpu_train.json']" ``` 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 #### Override the `train` config to execute evaluation with the trained model: ``` -python -m monai.bundle run evaluating \ - --meta_file configs/metadata.json \ - --config_file "['configs/train.json','configs/evaluate.json']" \ - --logging_file configs/logging.conf +python -m monai.bundle run --config_file "['configs/train.json','configs/evaluate.json']" ``` #### Execute inference: ``` -python -m monai.bundle run evaluating \ - --meta_file configs/metadata.json \ - --config_file configs/inference.json \ - --logging_file configs/logging.conf +python -m monai.bundle run --config_file configs/inference.json ``` The classification result of every images in `test.json` will be printed to the screen. diff --git a/models/endoscopic_tool_segmentation/configs/evaluate.json b/models/endoscopic_tool_segmentation/configs/evaluate.json index 79f9c902..cb3e8d29 100644 --- a/models/endoscopic_tool_segmentation/configs/evaluate.json +++ b/models/endoscopic_tool_segmentation/configs/evaluate.json @@ -68,8 +68,10 @@ "summary_ops": "*" } ], - "evaluating": [ - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "initialize": [ + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@validate#evaluator.run()" ] } diff --git a/models/endoscopic_tool_segmentation/configs/inference.json b/models/endoscopic_tool_segmentation/configs/inference.json index 3f6a66c9..31ec84f8 100644 --- a/models/endoscopic_tool_segmentation/configs/inference.json +++ b/models/endoscopic_tool_segmentation/configs/inference.json @@ -3,7 +3,7 @@ "$import glob", "$import os" ], - "bundle_root": "/workspace/bundle/endoscopic_tool_segmentation", + "bundle_root": ".", "output_dir": "$@bundle_root + '/eval'", "dataset_dir": "/workspace/data/endoscopic_tool_dataset", "datalist": "$list(sorted(glob.glob(os.path.join(@dataset_dir,'test', '*', '*[!seg].jpg'))))", @@ -130,8 +130,10 @@ "postprocessing": "@postprocessing", "val_handlers": "@handlers" }, - "evaluating": [ - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "initialize": [ + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@evaluator.run()" ] } diff --git a/models/endoscopic_tool_segmentation/configs/metadata.json b/models/endoscopic_tool_segmentation/configs/metadata.json index 53af8afb..f45e9bb5 100644 --- a/models/endoscopic_tool_segmentation/configs/metadata.json +++ b/models/endoscopic_tool_segmentation/configs/metadata.json @@ -1,7 +1,8 @@ { "schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json", - "version": "0.4.3", + "version": "0.4.4", "changelog": { + "0.4.4": "adapt to BundleWorkflow interface", "0.4.3": "update this bundle to support TensorRT convert", "0.4.2": "support monai 1.2 new FlexibleUNet", "0.4.1": "add name tag", @@ -15,8 +16,8 @@ "0.0.1": "initialize the model package structure" }, "monai_version": "1.2.0rc3", - "pytorch_version": "1.13.0", - "numpy_version": "1.22.4", + "pytorch_version": "1.13.1", + "numpy_version": "1.22.2", "optional_packages_version": { "nibabel": "4.0.1", "pytorch-ignite": "0.4.9" diff --git a/models/endoscopic_tool_segmentation/configs/multi_gpu_evaluate.json b/models/endoscopic_tool_segmentation/configs/multi_gpu_evaluate.json index f6b6c6dc..0c28563d 100644 --- a/models/endoscopic_tool_segmentation/configs/multi_gpu_evaluate.json +++ b/models/endoscopic_tool_segmentation/configs/multi_gpu_evaluate.json @@ -15,14 +15,18 @@ }, "validate#dataloader#sampler": "@validate#sampler", "validate#handlers#1#_disabled_": "$dist.get_rank() > 0", - "evaluating": [ + "initialize": [ "$import torch.distributed as dist", - "$dist.init_process_group(backend='nccl')", + "$dist.is_initialized() or dist.init_process_group(backend='nccl')", "$torch.cuda.set_device(@device)", "$setattr(torch.backends.cudnn, 'benchmark', True)", "$import logging", - "$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)", - "$@validate#evaluator.run()", + "$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)" + ], + "run": [ + "$@validate#evaluator.run()" + ], + "finalize": [ "$dist.destroy_process_group()" ] } diff --git a/models/endoscopic_tool_segmentation/configs/multi_gpu_train.json b/models/endoscopic_tool_segmentation/configs/multi_gpu_train.json index 8720788c..413eb86d 100644 --- a/models/endoscopic_tool_segmentation/configs/multi_gpu_train.json +++ b/models/endoscopic_tool_segmentation/configs/multi_gpu_train.json @@ -25,16 +25,20 @@ }, "validate#dataloader#sampler": "@validate#sampler", "validate#evaluator#val_handlers": "$None if dist.get_rank() > 0 else @validate#handlers", - "training": [ + "initialize": [ "$import torch.distributed as dist", - "$dist.init_process_group(backend='nccl')", + "$dist.is_initialized() or dist.init_process_group(backend='nccl')", "$torch.cuda.set_device(@device)", "$monai.utils.set_determinism(seed=123)", "$setattr(torch.backends.cudnn, 'benchmark', True)", "$import logging", "$@train#trainer.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)", - "$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)", - "$@train#trainer.run()", + "$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)" + ], + "run": [ + "$@train#trainer.run()" + ], + "finalize": [ "$dist.destroy_process_group()" ] } diff --git a/models/endoscopic_tool_segmentation/configs/train.json b/models/endoscopic_tool_segmentation/configs/train.json index da38d36d..43c7c06b 100644 --- a/models/endoscopic_tool_segmentation/configs/train.json +++ b/models/endoscopic_tool_segmentation/configs/train.json @@ -5,7 +5,7 @@ "$import torch", "$import numpy as np" ], - "bundle_root": "/workspace/bundle/endoscopic_tool_segmentation", + "bundle_root": ".", "ckpt_dir": "$@bundle_root + '/models'", "output_dir": "$@bundle_root + '/eval'", "dataset_dir": "/workspace/data/endoscopic_tool_dataset", @@ -274,9 +274,11 @@ "val_handlers": "@validate#handlers" } }, - "training": [ - "$monai.utils.set_determinism(seed=0)", - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "initialize": [ + "$monai.utils.set_determinism(seed=123)", + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@train#trainer.run()" ] } diff --git a/models/endoscopic_tool_segmentation/docs/README.md b/models/endoscopic_tool_segmentation/docs/README.md index eabe33d1..86382d18 100644 --- a/models/endoscopic_tool_segmentation/docs/README.md +++ b/models/endoscopic_tool_segmentation/docs/README.md @@ -65,13 +65,13 @@ For more details usage instructions, visit the [MONAI Bundle Configuration Page] #### Execute training: ``` -python -m monai.bundle run training --meta_file configs/metadata.json --config_file configs/train.json --logging_file configs/logging.conf +python -m monai.bundle run --config_file configs/train.json ``` #### Override the `train` config to execute multi-GPU training: ``` -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 +torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run --config_file "['configs/train.json','configs/multi_gpu_train.json']" ``` 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 #### Override the `train` config to execute evaluation with the trained model: ``` -python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file "['configs/train.json','configs/evaluate.json']" --logging_file configs/logging.conf +python -m monai.bundle run --config_file "['configs/train.json','configs/evaluate.json']" ``` #### Override the `train` config and `evaluate` config to execute multi-GPU evaluation: ``` -torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file "['configs/train.json','configs/evaluate.json','configs/multi_gpu_evaluate.json']" --logging_file configs/logging.conf +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']" ``` #### Execute inference: ``` -python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file configs/inference.json --logging_file configs/logging.conf +python -m monai.bundle run --config_file configs/inference.json ``` #### Export checkpoint to TorchScript file: diff --git a/models/lung_nodule_ct_detection/configs/evaluate.json b/models/lung_nodule_ct_detection/configs/evaluate.json index 1e37410a..2597dbe2 100644 --- a/models/lung_nodule_ct_detection/configs/evaluate.json +++ b/models/lung_nodule_ct_detection/configs/evaluate.json @@ -41,8 +41,10 @@ "summary_ops": "*" } ], - "evaluating": [ - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "initialize": [ + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@validate#evaluator.run()" ] } diff --git a/models/lung_nodule_ct_detection/configs/inference.json b/models/lung_nodule_ct_detection/configs/inference.json index 91743d95..9dce3725 100644 --- a/models/lung_nodule_ct_detection/configs/inference.json +++ b/models/lung_nodule_ct_detection/configs/inference.json @@ -5,7 +5,7 @@ "$import glob", "$import os" ], - "bundle_root": "./", + "bundle_root": ".", "ckpt_dir": "$@bundle_root + '/models'", "output_dir": "$@bundle_root + '/eval'", "data_list_file_path": "$@bundle_root + '/LUNA16_datasplit/dataset_fold0.json'", @@ -202,8 +202,10 @@ "val_handlers": "@handlers", "amp": "@amp" }, - "evaluating": [ - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "initialize": [ + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@evaluator.run()" ] } diff --git a/models/lung_nodule_ct_detection/configs/metadata.json b/models/lung_nodule_ct_detection/configs/metadata.json index f94a3f1c..e35c57b2 100644 --- a/models/lung_nodule_ct_detection/configs/metadata.json +++ b/models/lung_nodule_ct_detection/configs/metadata.json @@ -1,7 +1,8 @@ { "schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json", - "version": "0.5.2", + "version": "0.5.3", "changelog": { + "0.5.3": "adapt to BundleWorkflow interface", "0.5.2": "black autofix format and add name tag", "0.5.1": "modify dataset key name", "0.5.0": "use detection inferer", @@ -16,13 +17,13 @@ "0.1.1": "add reference for LIDC dataset", "0.1.0": "complete the model package" }, - "monai_version": "1.0.1", - "pytorch_version": "1.13.0", - "numpy_version": "1.22.4", + "monai_version": "1.2.0rc3", + "pytorch_version": "1.13.1", + "numpy_version": "1.22.2", "optional_packages_version": { "nibabel": "4.0.1", "pytorch-ignite": "0.4.9", - "torchvision": "0.14.0" + "torchvision": "0.14.1" }, "name": "Lung nodule CT detection", "task": "CT lung nodule detection", diff --git a/models/lung_nodule_ct_detection/configs/train.json b/models/lung_nodule_ct_detection/configs/train.json index b8ce458f..dde045a2 100644 --- a/models/lung_nodule_ct_detection/configs/train.json +++ b/models/lung_nodule_ct_detection/configs/train.json @@ -3,7 +3,7 @@ "$import glob", "$import os" ], - "bundle_root": "./", + "bundle_root": ".", "ckpt_dir": "$@bundle_root + '/models'", "output_dir": "$@bundle_root + '/eval'", "data_list_file_path": "$@bundle_root + '/LUNA16_datasplit/dataset_fold0.json'", @@ -446,10 +446,12 @@ "amp": "@amp" } }, - "training": [ + "initialize": [ "os.environ['CUDA_LAUNCH_BLOCKING']=1", "$monai.utils.set_determinism(seed=123)", - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@train#trainer.run()" ] } diff --git a/models/lung_nodule_ct_detection/docs/README.md b/models/lung_nodule_ct_detection/docs/README.md index 620813eb..bcbe9f25 100644 --- a/models/lung_nodule_ct_detection/docs/README.md +++ b/models/lung_nodule_ct_detection/docs/README.md @@ -67,17 +67,17 @@ For more details usage instructions, visit the [MONAI Bundle Configuration Page] #### Execute training: ``` -python -m monai.bundle run training --meta_file configs/metadata.json --config_file configs/train.json --logging_file configs/logging.conf +python -m monai.bundle run --config_file configs/train.json ``` #### Override the `train` config to execute evaluation with the trained model: ``` -python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file "['configs/train.json','configs/evaluate.json']" --logging_file configs/logging.conf +python -m monai.bundle run --config_file "['configs/train.json','configs/evaluate.json']" ``` #### Execute inference on resampled LUNA16 images by setting `"whether_raw_luna16": false` in `inference.json`: ``` -python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file configs/inference.json --logging_file configs/logging.conf +python -m monai.bundle run --config_file configs/inference.json ``` With the same command, we can execute inference on original LUNA16 images by setting `"whether_raw_luna16": true` in `inference.json`. Remember to also set `"data_list_file_path": "$@bundle_root + '/LUNA16_datasplit/mhd_original/dataset_fold0.json'"` and change `"dataset_dir"`. diff --git a/models/pathology_nuclei_classification/configs/evaluate.json b/models/pathology_nuclei_classification/configs/evaluate.json index 664de87a..e647b944 100644 --- a/models/pathology_nuclei_classification/configs/evaluate.json +++ b/models/pathology_nuclei_classification/configs/evaluate.json @@ -64,12 +64,14 @@ "summary_ops": "*" } ], - "evaluating": [ + "initialize": [ "$import sys", "$sys.path.append(@bundle_root)", "$setattr(torch.backends.cudnn, 'benchmark', True)", "$import scripts", - "$monai.data.register_writer('json', scripts.ClassificationWriter)", + "$monai.data.register_writer('json', scripts.ClassificationWriter)" + ], + "run": [ "$@validate#evaluator.run()" ] } diff --git a/models/pathology_nuclei_classification/configs/inference.json b/models/pathology_nuclei_classification/configs/inference.json index 0bde05ae..be93bbab 100644 --- a/models/pathology_nuclei_classification/configs/inference.json +++ b/models/pathology_nuclei_classification/configs/inference.json @@ -5,7 +5,7 @@ "$import pathlib", "$import os" ], - "bundle_root": "/workspace/data/pathology_nuclei_classification", + "bundle_root": ".", "output_dir": "$@bundle_root + '/eval'", "dataset_dir": "/workspace/data/CoNSePNuclei", "images": "$list(sorted(glob.glob(@dataset_dir + '/Test/Images/*.png')))[:1]", @@ -107,10 +107,12 @@ "val_handlers": "@handlers", "amp": true }, - "evaluating": [ + "initialize": [ "$setattr(torch.backends.cudnn, 'benchmark', True)", "$import scripts", - "$monai.data.register_writer('json', scripts.ClassificationWriter)", + "$monai.data.register_writer('json', scripts.ClassificationWriter)" + ], + "run": [ "$@evaluator.run()" ] } diff --git a/models/pathology_nuclei_classification/configs/metadata.json b/models/pathology_nuclei_classification/configs/metadata.json index 0b21fc9c..c27eb646 100644 --- a/models/pathology_nuclei_classification/configs/metadata.json +++ b/models/pathology_nuclei_classification/configs/metadata.json @@ -1,19 +1,21 @@ { "schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json", - "version": "0.0.5", + "version": "0.0.6", "changelog": { + "0.0.6": "adapt to BundleWorkflow interface", "0.0.5": "add name tag", "0.0.4": "Fix evaluation", "0.0.3": "Update to use MONAI 1.1.0", "0.0.2": "Update The Torch Vision Transform", "0.0.1": "initialize the model package structure" }, - "monai_version": "1.1.0", - "pytorch_version": "1.13.0", - "numpy_version": "1.21.2", + "monai_version": "1.2.0rc3", + "pytorch_version": "1.13.1", + "numpy_version": "1.22.2", "optional_packages_version": { "nibabel": "4.0.1", - "pytorch-ignite": "0.4.9" + "pytorch-ignite": "0.4.9", + "torchvision": "0.14.1" }, "name": "Pathology nuclei classification", "task": "Pathology Nuclei classification", diff --git a/models/pathology_nuclei_classification/configs/multi_gpu_evaluate.json b/models/pathology_nuclei_classification/configs/multi_gpu_evaluate.json index bbc1270d..d2ce690f 100644 --- a/models/pathology_nuclei_classification/configs/multi_gpu_evaluate.json +++ b/models/pathology_nuclei_classification/configs/multi_gpu_evaluate.json @@ -15,18 +15,22 @@ }, "validate#dataloader#sampler": "@validate#sampler", "validate#handlers#1#_disabled_": "$dist.get_rank() > 0", - "evaluating": [ + "initialize": [ "$import sys", "$sys.path.append(@bundle_root)", "$import torch.distributed as dist", - "$dist.init_process_group(backend='nccl')", + "$dist.is_initialized() or dist.init_process_group(backend='nccl')", "$torch.cuda.set_device(@device)", "$setattr(torch.backends.cudnn, 'benchmark', True)", "$import logging", "$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)", "$import scripts", - "$monai.data.register_writer('json', scripts.ClassificationWriter)", - "$@validate#evaluator.run()", + "$monai.data.register_writer('json', scripts.ClassificationWriter)" + ], + "run": [ + "$@validate#evaluator.run()" + ], + "finalize": [ "$dist.destroy_process_group()" ] } diff --git a/models/pathology_nuclei_classification/configs/multi_gpu_train.json b/models/pathology_nuclei_classification/configs/multi_gpu_train.json index 335753c1..0d4702de 100644 --- a/models/pathology_nuclei_classification/configs/multi_gpu_train.json +++ b/models/pathology_nuclei_classification/configs/multi_gpu_train.json @@ -24,18 +24,22 @@ }, "validate#dataloader#sampler": "@validate#sampler", "validate#evaluator#val_handlers": "$None if dist.get_rank() > 0 else @validate#handlers", - "training": [ + "initialize": [ "$import sys", "$sys.path.append(@bundle_root)", "$import torch.distributed as dist", - "$dist.init_process_group(backend='nccl')", + "$dist.is_initialized() or dist.init_process_group(backend='nccl')", "$torch.cuda.set_device(@device)", "$monai.utils.set_determinism(seed=123)", "$setattr(torch.backends.cudnn, 'benchmark', True)", "$import logging", "$@train#trainer.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)", - "$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)", - "$@train#trainer.run()", + "$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)" + ], + "run": [ + "$@train#trainer.run()" + ], + "finalize": [ "$dist.destroy_process_group()" ] } diff --git a/models/pathology_nuclei_classification/configs/train.json b/models/pathology_nuclei_classification/configs/train.json index 7cfe776b..8dd74b4c 100644 --- a/models/pathology_nuclei_classification/configs/train.json +++ b/models/pathology_nuclei_classification/configs/train.json @@ -6,7 +6,7 @@ "$import pathlib", "$import os" ], - "bundle_root": "/workspace/data/pathology_nuclei_classification", + "bundle_root": ".", "ckpt_dir": "$@bundle_root + '/models'", "output_dir": "$@bundle_root + '/eval'", "dataset_dir": "/workspace/data/CoNSePNuclei", @@ -340,11 +340,13 @@ "amp": true } }, - "training": [ + "initialize": [ "$import sys", "$sys.path.append(@bundle_root)", "$monai.utils.set_determinism(seed=123)", - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@train#trainer.run()" ] } diff --git a/models/pathology_nuclei_classification/docs/README.md b/models/pathology_nuclei_classification/docs/README.md index 956b170a..d1b77087 100644 --- a/models/pathology_nuclei_classification/docs/README.md +++ b/models/pathology_nuclei_classification/docs/README.md @@ -141,13 +141,13 @@ A graph showing the validation F1-score over 50 epochs. Execute training: ``` -python -m monai.bundle run training --meta_file configs/metadata.json --config_file configs/train.json --logging_file configs/logging.conf +python -m monai.bundle run --config_file configs/train.json ``` Override the `train` config to execute multi-GPU training: ``` -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 +torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run --config_file "['configs/train.json','configs/multi_gpu_train.json']" ``` 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 Override the `train` config to execute evaluation with the trained model: ``` -python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file "['configs/train.json','configs/evaluate.json']" --logging_file configs/logging.conf +python -m monai.bundle run --config_file "['configs/train.json','configs/evaluate.json']" ``` Override the `train` config and `evaluate` config to execute multi-GPU evaluation: ``` -torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file "['configs/train.json','configs/evaluate.json','configs/multi_gpu_evaluate.json']" --logging_file configs/logging.conf +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']" ``` Execute inference: ``` -python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file configs/inference.json --logging_file configs/logging.conf +python -m monai.bundle run --config_file configs/inference.json ``` # Disclaimer diff --git a/models/pathology_nuclei_segmentation_classification/configs/evaluate.json b/models/pathology_nuclei_segmentation_classification/configs/evaluate.json index bd8f29ba..2a37bc1c 100644 --- a/models/pathology_nuclei_segmentation_classification/configs/evaluate.json +++ b/models/pathology_nuclei_segmentation_classification/configs/evaluate.json @@ -31,8 +31,10 @@ "summary_ops": "*" } ], - "evaluating": [ - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "initialize": [ + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@validate#evaluator.run()" ] } diff --git a/models/pathology_nuclei_segmentation_classification/configs/inference.json b/models/pathology_nuclei_segmentation_classification/configs/inference.json index 6c46ff3d..53c9adab 100644 --- a/models/pathology_nuclei_segmentation_classification/configs/inference.json +++ b/models/pathology_nuclei_segmentation_classification/configs/inference.json @@ -3,7 +3,7 @@ "$import glob", "$import os" ], - "bundle_root": "$os.getcwd()", + "bundle_root": ".", "output_dir": "$os.path.join(@bundle_root, 'eval')", "dataset_dir": "/workspace/Data/Pathology/CoNSeP/Test/Images", "num_cpus": 2, @@ -144,8 +144,10 @@ "inferer": "@inferer", "amp": true }, - "evaluating": [ - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "initialize": [ + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@evaluator.run()" ] } diff --git a/models/pathology_nuclei_segmentation_classification/configs/metadata.json b/models/pathology_nuclei_segmentation_classification/configs/metadata.json index 3cce0bfc..1cbe27d7 100644 --- a/models/pathology_nuclei_segmentation_classification/configs/metadata.json +++ b/models/pathology_nuclei_segmentation_classification/configs/metadata.json @@ -1,14 +1,15 @@ { "schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_hovernet_20221124.json", - "version": "0.1.3", + "version": "0.1.4", "changelog": { + "0.1.4": "adapt to BundleWorkflow interface", "0.1.3": "add name tag", "0.1.2": "update the workflow figure", "0.1.1": "update to use monai 1.1.0", "0.1.0": "complete the model package" }, - "monai_version": "1.1.0", - "pytorch_version": "1.13.0", + "monai_version": "1.2.0rc3", + "pytorch_version": "1.13.1", "numpy_version": "1.22.2", "optional_packages_version": { "scikit-image": "0.19.3", diff --git a/models/pathology_nuclei_segmentation_classification/configs/multi_gpu_train.json b/models/pathology_nuclei_segmentation_classification/configs/multi_gpu_train.json index 0663a3ae..586aa2b9 100644 --- a/models/pathology_nuclei_segmentation_classification/configs/multi_gpu_train.json +++ b/models/pathology_nuclei_segmentation_classification/configs/multi_gpu_train.json @@ -24,13 +24,17 @@ }, "validate#dataloader#sampler": "@validate#sampler", "validate#evaluator#val_handlers": "$None if dist.get_rank() > 0 else @validate#handlers", - "training": [ + "initialize": [ "$import torch.distributed as dist", - "$dist.init_process_group(backend='nccl')", + "$dist.is_initialized() or dist.init_process_group(backend='nccl')", "$torch.cuda.set_device(@device)", "$monai.utils.set_determinism(seed=321)", - "$setattr(torch.backends.cudnn, 'benchmark', True)", - "$@train#trainer.run()", + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ + "$@train#trainer.run()" + ], + "finalize": [ "$dist.destroy_process_group()" ] } diff --git a/models/pathology_nuclei_segmentation_classification/configs/train.json b/models/pathology_nuclei_segmentation_classification/configs/train.json index 9e359c6a..d3042f8f 100644 --- a/models/pathology_nuclei_segmentation_classification/configs/train.json +++ b/models/pathology_nuclei_segmentation_classification/configs/train.json @@ -4,7 +4,7 @@ "$import os", "$import skimage" ], - "bundle_root": "$os.getcwd()", + "bundle_root": ".", "ckpt_dir_stage0": "$os.path.join(@bundle_root, 'models', 'stage0')", "ckpt_dir_stage1": "$os.path.join(@bundle_root, 'models')", "ckpt_path_stage0": "$os.path.join(@ckpt_dir_stage0, 'model.pt')", @@ -517,9 +517,11 @@ "amp": "@amp" } }, - "training": [ + "initialize": [ "$monai.utils.set_determinism(seed=321)", - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@train#trainer.run()" ] } diff --git a/models/pathology_nuclei_segmentation_classification/docs/README.md b/models/pathology_nuclei_segmentation_classification/docs/README.md index d16ce578..cd5c67b0 100644 --- a/models/pathology_nuclei_segmentation_classification/docs/README.md +++ b/models/pathology_nuclei_segmentation_classification/docs/README.md @@ -88,13 +88,13 @@ Execute training: - Run first stage ``` -python -m monai.bundle run training --meta_file configs/metadata.json --config_file configs/train.json --logging_file configs/logging.conf --network_def#pretrained_url `PRETRAIN_MODEL_URL` --stage 0 +python -m monai.bundle run --config_file configs/train.json --network_def#pretrained_url `PRETRAIN_MODEL_URL` --stage 0 ``` - Run second stage ``` -python -m monai.bundle run training --meta_file configs/metadata.json --config_file configs/train.json --logging_file configs/logging.conf --network_def#freeze_encoder false --network_def#pretrained_url None --stage 1 +python -m monai.bundle run --config_file configs/train.json --network_def#freeze_encoder false --network_def#pretrained_url None --stage 1 ``` Override the `train` config to execute multi-GPU training: @@ -102,25 +102,25 @@ Override the `train` config to execute multi-GPU training: - Run first stage ``` -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 --train#dataloader#batch_size 8 --network_def#freeze_encoder true --network_def#pretrained_url `PRETRAIN_MODEL_URL` --stage 0 +torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run --config_file "['configs/train.json','configs/multi_gpu_train.json']" --train#dataloader#batch_size 8 --network_def#freeze_encoder true --network_def#pretrained_url `PRETRAIN_MODEL_URL` --stage 0 ``` - Run second stage ``` -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 --train#dataloader#batch_size 4 --network_def#freeze_encoder false --network_def#pretrained_url None --stage 1 +torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run --config_file "['configs/train.json','configs/multi_gpu_train.json']" --train#dataloader#batch_size 4 --network_def#freeze_encoder false --network_def#pretrained_url None --stage 1 ``` Override the `train` config to execute evaluation with the trained model: ``` -python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file "['configs/train.json','configs/evaluate.json']" --logging_file configs/logging.conf +python -m monai.bundle run --config_file "['configs/train.json','configs/evaluate.json']" ``` ### Execute inference ``` -python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file configs/inference.json --logging_file configs/logging.conf +python -m monai.bundle run --config_file configs/inference.json ``` # Disclaimer diff --git a/models/pathology_nuclick_annotation/configs/evaluate.json b/models/pathology_nuclick_annotation/configs/evaluate.json index 158c9c82..97970daf 100644 --- a/models/pathology_nuclick_annotation/configs/evaluate.json +++ b/models/pathology_nuclick_annotation/configs/evaluate.json @@ -49,10 +49,12 @@ "summary_ops": "*" } ], - "evaluating": [ + "initialize": [ "$import sys", "$sys.path.append(@bundle_root)", - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@validate#evaluator.run()" ] } diff --git a/models/pathology_nuclick_annotation/configs/inference.json b/models/pathology_nuclick_annotation/configs/inference.json index fa9caba7..32d0e4ac 100644 --- a/models/pathology_nuclick_annotation/configs/inference.json +++ b/models/pathology_nuclick_annotation/configs/inference.json @@ -5,7 +5,7 @@ "$import pathlib", "$import os" ], - "bundle_root": "/workspace/data/pathology_nuclick_annotation", + "bundle_root": ".", "output_dir": "$@bundle_root + '/eval'", "dataset_dir": "/workspace/data/CoNSePNuclei", "images": "$list(sorted(glob.glob(@dataset_dir + '/Test/Images/*.png')))[:1]", @@ -123,8 +123,10 @@ "val_handlers": "@handlers", "amp": true }, - "evaluating": [ - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "initialize": [ + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@evaluator.run()" ] } diff --git a/models/pathology_nuclick_annotation/configs/metadata.json b/models/pathology_nuclick_annotation/configs/metadata.json index 309eaea9..33c56a70 100644 --- a/models/pathology_nuclick_annotation/configs/metadata.json +++ b/models/pathology_nuclick_annotation/configs/metadata.json @@ -1,19 +1,21 @@ { "schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json", - "version": "0.0.5", + "version": "0.0.6", "changelog": { + "0.0.6": "adapt to BundleWorkflow interface", "0.0.5": "add name tag", "0.0.4": "Fix evaluation", "0.0.3": "Update to use MONAI 1.1.0", "0.0.2": "Update The Torch Vision Transform", "0.0.1": "initialize the model package structure" }, - "monai_version": "1.1.0", - "pytorch_version": "1.13.0", - "numpy_version": "1.21.2", + "monai_version": "1.2.0rc3", + "pytorch_version": "1.13.1", + "numpy_version": "1.22.2", "optional_packages_version": { "nibabel": "4.0.1", - "pytorch-ignite": "0.4.9" + "pytorch-ignite": "0.4.9", + "torchvision": "0.14.1" }, "name": "Pathology nuclick annotation", "task": "Pathology Nuclick annotation", diff --git a/models/pathology_nuclick_annotation/configs/multi_gpu_evaluate.json b/models/pathology_nuclick_annotation/configs/multi_gpu_evaluate.json index 188d6a46..840a9bfa 100644 --- a/models/pathology_nuclick_annotation/configs/multi_gpu_evaluate.json +++ b/models/pathology_nuclick_annotation/configs/multi_gpu_evaluate.json @@ -15,16 +15,20 @@ }, "validate#dataloader#sampler": "@validate#sampler", "validate#handlers#1#_disabled_": "$dist.get_rank() > 0", - "evaluating": [ + "initialize": [ "$import sys", "$sys.path.append(@bundle_root)", "$import torch.distributed as dist", - "$dist.init_process_group(backend='nccl')", + "$dist.is_initialized() or dist.init_process_group(backend='nccl')", "$torch.cuda.set_device(@device)", "$setattr(torch.backends.cudnn, 'benchmark', True)", "$import logging", - "$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)", - "$@validate#evaluator.run()", + "$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)" + ], + "run": [ + "$@validate#evaluator.run()" + ], + "finalize": [ "$dist.destroy_process_group()" ] } diff --git a/models/pathology_nuclick_annotation/configs/multi_gpu_train.json b/models/pathology_nuclick_annotation/configs/multi_gpu_train.json index 335753c1..0d4702de 100644 --- a/models/pathology_nuclick_annotation/configs/multi_gpu_train.json +++ b/models/pathology_nuclick_annotation/configs/multi_gpu_train.json @@ -24,18 +24,22 @@ }, "validate#dataloader#sampler": "@validate#sampler", "validate#evaluator#val_handlers": "$None if dist.get_rank() > 0 else @validate#handlers", - "training": [ + "initialize": [ "$import sys", "$sys.path.append(@bundle_root)", "$import torch.distributed as dist", - "$dist.init_process_group(backend='nccl')", + "$dist.is_initialized() or dist.init_process_group(backend='nccl')", "$torch.cuda.set_device(@device)", "$monai.utils.set_determinism(seed=123)", "$setattr(torch.backends.cudnn, 'benchmark', True)", "$import logging", "$@train#trainer.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)", - "$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)", - "$@train#trainer.run()", + "$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)" + ], + "run": [ + "$@train#trainer.run()" + ], + "finalize": [ "$dist.destroy_process_group()" ] } diff --git a/models/pathology_nuclick_annotation/configs/train.json b/models/pathology_nuclick_annotation/configs/train.json index 4fdb373a..35612e17 100644 --- a/models/pathology_nuclick_annotation/configs/train.json +++ b/models/pathology_nuclick_annotation/configs/train.json @@ -6,7 +6,7 @@ "$import pathlib", "$import os" ], - "bundle_root": "/workspace/data/pathology_nuclick_annotation", + "bundle_root": ".", "ckpt_dir": "$@bundle_root + '/models'", "output_dir": "$@bundle_root + '/eval'", "dataset_dir": "/workspace/data/CoNSePNuclei", @@ -318,11 +318,13 @@ "amp": true } }, - "training": [ + "initialize": [ "$import sys", "$sys.path.append(@bundle_root)", "$monai.utils.set_determinism(seed=123)", - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@train#trainer.run()" ] } diff --git a/models/pathology_nuclick_annotation/docs/README.md b/models/pathology_nuclick_annotation/docs/README.md index be81fc40..67d8663a 100644 --- a/models/pathology_nuclick_annotation/docs/README.md +++ b/models/pathology_nuclick_annotation/docs/README.md @@ -120,13 +120,13 @@ A graph showing the validation mean Dice over 50 epochs. Execute training: ``` -python -m monai.bundle run training --meta_file configs/metadata.json --config_file configs/train.json --logging_file configs/logging.conf +python -m monai.bundle run --config_file configs/train.json ``` Override the `train` config to execute multi-GPU training: ``` -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 +torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run --config_file "['configs/train.json','configs/multi_gpu_train.json']" ``` 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. @@ -135,19 +135,19 @@ Please refer to [pytorch's official tutorial](https://pytorch.org/tutorials/inte Override the `train` config to execute evaluation with the trained model: ``` -python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file "['configs/train.json','configs/evaluate.json']" --logging_file configs/logging.conf +python -m monai.bundle run --config_file "['configs/train.json','configs/evaluate.json']" ``` Override the `train` config and `evaluate` config to execute multi-GPU evaluation: ``` -torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file "['configs/train.json','configs/evaluate.json','configs/multi_gpu_evaluate.json']" --logging_file configs/logging.conf +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']" ``` Execute inference: ``` -python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file configs/inference.json --logging_file configs/logging.conf +python -m monai.bundle run --config_file configs/inference.json ``` # Disclaimer diff --git a/models/pathology_tumor_detection/configs/inference.json b/models/pathology_tumor_detection/configs/inference.json index f6a5b1f8..8694c6f9 100644 --- a/models/pathology_tumor_detection/configs/inference.json +++ b/models/pathology_tumor_detection/configs/inference.json @@ -125,8 +125,10 @@ "amp": true, "decollate": false }, - "evaluating": [ - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "initialize": [ + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@evaluator.run()" ] } diff --git a/models/pathology_tumor_detection/configs/metadata.json b/models/pathology_tumor_detection/configs/metadata.json index dcdaaf79..5019315c 100644 --- a/models/pathology_tumor_detection/configs/metadata.json +++ b/models/pathology_tumor_detection/configs/metadata.json @@ -1,7 +1,8 @@ { "schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json", - "version": "0.4.8", + "version": "0.4.9", "changelog": { + "0.4.9": "adapt to BundleWorkflow interface", "0.4.8": "update the readme file with TensorRT convert", "0.4.7": "add name tag", "0.4.6": "modify dataset key name", @@ -20,12 +21,12 @@ "0.1.0": "initialize release of the bundle" }, "monai_version": "1.2.0rc3", - "pytorch_version": "1.13.0", - "numpy_version": "1.21.2", + "pytorch_version": "1.13.1", + "numpy_version": "1.22.2", "optional_packages_version": { - "cucim": "22.04", + "cucim": "22.8.1", "pandas": "1.3.5", - "torchvision": "0.14.0" + "torchvision": "0.14.1" }, "name": "Pathology tumor detection", "task": "Pathology metastasis detection", diff --git a/models/pathology_tumor_detection/configs/multi_gpu_train.json b/models/pathology_tumor_detection/configs/multi_gpu_train.json index 893815cd..fd55dbc0 100644 --- a/models/pathology_tumor_detection/configs/multi_gpu_train.json +++ b/models/pathology_tumor_detection/configs/multi_gpu_train.json @@ -24,13 +24,17 @@ }, "validate#dataloader#sampler": "@validate#sampler", "validate#evaluator#val_handlers": "$None if dist.get_rank() > 0 else @validate#handlers", - "training": [ + "initialize": [ "$import torch.distributed as dist", - "$dist.init_process_group(backend='nccl')", + "$dist.is_initialized() or dist.init_process_group(backend='nccl')", "$torch.cuda.set_device(@device)", "$monai.utils.set_determinism(seed=123)", - "$setattr(torch.backends.cudnn, 'benchmark', True)", - "$@train#trainer.run()", + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ + "$@train#trainer.run()" + ], + "finalize": [ "$dist.destroy_process_group()" ] } diff --git a/models/pathology_tumor_detection/configs/train.json b/models/pathology_tumor_detection/configs/train.json index b92a2e24..8fca5781 100644 --- a/models/pathology_tumor_detection/configs/train.json +++ b/models/pathology_tumor_detection/configs/train.json @@ -371,9 +371,11 @@ "amp": true } }, - "training": [ + "initialize": [ "$monai.utils.set_determinism(seed=15)", - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@train#trainer.run()" ] } diff --git a/models/pathology_tumor_detection/docs/README.md b/models/pathology_tumor_detection/docs/README.md index 560c1a8b..b3e8682f 100644 --- a/models/pathology_tumor_detection/docs/README.md +++ b/models/pathology_tumor_detection/docs/README.md @@ -85,13 +85,13 @@ For more details usage instructions, visit the [MONAI Bundle Configuration Page] #### Execute training ``` -python -m monai.bundle run training --meta_file configs/metadata.json --config_file configs/train.json --logging_file configs/logging.conf +python -m monai.bundle run --config_file configs/train.json ``` #### Override the `train` config to execute multi-GPU training ``` -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 +torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run --config_file "['configs/train.json','configs/multi_gpu_train.json']" ``` 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 #### Execute inference ``` -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 +CUDA_LAUNCH_BLOCKING=1 python -m monai.bundle run --config_file configs/inference.json ``` #### Evaluate FROC metric diff --git a/models/pathology_tumor_detection/scripts/lesion_froc.py b/models/pathology_tumor_detection/scripts/lesion_froc.py index 2d11d732..0640675e 100644 --- a/models/pathology_tumor_detection/scripts/lesion_froc.py +++ b/models/pathology_tumor_detection/scripts/lesion_froc.py @@ -17,7 +17,7 @@ def load_data(ground_truth_dir: str, eval_dir: str, level: int, spacing: float): for prob_name in prob_files: if prob_name.endswith(".npy"): sample = { - "tumor_mask": full_path(ground_truth_dir, prob_name[:-4]), + "tumor_mask": full_path(ground_truth_dir, prob_name.replace("npy", "tif")), "prob_map": full_path(eval_dir, prob_name), "level": level, "pixel_spacing": spacing, diff --git a/models/spleen_ct_segmentation/configs/metadata.json b/models/spleen_ct_segmentation/configs/metadata.json index 30ce3e46..d9b3cb0e 100644 --- a/models/spleen_ct_segmentation/configs/metadata.json +++ b/models/spleen_ct_segmentation/configs/metadata.json @@ -1,7 +1,8 @@ { "schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json", - "version": "0.4.1", + "version": "0.4.2", "changelog": { + "0.4.2": "use torch 1.13.1", "0.4.1": "update the readme file with TensorRT convert", "0.4.0": "fix multi-gpu train config typo", "0.3.9": "adapt to BundleWorkflow interface", @@ -20,8 +21,8 @@ "0.0.1": "initialize the model package structure" }, "monai_version": "1.2.0rc3", - "pytorch_version": "1.13.0", - "numpy_version": "1.21.2", + "pytorch_version": "1.13.1", + "numpy_version": "1.22.2", "optional_packages_version": { "nibabel": "4.0.1", "pytorch-ignite": "0.4.9" diff --git a/models/spleen_deepedit_annotation/configs/evaluate.json b/models/spleen_deepedit_annotation/configs/evaluate.json index f47d97ee..e349832d 100644 --- a/models/spleen_deepedit_annotation/configs/evaluate.json +++ b/models/spleen_deepedit_annotation/configs/evaluate.json @@ -57,8 +57,10 @@ "summary_ops": "*" } ], - "evaluating": [ - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "initialize": [ + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@validate#evaluator.run()" ] } diff --git a/models/spleen_deepedit_annotation/configs/inference.json b/models/spleen_deepedit_annotation/configs/inference.json index 059c9e0d..6ed1b8b2 100644 --- a/models/spleen_deepedit_annotation/configs/inference.json +++ b/models/spleen_deepedit_annotation/configs/inference.json @@ -4,7 +4,7 @@ "$import os", "$import ignite" ], - "bundle_root": "/workspace/tutorials/deepedit/deepedit_bundle", + "bundle_root": ".", "output_dir": "$@bundle_root + '/eval'", "dataset_dir": "/workspace/Datasets/MSD_datasets/Task09_Spleen", "datalist": "$list(sorted(glob.glob(@dataset_dir + '/imagesTs/*.nii.gz')))", @@ -176,8 +176,10 @@ "val_handlers": "@handlers", "amp": true }, - "evaluating": [ - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "initialize": [ + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@evaluator.run()" ] } diff --git a/models/spleen_deepedit_annotation/configs/metadata.json b/models/spleen_deepedit_annotation/configs/metadata.json index aea699e8..0b284b3f 100644 --- a/models/spleen_deepedit_annotation/configs/metadata.json +++ b/models/spleen_deepedit_annotation/configs/metadata.json @@ -1,7 +1,8 @@ { "schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json", - "version": "0.3.7", + "version": "0.3.8", "changelog": { + "0.3.8": "adapt to BundleWorkflow interface", "0.3.7": "add name tag", "0.3.6": "restructure readme to match updated template", "0.3.5": "update metric in metadata", @@ -14,9 +15,9 @@ "0.1.0": "complete the model package", "0.0.1": "initialize the model package structure" }, - "monai_version": "1.0.1", - "pytorch_version": "1.13.0", - "numpy_version": "1.21.2", + "monai_version": "1.2.0rc3", + "pytorch_version": "1.13.1", + "numpy_version": "1.22.2", "optional_packages_version": { "nibabel": "4.0.1", "pytorch-ignite": "0.4.9", diff --git a/models/spleen_deepedit_annotation/configs/multi_gpu_train.json b/models/spleen_deepedit_annotation/configs/multi_gpu_train.json index 893815cd..fd55dbc0 100644 --- a/models/spleen_deepedit_annotation/configs/multi_gpu_train.json +++ b/models/spleen_deepedit_annotation/configs/multi_gpu_train.json @@ -24,13 +24,17 @@ }, "validate#dataloader#sampler": "@validate#sampler", "validate#evaluator#val_handlers": "$None if dist.get_rank() > 0 else @validate#handlers", - "training": [ + "initialize": [ "$import torch.distributed as dist", - "$dist.init_process_group(backend='nccl')", + "$dist.is_initialized() or dist.init_process_group(backend='nccl')", "$torch.cuda.set_device(@device)", "$monai.utils.set_determinism(seed=123)", - "$setattr(torch.backends.cudnn, 'benchmark', True)", - "$@train#trainer.run()", + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ + "$@train#trainer.run()" + ], + "finalize": [ "$dist.destroy_process_group()" ] } diff --git a/models/spleen_deepedit_annotation/configs/train.json b/models/spleen_deepedit_annotation/configs/train.json index ae2e1af3..7d831dac 100644 --- a/models/spleen_deepedit_annotation/configs/train.json +++ b/models/spleen_deepedit_annotation/configs/train.json @@ -4,7 +4,7 @@ "$import os", "$import ignite" ], - "bundle_root": "/workspace/tutorials/deepedit/deepedit_bundle", + "bundle_root": ".", "ckpt_dir": "$@bundle_root + '/models'", "output_dir": "$@bundle_root + '/eval'", "dataset_dir": "/workspace/Datasets/MSD_datasets/Task09_Spleen", @@ -425,9 +425,11 @@ "amp": true } }, - "training": [ + "initialize": [ "$monai.utils.set_determinism(seed=123)", - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@train#trainer.run()" ] } diff --git a/models/spleen_deepedit_annotation/docs/README.md b/models/spleen_deepedit_annotation/docs/README.md index a9cbc717..80668334 100644 --- a/models/spleen_deepedit_annotation/docs/README.md +++ b/models/spleen_deepedit_annotation/docs/README.md @@ -55,13 +55,13 @@ For more details usage instructions, visit the [MONAI Bundle Configuration Page] #### Execute training: ``` -python -m monai.bundle run training --meta_file configs/metadata.json --config_file configs/train.json --logging_file configs/logging.conf +python -m monai.bundle run --config_file configs/train.json ``` #### Override the `train` config to execute multi-GPU training: ``` -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 +torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run --config_file "['configs/train.json','configs/multi_gpu_train.json']" ``` 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). @@ -69,13 +69,13 @@ Please note that the distributed training-related options depend on the actual r #### Override the `train` config to execute evaluation with the trained model: ``` -python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file "['configs/train.json','configs/evaluate.json']" --logging_file configs/logging.conf +python -m monai.bundle run --config_file "['configs/train.json','configs/evaluate.json']" ``` #### Execute inference: ``` -python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file configs/inference.json --logging_file configs/logging.conf +python -m monai.bundle run --config_file configs/inference.json ``` # References diff --git a/models/swin_unetr_btcv_segmentation/configs/evaluate.json b/models/swin_unetr_btcv_segmentation/configs/evaluate.json index 8094921f..addffe62 100644 --- a/models/swin_unetr_btcv_segmentation/configs/evaluate.json +++ b/models/swin_unetr_btcv_segmentation/configs/evaluate.json @@ -70,8 +70,10 @@ "summary_ops": "*" } ], - "evaluating": [ - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "initialize": [ + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@validate#evaluator.run()" ] } diff --git a/models/swin_unetr_btcv_segmentation/configs/inference.json b/models/swin_unetr_btcv_segmentation/configs/inference.json index 5b382e28..d046106c 100644 --- a/models/swin_unetr_btcv_segmentation/configs/inference.json +++ b/models/swin_unetr_btcv_segmentation/configs/inference.json @@ -3,9 +3,9 @@ "$import glob", "$import os" ], - "bundle_root": "/workspace/MONAI_Bundle/swin_unetr_btcv_segmentation/", + "bundle_root": ".", "output_dir": "$@bundle_root + '/eval'", - "dataset_dir": "/dataset/dataset0", + "dataset_dir": "/workspace/data/RawData/", "datalist": "$list(sorted(glob.glob(@dataset_dir + '/imagesTs/*.nii.gz')))", "device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')", "network_def": { @@ -135,8 +135,10 @@ "val_handlers": "@handlers", "amp": true }, - "evaluating": [ - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "initialize": [ + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@evaluator.run()" ] } diff --git a/models/swin_unetr_btcv_segmentation/configs/metadata.json b/models/swin_unetr_btcv_segmentation/configs/metadata.json index 1de4e9be..671593d7 100644 --- a/models/swin_unetr_btcv_segmentation/configs/metadata.json +++ b/models/swin_unetr_btcv_segmentation/configs/metadata.json @@ -1,7 +1,9 @@ { "schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json", - "version": "0.4.2", + "version": "0.4.4", "changelog": { + "0.4.4": "update numbers", + "0.4.3": "adapt to BundleWorkflow interface", "0.4.2": "fix train params of use_checkpoint", "0.4.1": "update params to supprot torch.jit.trace torchscript conversion", "0.4.0": "add name tag", @@ -19,12 +21,12 @@ "0.1.0": "complete the model package", "0.0.1": "initialize the model package structure" }, - "monai_version": "1.0.1", - "pytorch_version": "1.13.0", - "numpy_version": "1.21.2", + "monai_version": "1.2.0rc3", + "pytorch_version": "1.13.1", + "numpy_version": "1.22.2", "optional_packages_version": { - "nibabel": "3.2.1", - "pytorch-ignite": "0.4.8", + "nibabel": "4.0.1", + "pytorch-ignite": "0.4.9", "einops": "0.4.1" }, "name": "Swin UNETR BTCV segmentation", @@ -38,7 +40,7 @@ "label_classes": "multi-channel data,0:background,1:spleen, 2:Right Kidney, 3:Left Kideny, 4:Gallbladder, 5:Esophagus, 6:Liver, 7:Stomach, 8:Aorta, 9:IVC, 10:Portal and Splenic Veins, 11:Pancreas, 12:Right adrenal gland, 13:Left adrenal gland", "pred_classes": "14 channels OneHot data, 0:background,1:spleen, 2:Right Kidney, 3:Left Kideny, 4:Gallbladder, 5:Esophagus, 6:Liver, 7:Stomach, 8:Aorta, 9:IVC, 10:Portal and Splenic Veins, 11:Pancreas, 12:Right adrenal gland, 13:Left adrenal gland", "eval_metrics": { - "mean_dice": 0.8269 + "mean_dice": 0.812 }, "intended_use": "This is an example, not to be used for diagnostic purposes", "references": [ diff --git a/models/swin_unetr_btcv_segmentation/configs/multi_gpu_train.json b/models/swin_unetr_btcv_segmentation/configs/multi_gpu_train.json index 893815cd..fd55dbc0 100644 --- a/models/swin_unetr_btcv_segmentation/configs/multi_gpu_train.json +++ b/models/swin_unetr_btcv_segmentation/configs/multi_gpu_train.json @@ -24,13 +24,17 @@ }, "validate#dataloader#sampler": "@validate#sampler", "validate#evaluator#val_handlers": "$None if dist.get_rank() > 0 else @validate#handlers", - "training": [ + "initialize": [ "$import torch.distributed as dist", - "$dist.init_process_group(backend='nccl')", + "$dist.is_initialized() or dist.init_process_group(backend='nccl')", "$torch.cuda.set_device(@device)", "$monai.utils.set_determinism(seed=123)", - "$setattr(torch.backends.cudnn, 'benchmark', True)", - "$@train#trainer.run()", + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ + "$@train#trainer.run()" + ], + "finalize": [ "$dist.destroy_process_group()" ] } diff --git a/models/swin_unetr_btcv_segmentation/configs/train.json b/models/swin_unetr_btcv_segmentation/configs/train.json index e5694677..33c8d660 100644 --- a/models/swin_unetr_btcv_segmentation/configs/train.json +++ b/models/swin_unetr_btcv_segmentation/configs/train.json @@ -4,10 +4,10 @@ "$import os", "$import ignite" ], - "bundle_root": "/workspace/MONAI_Bundle/swin_unetr_btcv_segmentation/", + "bundle_root": ".", "ckpt_dir": "$@bundle_root + '/models'", "output_dir": "$@bundle_root + '/eval'", - "dataset_dir": "/dataset/dataset0", + "dataset_dir": "/workspace/data/RawData/", "images": "$list(sorted(glob.glob(@dataset_dir + '/imagesTr/*.nii.gz')))", "labels": "$list(sorted(glob.glob(@dataset_dir + '/labelsTr/*.nii.gz')))", "val_interval": 5, @@ -318,9 +318,11 @@ "amp": true } }, - "training": [ + "initialize": [ "$monai.utils.set_determinism(seed=123)", - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@train#trainer.run()" ] } diff --git a/models/swin_unetr_btcv_segmentation/docs/README.md b/models/swin_unetr_btcv_segmentation/docs/README.md index a659935d..1d18f3bf 100644 --- a/models/swin_unetr_btcv_segmentation/docs/README.md +++ b/models/swin_unetr_btcv_segmentation/docs/README.md @@ -52,7 +52,7 @@ The training as performed with the following: - 13: Left adrenal gland ## Performance -Dice score was used for evaluating the performance of the model. This model achieves a mean dice score of 0.8269 +Dice score was used for evaluating the performance of the model. This model achieves a mean dice score of 0.8120 #### Training Loss ![The figure shows the training loss curve for 10K iterations.](https://developer.download.nvidia.com/assets/Clara/Images/monai_swin_unetr_btcv_segmentation_trainloss_v1.png) @@ -69,13 +69,13 @@ For more details usage instructions, visit the [MONAI Bundle Configuration Page] #### Execute training: ``` -python -m monai.bundle run training --meta_file configs/metadata.json --config_file configs/train.json --logging_file configs/logging.conf +python -m monai.bundle run --config_file configs/train.json ``` #### Override the `train` config to execute multi-GPU training: ``` -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 +torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run --config_file "['configs/train.json','configs/multi_gpu_train.json']" ``` 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). @@ -83,13 +83,13 @@ Please note that the distributed training-related options depend on the actual r #### Override the `train` config to execute evaluation with the trained model: ``` -python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file "['configs/train.json','configs/evaluate.json']" --logging_file configs/logging.conf +python -m monai.bundle run --config_file "['configs/train.json','configs/evaluate.json']" ``` #### Execute inference: ``` -python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file configs/inference.json --logging_file configs/logging.conf +python -m monai.bundle run --config_file configs/inference.json ``` #### Export checkpoint to TorchScript file: diff --git a/models/wholeBody_ct_segmentation/configs/evaluate.json b/models/wholeBody_ct_segmentation/configs/evaluate.json index 2860fc2a..0c6cc91c 100644 --- a/models/wholeBody_ct_segmentation/configs/evaluate.json +++ b/models/wholeBody_ct_segmentation/configs/evaluate.json @@ -8,31 +8,31 @@ "softmax": true }, { - "_target_": "AsDiscreted", + "_target_": "Invertd", "keys": [ "pred", "label" ], - "argmax": [ + "transform": "@validate#preprocessing", + "orig_keys": "image", + "meta_key_postfix": "meta_dict", + "nearest_interp": [ true, - false + true ], - "to_onehot": 105 + "to_tensor": true }, { - "_target_": "Invertd", + "_target_": "AsDiscreted", "keys": [ "pred", "label" ], - "transform": "@validate#preprocessing", - "orig_keys": "image", - "meta_key_postfix": "meta_dict", - "nearest_interp": [ + "argmax": [ true, - true + false ], - "to_tensor": true + "to_onehot": 105 }, { "_target_": "SaveImaged", @@ -71,8 +71,10 @@ "summary_ops": "*" } ], - "evaluating": [ - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "initialize": [ + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@validate#evaluator.run()" ] } diff --git a/models/wholeBody_ct_segmentation/configs/inference.json b/models/wholeBody_ct_segmentation/configs/inference.json index b17f4ce8..94ac74c7 100644 --- a/models/wholeBody_ct_segmentation/configs/inference.json +++ b/models/wholeBody_ct_segmentation/configs/inference.json @@ -152,8 +152,10 @@ "val_handlers": "@handlers", "amp": true }, - "evaluating": [ - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "initialize": [ + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@evaluator.run()" ] } diff --git a/models/wholeBody_ct_segmentation/configs/metadata.json b/models/wholeBody_ct_segmentation/configs/metadata.json index f5513a70..651b5630 100644 --- a/models/wholeBody_ct_segmentation/configs/metadata.json +++ b/models/wholeBody_ct_segmentation/configs/metadata.json @@ -1,13 +1,14 @@ { "schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json", - "version": "0.1.0", + "version": "0.1.1", "changelog": { + "0.1.1": "adapt to BundleWorkflow interface and val metric", "0.1.0": "complete the model package", "0.0.1": "initialize the model package structure" }, - "monai_version": "1.1.0", - "pytorch_version": "1.13.0", - "numpy_version": "1.21.2", + "monai_version": "1.2.0rc3", + "pytorch_version": "1.13.1", + "numpy_version": "1.22.2", "optional_packages_version": { "nibabel": "4.0.1", "pytorch-ignite": "0.4.9" @@ -23,7 +24,7 @@ "label_classes": "0 is the background, others are whole body segments", "pred_classes": "0 is the background, 104 other chanels are whole body segments", "eval_metrics": { - "mean_dice": 0.5 + "mean_dice": 0.8 }, "intended_use": "This is an example, not to be used for diagnostic purposes", "references": [ diff --git a/models/wholeBody_ct_segmentation/configs/multi_gpu_evaluate.json b/models/wholeBody_ct_segmentation/configs/multi_gpu_evaluate.json index f6b6c6dc..0c28563d 100644 --- a/models/wholeBody_ct_segmentation/configs/multi_gpu_evaluate.json +++ b/models/wholeBody_ct_segmentation/configs/multi_gpu_evaluate.json @@ -15,14 +15,18 @@ }, "validate#dataloader#sampler": "@validate#sampler", "validate#handlers#1#_disabled_": "$dist.get_rank() > 0", - "evaluating": [ + "initialize": [ "$import torch.distributed as dist", - "$dist.init_process_group(backend='nccl')", + "$dist.is_initialized() or dist.init_process_group(backend='nccl')", "$torch.cuda.set_device(@device)", "$setattr(torch.backends.cudnn, 'benchmark', True)", "$import logging", - "$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)", - "$@validate#evaluator.run()", + "$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)" + ], + "run": [ + "$@validate#evaluator.run()" + ], + "finalize": [ "$dist.destroy_process_group()" ] } diff --git a/models/wholeBody_ct_segmentation/configs/multi_gpu_train.json b/models/wholeBody_ct_segmentation/configs/multi_gpu_train.json index 4161e527..fe16cbb0 100644 --- a/models/wholeBody_ct_segmentation/configs/multi_gpu_train.json +++ b/models/wholeBody_ct_segmentation/configs/multi_gpu_train.json @@ -24,16 +24,20 @@ }, "validate#dataloader#sampler": "@validate#sampler", "validate#evaluator#val_handlers": "$None if dist.get_rank() > 0 else @validate#handlers", - "training": [ + "initialize": [ "$import torch.distributed as dist", - "$dist.init_process_group(backend='nccl')", + "$dist.is_initialized() or dist.init_process_group(backend='nccl')", "$torch.cuda.set_device(@device)", "$monai.utils.set_determinism(seed=123)", "$setattr(torch.backends.cudnn, 'benchmark', True)", "$import logging", "$@train#trainer.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)", - "$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)", - "$@train#trainer.run()", + "$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)" + ], + "run": [ + "$@train#trainer.run()" + ], + "finalize": [ "$dist.destroy_process_group()" ] } diff --git a/models/wholeBody_ct_segmentation/configs/train.json b/models/wholeBody_ct_segmentation/configs/train.json index 9e79afd6..8caf7d2e 100644 --- a/models/wholeBody_ct_segmentation/configs/train.json +++ b/models/wholeBody_ct_segmentation/configs/train.json @@ -414,9 +414,11 @@ "amp": true } }, - "training": [ + "initialize": [ "$monai.utils.set_determinism(seed=123)", - "$setattr(torch.backends.cudnn, 'benchmark', True)", + "$setattr(torch.backends.cudnn, 'benchmark', True)" + ], + "run": [ "$@train#trainer.run()" ] } diff --git a/models/wholeBody_ct_segmentation/docs/README.md b/models/wholeBody_ct_segmentation/docs/README.md index 9a2b7fad..adb003b5 100644 --- a/models/wholeBody_ct_segmentation/docs/README.md +++ b/models/wholeBody_ct_segmentation/docs/README.md @@ -110,13 +110,13 @@ For more details usage instructions, visit the [MONAI Bundle Configuration Page] #### Execute training ``` -python -m monai.bundle run training --meta_file configs/metadata.json --config_file configs/train.json --logging_file configs/logging.conf +python -m monai.bundle run --config_file configs/train.json ``` #### Override the `train` config to execute multi-GPU training ``` -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 +torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run --config_file "['configs/train.json','configs/multi_gpu_train.json']" ``` 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). @@ -124,24 +124,24 @@ Please note that the distributed training-related options depend on the actual r #### Override the `train` config to execute evaluation with the trained model ``` -python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file "['configs/train.json','configs/evaluate.json']" --logging_file configs/logging.conf +python -m monai.bundle run --config_file "['configs/train.json','configs/evaluate.json']" ``` #### Override the `train` config and `evaluate` config to execute multi-GPU evaluation ``` -torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file "['configs/train.json','configs/evaluate.json','configs/multi_gpu_evaluate.json']" --logging_file configs/logging.conf +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']" ``` #### Execute inference ``` -python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file configs/inference.json --logging_file configs/logging.conf +python -m monai.bundle run --config_file configs/inference.json ``` #### Execute inference with Data Samples ``` -python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file configs/inference.json --logging_file configs/logging.conf --datalist "['sampledata/imagesTr/s0037.nii.gz','sampledata/imagesTr/s0038.nii.gz']" +python -m monai.bundle run --config_file configs/inference.json --datalist "['sampledata/imagesTr/s0037.nii.gz','sampledata/imagesTr/s0038.nii.gz']" ```