huggingface/pytorch-image-models · error · RuntimeError
features_only not implemented for Vision Transformer models.
Error message
features_only not implemented for Vision Transformer models.
What it means
The visformer factories explicitly reject features_only=True because Visformer's feature extraction isn't wired through build_model_with_cfg's feature-only pathway; a RuntimeError (not ValueError) is raised at model creation.
Source
Thrown at timm/models/visformer.py:485
x = self.stage3(x)
x = self.norm(x)
return x
def forward_head(self, x, pre_logits: bool = False):
x = self.global_pool(x)
x = self.head_drop(x)
return x if pre_logits else self.head(x)
def forward(self, x):
x = self.forward_features(x)
x = self.forward_head(x)
return x
def _create_visformer(variant, pretrained=False, default_cfg=None, **kwargs):
if kwargs.get('features_only', None):
raise RuntimeError('features_only not implemented for Vision Transformer models.')
model = build_model_with_cfg(Visformer, variant, pretrained, **kwargs)
return model
def _cfg(url='', **kwargs):
return {
'url': url,
'num_classes': 1000, 'input_size': (3, 224, 224), 'pool_size': (7, 7),
'crop_pct': .9, 'interpolation': 'bicubic', 'fixed_input_size': True,
'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD,
'first_conv': 'stem.0', 'classifier': 'head',
'license': 'apache-2.0',
**kwargs
}
default_cfgs = generate_default_cfgs({
'visformer_tiny.in1k': _cfg(hf_hub_id='timm/'),View on GitHub (pinned to 9a5261e31b)
Solutions
- Create the model without features_only and call forward_intermediates() to get intermediate features
- Choose a backbone that supports features_only if a feature pyramid API is required
Example fix
# before
model = timm.create_model('visformer_tiny', features_only=True)
# after
model = timm.create_model('visformer_tiny', features_only=False)
feats = model.forward_intermediates(x, indices=[1, 3, 5, 7]) Defensive patterns
Strategy: validation
Validate before calling
kwargs.pop('features_only', False) if name.startswith('visformer') else None
model = timm.create_model(name, **kwargs) Type guard
def supports_features_only(name: str) -> bool:
return not name.startswith('visformer') Try / catch
try:
model = timm.create_model(name, features_only=True)
except RuntimeError:
model = timm.create_model(name) # use forward_intermediates instead Prevention
- Check timm.features or model capability before passing features_only
- Prefer forward_intermediates for transformers needing intermediates
When it happens
Trigger: timm.create_model('visformer_tiny', features_only=True) or any visformer_* with features_only in kwargs.
Common situations: Generic FPN/segmentation code that blindly passes features_only=True to every backbone in a model zoo.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- features_only not implemented for Vision Transformer models.
- features_only not implemented for Vision Transformer models.
- features_only not implemented for ConvMixer models.
- features_only not implemented for Vision Transformer models.
- Input image must have positive dimensions, got H={height}, W
AI-assisted analysis of huggingface/pytorch-image-models@9a5261e31b (2026-08-27).
Data as JSON: /api/errors/c90274562e2c7b41.
Report an issue: GitHub.