From a86c0e01555727bd848275c7eabc5b9dc26da73d Mon Sep 17 00:00:00 2001 From: Suraj Pai Date: Thu, 10 Aug 2023 17:22:49 -0400 Subject: [PATCH] Remove hard coding of `bias_downsample` in `resnet` methods (#6848) Fixes #6811 . ### Description Remove hard coding of `bias_downsample` in `resnet` methods. This allows for loading `MedicalNet` models. ### Types of changes - [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: Suraj Pai --- monai/networks/nets/resnet.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/monai/networks/nets/resnet.py b/monai/networks/nets/resnet.py index 02869d415f..e742db5ca5 100644 --- a/monai/networks/nets/resnet.py +++ b/monai/networks/nets/resnet.py @@ -333,7 +333,7 @@ def _resnet( progress: bool, **kwargs: Any, ) -> ResNet: - model: ResNet = ResNet(block, layers, block_inplanes, bias_downsample=not pretrained, **kwargs) + model: ResNet = ResNet(block, layers, block_inplanes, **kwargs) if pretrained: # Author of paper zipped the state_dict on googledrive, # so would need to download, unzip and read (2.8gb file for a ~150mb state dict). @@ -341,6 +341,8 @@ def _resnet( raise NotImplementedError( "Currently not implemented. You need to manually download weights provided by the paper's author" " and load then to the model with `state_dict`. See https://github.com/Tencent/MedicalNet" + "Please ensure you pass the appropriate `shortcut_type` and `bias_downsample` args. as specified" + "here: https://github.com/Tencent/MedicalNet/tree/18c8bb6cd564eb1b964bffef1f4c2283f1ae6e7b#update20190730" ) return model