You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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'
The text was updated successfully, but these errors were encountered:
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. RaisesTypeError
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):
The text was updated successfully, but these errors were encountered: