-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
8134 Add unit test for responsive inference (#8146)
Fixes #8134 . ### Description This PR added unit test to cover the realtime inference with bundles. And updated `BundleWorkflow` to support cyclically calling the `run` function with all components instantiated. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: Nic Ma <[email protected]> Signed-off-by: YunLiu <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: YunLiu <[email protected]> Co-authored-by: Eric Kerfoot <[email protected]>
- Loading branch information
1 parent
b1e915c
commit d94df3f
Showing
4 changed files
with
162 additions
and
3 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
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
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 |
---|---|---|
@@ -0,0 +1,101 @@ | ||
{ | ||
"imports": [ | ||
"$from collections import defaultdict" | ||
], | ||
"bundle_root": "will override", | ||
"device": "$torch.device('cpu')", | ||
"network_def": { | ||
"_target_": "UNet", | ||
"spatial_dims": 3, | ||
"in_channels": 1, | ||
"out_channels": 2, | ||
"channels": [ | ||
2, | ||
2, | ||
4, | ||
8, | ||
4 | ||
], | ||
"strides": [ | ||
2, | ||
2, | ||
2, | ||
2 | ||
], | ||
"num_res_units": 2, | ||
"norm": "batch" | ||
}, | ||
"network": "$@network_def.to(@device)", | ||
"dataflow": "$defaultdict()", | ||
"preprocessing": { | ||
"_target_": "Compose", | ||
"transforms": [ | ||
{ | ||
"_target_": "EnsureChannelFirstd", | ||
"keys": "image" | ||
}, | ||
{ | ||
"_target_": "ScaleIntensityd", | ||
"keys": "image" | ||
}, | ||
{ | ||
"_target_": "RandRotated", | ||
"_disabled_": true, | ||
"keys": "image" | ||
} | ||
] | ||
}, | ||
"dataset": { | ||
"_target_": "Dataset", | ||
"data": [ | ||
"@dataflow" | ||
], | ||
"transform": "@preprocessing" | ||
}, | ||
"dataloader": { | ||
"_target_": "DataLoader", | ||
"dataset": "@dataset", | ||
"batch_size": 1, | ||
"shuffle": false, | ||
"num_workers": 0 | ||
}, | ||
"inferer": { | ||
"_target_": "SlidingWindowInferer", | ||
"roi_size": [ | ||
64, | ||
64, | ||
32 | ||
], | ||
"sw_batch_size": 4, | ||
"overlap": 0.25 | ||
}, | ||
"postprocessing": { | ||
"_target_": "Compose", | ||
"transforms": [ | ||
{ | ||
"_target_": "Activationsd", | ||
"keys": "pred", | ||
"softmax": true | ||
}, | ||
{ | ||
"_target_": "AsDiscreted", | ||
"keys": "pred", | ||
"argmax": true | ||
} | ||
] | ||
}, | ||
"evaluator": { | ||
"_target_": "SupervisedEvaluator", | ||
"device": "@device", | ||
"val_data_loader": "@dataloader", | ||
"network": "@network", | ||
"inferer": "@inferer", | ||
"postprocessing": "@postprocessing", | ||
"amp": false, | ||
"epoch_length": 1 | ||
}, | ||
"run": [ | ||
"[email protected]()", | ||
"[email protected](@evaluator.state.output[0])" | ||
] | ||
} |