monai
medical
katielink commited on
Commit
83ad0c8
1 Parent(s): bd519ec

enable deterministic training

Browse files
README.md CHANGED
@@ -18,7 +18,6 @@ Datasets used in this work were provided by [Activ Surgical](https://www.activsu
18
  Since datasets are private, existing public datasets like [EndoVis 2017](https://endovissub2017-roboticinstrumentsegmentation.grand-challenge.org/Data/) can be used to train a similar model.
19
 
20
  ### Preprocessing
21
-
22
  When using EndoVis or any other dataset, it should be divided into "train", "valid" and "test" folders. Samples in each folder would better be images and converted to jpg format. Otherwise, "images", "labels", "val_images" and "val_labels" parameters in "configs/train.json" and "datalist" in "configs/inference.json" should be modified to fit given dataset. After that, "dataset_dir" parameter in "configs/train.json" and "configs/inference.json" should be changed to root folder which contains previous "train", "valid" and "test" folders.
23
 
24
  Please notice that loading data operation in this bundle is adaptive. If images and labels are not in the same format, it may lead to a mismatching problem. For example, if images are in jpg format and labels are in npy format, PIL and Numpy readers will be used separately to load images and labels. Since these two readers have their own way to parse file's shape, loaded labels will be transpose of the correct ones and incur a missmatching problem.
@@ -113,7 +112,7 @@ python -m monai.bundle ckpt_export network_def --filepath models/model.ts --ckpt
113
  python -m monai.bundle trt_export --net_id network_def --filepath models/model_trt.ts --ckpt_file models/model.pt --meta_file configs/metadata.json --config_file configs/inference.json --precision <fp32/fp16>
114
  ```
115
 
116
- #### Execute inference with the TensorRT model
117
 
118
  ```
119
  python -m monai.bundle run --config_file "['configs/inference.json', 'configs/inference_trt.json']"
 
18
  Since datasets are private, existing public datasets like [EndoVis 2017](https://endovissub2017-roboticinstrumentsegmentation.grand-challenge.org/Data/) can be used to train a similar model.
19
 
20
  ### Preprocessing
 
21
  When using EndoVis or any other dataset, it should be divided into "train", "valid" and "test" folders. Samples in each folder would better be images and converted to jpg format. Otherwise, "images", "labels", "val_images" and "val_labels" parameters in "configs/train.json" and "datalist" in "configs/inference.json" should be modified to fit given dataset. After that, "dataset_dir" parameter in "configs/train.json" and "configs/inference.json" should be changed to root folder which contains previous "train", "valid" and "test" folders.
22
 
23
  Please notice that loading data operation in this bundle is adaptive. If images and labels are not in the same format, it may lead to a mismatching problem. For example, if images are in jpg format and labels are in npy format, PIL and Numpy readers will be used separately to load images and labels. Since these two readers have their own way to parse file's shape, loaded labels will be transpose of the correct ones and incur a missmatching problem.
 
112
  python -m monai.bundle trt_export --net_id network_def --filepath models/model_trt.ts --ckpt_file models/model.pt --meta_file configs/metadata.json --config_file configs/inference.json --precision <fp32/fp16>
113
  ```
114
 
115
+ #### Execute inference with the TensorRT model:
116
 
117
  ```
118
  python -m monai.bundle run --config_file "['configs/inference.json', 'configs/inference_trt.json']"
configs/metadata.json CHANGED
@@ -1,7 +1,8 @@
1
  {
2
  "schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json",
3
- "version": "0.4.5",
4
  "changelog": {
 
5
  "0.4.5": "add the command of executing inference with TensorRT models",
6
  "0.4.4": "adapt to BundleWorkflow interface",
7
  "0.4.3": "update this bundle to support TensorRT convert",
@@ -16,7 +17,7 @@
16
  "0.1.0": "complete the first version model package",
17
  "0.0.1": "initialize the model package structure"
18
  },
19
- "monai_version": "1.2.0rc3",
20
  "pytorch_version": "1.13.1",
21
  "numpy_version": "1.22.2",
22
  "optional_packages_version": {
 
1
  {
2
  "schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json",
3
+ "version": "0.4.6",
4
  "changelog": {
5
+ "0.4.6": "enable deterministic training",
6
  "0.4.5": "add the command of executing inference with TensorRT models",
7
  "0.4.4": "adapt to BundleWorkflow interface",
8
  "0.4.3": "update this bundle to support TensorRT convert",
 
17
  "0.1.0": "complete the first version model package",
18
  "0.0.1": "initialize the model package structure"
19
  },
20
+ "monai_version": "1.2.0rc4",
21
  "pytorch_version": "1.13.1",
22
  "numpy_version": "1.22.2",
23
  "optional_packages_version": {
configs/multi_gpu_evaluate.json CHANGED
@@ -19,7 +19,6 @@
19
  "$import torch.distributed as dist",
20
  "$dist.is_initialized() or dist.init_process_group(backend='nccl')",
21
  "$torch.cuda.set_device(@device)",
22
- "$setattr(torch.backends.cudnn, 'benchmark', True)",
23
  "$import logging",
24
  "$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)"
25
  ],
 
19
  "$import torch.distributed as dist",
20
  "$dist.is_initialized() or dist.init_process_group(backend='nccl')",
21
  "$torch.cuda.set_device(@device)",
 
22
  "$import logging",
23
  "$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)"
24
  ],
configs/multi_gpu_train.json CHANGED
@@ -30,7 +30,6 @@
30
  "$dist.is_initialized() or dist.init_process_group(backend='nccl')",
31
  "$torch.cuda.set_device(@device)",
32
  "$monai.utils.set_determinism(seed=123)",
33
- "$setattr(torch.backends.cudnn, 'benchmark', True)",
34
  "$import logging",
35
  "$@train#trainer.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)",
36
  "$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)"
 
30
  "$dist.is_initialized() or dist.init_process_group(backend='nccl')",
31
  "$torch.cuda.set_device(@device)",
32
  "$monai.utils.set_determinism(seed=123)",
 
33
  "$import logging",
34
  "$@train#trainer.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)",
35
  "$@validate#evaluator.logger.setLevel(logging.WARNING if dist.get_rank() > 0 else logging.INFO)"
configs/train.json CHANGED
@@ -275,8 +275,7 @@
275
  }
276
  },
277
  "initialize": [
278
- "$monai.utils.set_determinism(seed=123)",
279
- "$setattr(torch.backends.cudnn, 'benchmark', True)"
280
  ],
281
  "run": [
282
  "$@train#trainer.run()"
 
275
  }
276
  },
277
  "initialize": [
278
+ "$monai.utils.set_determinism(seed=123)"
 
279
  ],
280
  "run": [
281
  "$@train#trainer.run()"
docs/README.md CHANGED
@@ -11,7 +11,6 @@ Datasets used in this work were provided by [Activ Surgical](https://www.activsu
11
  Since datasets are private, existing public datasets like [EndoVis 2017](https://endovissub2017-roboticinstrumentsegmentation.grand-challenge.org/Data/) can be used to train a similar model.
12
 
13
  ### Preprocessing
14
-
15
  When using EndoVis or any other dataset, it should be divided into "train", "valid" and "test" folders. Samples in each folder would better be images and converted to jpg format. Otherwise, "images", "labels", "val_images" and "val_labels" parameters in "configs/train.json" and "datalist" in "configs/inference.json" should be modified to fit given dataset. After that, "dataset_dir" parameter in "configs/train.json" and "configs/inference.json" should be changed to root folder which contains previous "train", "valid" and "test" folders.
16
 
17
  Please notice that loading data operation in this bundle is adaptive. If images and labels are not in the same format, it may lead to a mismatching problem. For example, if images are in jpg format and labels are in npy format, PIL and Numpy readers will be used separately to load images and labels. Since these two readers have their own way to parse file's shape, loaded labels will be transpose of the correct ones and incur a missmatching problem.
@@ -106,7 +105,7 @@ python -m monai.bundle ckpt_export network_def --filepath models/model.ts --ckpt
106
  python -m monai.bundle trt_export --net_id network_def --filepath models/model_trt.ts --ckpt_file models/model.pt --meta_file configs/metadata.json --config_file configs/inference.json --precision <fp32/fp16>
107
  ```
108
 
109
- #### Execute inference with the TensorRT model
110
 
111
  ```
112
  python -m monai.bundle run --config_file "['configs/inference.json', 'configs/inference_trt.json']"
 
11
  Since datasets are private, existing public datasets like [EndoVis 2017](https://endovissub2017-roboticinstrumentsegmentation.grand-challenge.org/Data/) can be used to train a similar model.
12
 
13
  ### Preprocessing
 
14
  When using EndoVis or any other dataset, it should be divided into "train", "valid" and "test" folders. Samples in each folder would better be images and converted to jpg format. Otherwise, "images", "labels", "val_images" and "val_labels" parameters in "configs/train.json" and "datalist" in "configs/inference.json" should be modified to fit given dataset. After that, "dataset_dir" parameter in "configs/train.json" and "configs/inference.json" should be changed to root folder which contains previous "train", "valid" and "test" folders.
15
 
16
  Please notice that loading data operation in this bundle is adaptive. If images and labels are not in the same format, it may lead to a mismatching problem. For example, if images are in jpg format and labels are in npy format, PIL and Numpy readers will be used separately to load images and labels. Since these two readers have their own way to parse file's shape, loaded labels will be transpose of the correct ones and incur a missmatching problem.
 
105
  python -m monai.bundle trt_export --net_id network_def --filepath models/model_trt.ts --ckpt_file models/model.pt --meta_file configs/metadata.json --config_file configs/inference.json --precision <fp32/fp16>
106
  ```
107
 
108
+ #### Execute inference with the TensorRT model:
109
 
110
  ```
111
  python -m monai.bundle run --config_file "['configs/inference.json', 'configs/inference_trt.json']"