Skip to content

Commit

Permalink
Added missing RuntimeError to builder functions of models that do not…
Browse files Browse the repository at this point in the history
… currently support feature extraction
  • Loading branch information
belfner authored and rwightman committed Sep 19, 2023
1 parent d4c21b9 commit 245ad4f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions timm/models/convmixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ def forward(self, x):


def _create_convmixer(variant, pretrained=False, **kwargs):
if kwargs.get('features_only', None):
raise RuntimeError('features_only not implemented for ConvMixer models.')

return build_model_with_cfg(ConvMixer, variant, pretrained, **kwargs)


Expand Down
3 changes: 3 additions & 0 deletions timm/models/efficientformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,9 @@ def _cfg(url='', **kwargs):


def _create_efficientformer(variant, pretrained=False, **kwargs):
if kwargs.get('features_only', None):
raise RuntimeError('features_only not implemented for EfficientFormer models.')

model = build_model_with_cfg(
EfficientFormer, variant, pretrained,
pretrained_filter_fn=_checkpoint_filter_fn,
Expand Down
3 changes: 3 additions & 0 deletions timm/models/mvitv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,9 @@ def checkpoint_filter_fn(state_dict, model):


def _create_mvitv2(variant, cfg_variant=None, pretrained=False, **kwargs):
if kwargs.get('features_only', None):
raise RuntimeError('features_only not implemented for Multiscale Vision Transformer models.')

return build_model_with_cfg(
MultiScaleVit,
variant,
Expand Down
3 changes: 3 additions & 0 deletions timm/models/xcit.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,9 @@ def checkpoint_filter_fn(state_dict, model):


def _create_xcit(variant, pretrained=False, default_cfg=None, **kwargs):
if kwargs.get('features_only', None):
raise RuntimeError('features_only not implemented for Cross-Covariance Image Transformers models.')

model = build_model_with_cfg(
Xcit,
variant,
Expand Down

0 comments on commit 245ad4f

Please sign in to comment.