Project-MONAI / MONAI

AI Toolkit for Healthcare Imaging
https://monai.io/
Apache License 2.0
5.93k stars 1.09k forks source link

(partly) load weights from a bundle #5629

Closed wyli closed 1 year ago

wyli commented 2 years ago

pythonic API to set initial weights of a model from a model zoo item

for example, loading from existing bundle:

my_model = monai.networks.net.SwinUNETR(...)
load_state_dict(my_model, weights_url='model-zoo:swin_unetr_btcv_segmentation')

the load_state_dict should implement the logic of filtering and assigning parameters, similar to this existing implementation in DenseNet:

https://github.com/Project-MONAI/MONAI/blob/e15da1ca3f0651faf3bc75c8274f417acc2c27b1/monai/networks/nets/densenet.py#L266-L281

wyli commented 1 year ago

basic utils implemented by https://github.com/Project-MONAI/MONAI/commit/392c5c1b860c0f0cfd0aa14e9d4b342c8b5ef5e7