Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwinUNETR requires 'img_size' argument, then refuses to use it because it is deprecated #403

Open
louisfabrice13 opened this issue Oct 24, 2024 · 0 comments

Comments

@louisfabrice13
Copy link

Describe the bug
SwinUNETR requires 'img_size' argument, then refuses to use it because it is deprecated

To Reproduce
Define a SwinUNETR model with 'img_size' argument, and without it.

Expected behavior
I would expect at most a deprecation warning, without the model breaking if img_size is indeed input, and a smooth instantiation without img_size.

Screenshots

DeprecatedError Traceback (most recent call last)
Cell In[26], line 1
----> 1 totrain_model = monai.networks.nets.SwinUNETR(img_size=(96,96,96), in_channels=4, out_channels=3,
2 depths=(2, 2, 2, 2), num_heads=(3, 6, 12, 24),
3 feature_size=48, norm_name='instance',
4 drop_rate=0.0, attn_drop_rate=0.0, dropout_path_rate=0.0,
5 normalize=True, use_checkpoint=False, spatial_dims=3, downsample='merging', use_v2=True)
7 def count_pms(model):
8 return sum(p.numel() for p in model.parameters() if p.requires_grad)

File ~/miniconda3/envs/mri_ssl/lib/python3.11/site-packages/monai/utils/deprecate_utils.py:219, in deprecated_arg.._decorator.._wrapper(*args, **kwargs)
217 if positional_found or kw_found:
218 if is_removed:
--> 219 raise DeprecatedError(msg)
220 if is_deprecated:
221 warn_deprecated(argname, msg, warning_category)

DeprecatedError: Argument img_size was removed in version 1.5. The img_size argument is not required anymore and checks on the input size are run during forward().

OR

TypeError Traceback (most recent call last)
Cell In[28], line 1
----> 1 totrain_model = monai.networks.nets.SwinUNETR(in_channels=4, out_channels=3,
2 depths=(2, 2, 2, 2), num_heads=(3, 6, 12, 24),
3 feature_size=48, norm_name='instance',
4 drop_rate=0.0, attn_drop_rate=0.0, dropout_path_rate=0.0,
5 normalize=True, use_checkpoint=False, spatial_dims=3, downsample='merging', use_v2=True)
7 def count_pms(model):
8 return sum(p.numel() for p in model.parameters() if p.requires_grad)

File ~/miniconda3/envs/mri_ssl/lib/python3.11/site-packages/monai/utils/deprecate_utils.py:208, in deprecated_arg.._decorator.._wrapper(*args, **kwargs)
205 except TypeError:
206 # multiple values for new_name using both args and kwargs
207 kwargs.pop(new_name, None)
--> 208 binding = sig.bind(*args, **kwargs).arguments
209 positional_found = name in binding
210 kw_found = False

File ~/miniconda3/envs/mri_ssl/lib/python3.11/inspect.py:3195, in Signature.bind(self, *args, **kwargs)
3190 def bind(self, /, *args, **kwargs):
3191 """Get a BoundArguments object, that maps the passed args
3192 and kwargs to the function's signature. Raises TypeError
3193 if the passed arguments can not be bound.
3194 """
-> 3195 return self._bind(args, kwargs)

File ~/miniconda3/envs/mri_ssl/lib/python3.11/inspect.py:3110, in Signature._bind(self, args, kwargs, partial)
3108 msg = 'missing a required argument: {arg!r}'
3109 msg = msg.format(arg=param.name)
-> 3110 raise TypeError(msg) from None
3111 else:
3112 # We have a positional argument to process
3113 try:

TypeError: missing a required argument: 'img_size'

Environment (please complete the following information):

  • Python 3.11
  • MONAI version '1.5.dev2442'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant