-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
load_pretrain
flag in the reference (#571)
Follow up #559 #561 #565, here introduced the `load_pretrain` flag. This allows users to decide whether or not to load pre-trained weights when initializing the workflow. ### Status **Ready** ### Please ensure all the checkboxes: <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Codeformat tests passed locally by running `./runtests.sh --codeformat`. - [ ] In-line docstrings updated. - [ ] Update `version` and `changelog` in `metadata.json` if changing an existing bundle. - [ ] Please ensure the naming rules in config files meet our requirements (please refer to: `CONTRIBUTING.md`). - [ ] Ensure versions of packages such as `monai`, `pytorch` and `numpy` are correct in `metadata.json`. - [ ] Descriptions should be consistent with the content, such as `eval_metrics` of the provided weights and TorchScript modules. - [ ] Files larger than 25MB are excluded and replaced by providing download links in `large_file.yml`. - [ ] Avoid using path that contains personal information within config files (such as use `/home/your_name/` for `"bundle_root"`). --------- Signed-off-by: YunLiu <[email protected]> Co-authored-by: Yiheng Wang <[email protected]>
- Loading branch information
1 parent
8b2530c
commit 74e258e
Showing
20 changed files
with
40 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
"output_dtype": "uint8", | ||
"output_postfix": "seg", | ||
"separate_folder": true, | ||
"load_pretrain": true, | ||
"data_list_file_path": "$@bundle_root + '/configs/datalist.json'", | ||
"dataset_dir": "/workspace/data/medical/brats2018challenge", | ||
"test_datalist": "$monai.data.load_decathlon_datalist(@data_list_file_path, data_list_key='testing', base_dir=@dataset_dir)", | ||
|
@@ -140,7 +141,7 @@ | |
}, | ||
"initialize": [ | ||
"$setattr(torch.backends.cudnn, 'benchmark', True)", | ||
"$@checkpointloader(@evaluator)" | ||
"$@checkpointloader(@evaluator) if @load_pretrain else None" | ||
], | ||
"run": [ | ||
"[email protected]()" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
], | ||
"bundle_root": ".", | ||
"image_key": "image", | ||
"load_pretrain": true, | ||
"output_dir": "$@bundle_root + '/eval'", | ||
"output_filename": "predictions.csv", | ||
"dataset_dir": "/workspace/data/endoscopic_inbody_classification", | ||
|
@@ -119,7 +120,7 @@ | |
}, | ||
"initialize": [ | ||
"$monai.utils.set_determinism(seed=123)", | ||
"$@checkpointloader(@evaluator)" | ||
"$@checkpointloader(@evaluator) if @load_pretrain else None" | ||
], | ||
"run": [ | ||
"[email protected]()" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
"output_dtype": "$numpy.float32", | ||
"output_postfix": "trans", | ||
"separate_folder": true, | ||
"load_pretrain": true, | ||
"dataset_dir": "/workspace/data/endoscopic_tool_dataset", | ||
"datalist": "$list(sorted(glob.glob(os.path.join(@dataset_dir,'test', '*', '*[!seg].jpg'))))", | ||
"device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')", | ||
|
@@ -140,7 +141,7 @@ | |
}, | ||
"initialize": [ | ||
"$monai.utils.set_determinism(seed=123)", | ||
"$@checkpointloader(@evaluator)" | ||
"$@checkpointloader(@evaluator) if @load_pretrain else None" | ||
], | ||
"run": [ | ||
"[email protected]()" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
"test_datalist": "$monai.data.load_decathlon_datalist(@data_list_file_path, is_segmentation=True, data_list_key='validation', base_dir=@dataset_dir)", | ||
"device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')", | ||
"amp": true, | ||
"load_pretrain": true, | ||
"spatial_dims": 3, | ||
"num_classes": 1, | ||
"force_sliding_window": false, | ||
|
@@ -212,7 +213,7 @@ | |
}, | ||
"initialize": [ | ||
"$setattr(torch.backends.cudnn, 'benchmark', True)", | ||
"$@checkpointloader(@evaluator)" | ||
"$@checkpointloader(@evaluator) if @load_pretrain else None" | ||
], | ||
"run": [ | ||
"[email protected]()" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ output_ext: ".nii.gz" | |
output_dtype: "$numpy.float32" | ||
output_postfix: "trans" | ||
separate_folder: true | ||
load_pretrain: true | ||
dataset_dir: "/workspace/data/msd/Task07_Pancreas" | ||
data_list_file_path: "$@bundle_root + '/configs/dataset_0.json'" | ||
datalist: "$monai.data.load_decathlon_datalist(@data_list_file_path, data_list_key='testing', | ||
|
@@ -124,6 +125,6 @@ checkpointloader: | |
model: "@network" | ||
initialize: | ||
- "$setattr(torch.backends.cudnn, 'benchmark', True)" | ||
- "$@checkpointloader(@evaluator)" | ||
- "$@checkpointloader(@evaluator) if @load_pretrain else None" | ||
run: | ||
- "[email protected]()" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
"output_dtype": "$numpy.float32", | ||
"output_postfix": "trans", | ||
"separate_folder": true, | ||
"load_pretrain": true, | ||
"dataset_dir": "/workspace/data/CoNSePNuclei", | ||
"images": "$list(sorted(glob.glob(@dataset_dir + '/Test/Images/*.png')))[:1]", | ||
"centroids": "$list(sorted(glob.glob(@dataset_dir + '/Test/Centroids/*.txt')))[:1]", | ||
|
@@ -137,7 +138,7 @@ | |
"$import sys", | ||
"$sys.path.append(@bundle_root)", | ||
"$monai.utils.set_determinism(seed=123)", | ||
"$@checkpointloader(@evaluator)" | ||
"$@checkpointloader(@evaluator) if @load_pretrain else None" | ||
], | ||
"run": [ | ||
"[email protected]()" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
"output_dtype": "$numpy.float32", | ||
"output_postfix": "trans", | ||
"separate_folder": true, | ||
"load_pretrain": true, | ||
"dataset_dir": "/workspace/data/Task09_Spleen", | ||
"datalist": "$list(sorted(glob.glob(@dataset_dir + '/imagesTs/*.nii.gz')))", | ||
"device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')", | ||
|
@@ -156,7 +157,7 @@ | |
}, | ||
"initialize": [ | ||
"$monai.utils.set_determinism(seed=123)", | ||
"$@checkpointloader(@evaluator)" | ||
"$@checkpointloader(@evaluator) if @load_pretrain else None" | ||
], | ||
"run": [ | ||
"[email protected]()" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
"output_dtype": "$numpy.float32", | ||
"output_postfix": "trans", | ||
"separate_folder": true, | ||
"load_pretrain": true, | ||
"dataset_dir": "/workspace/Datasets/MSD_datasets/Task09_Spleen", | ||
"datalist": "$list(sorted(glob.glob(@dataset_dir + '/imagesTs/*.nii.gz')))", | ||
"label_names": { | ||
|
@@ -207,7 +208,7 @@ | |
}, | ||
"initialize": [ | ||
"$monai.utils.set_determinism(seed=123)", | ||
"$@checkpointloader(@evaluator)" | ||
"$@checkpointloader(@evaluator) if @load_pretrain else None" | ||
], | ||
"run": [ | ||
"[email protected]()" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
"output_dtype": "$numpy.float32", | ||
"output_postfix": "trans", | ||
"separate_folder": true, | ||
"load_pretrain": true, | ||
"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')", | ||
|
@@ -145,7 +146,7 @@ | |
}, | ||
"initialize": [ | ||
"$monai.utils.set_determinism(seed=123)", | ||
"$@checkpointloader(@evaluator)" | ||
"$@checkpointloader(@evaluator) if @load_pretrain else None" | ||
], | ||
"run": [ | ||
"[email protected]()" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
"output_dtype": "$numpy.float32", | ||
"output_postfix": "trans", | ||
"separate_folder": true, | ||
"load_pretrain": true, | ||
"dataset_dir": "sampledata", | ||
"datalist": "$list(sorted(glob.glob(@dataset_dir + '/imagesTs/*.nii.gz')))", | ||
"device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')", | ||
|
@@ -162,7 +163,7 @@ | |
}, | ||
"initialize": [ | ||
"$setattr(torch.backends.cudnn, 'benchmark', True)", | ||
"$@checkpointloader(@evaluator)" | ||
"$@checkpointloader(@evaluator) if @load_pretrain else None" | ||
], | ||
"run": [ | ||
"[email protected]()" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters