huggingface/pytorch-image-models · error · ValueError
Invalid net configuration
Error message
Invalid net configuration
What it means
_create_selecsls builds a config from a hardcoded table keyed by variant string; an unknown variant falls through to the generic 'Invalid net configuration' error. The public factories (selecsls42, selecsls42b, selecsls60, selecsls60b, selecsls84) always pass valid names, so this fires only on custom/misspelled variants.
Source
Thrown at timm/models/selecsls.py:316
feature_info.extend([
dict(num_chs=144, reduction=4, module='features.1'),
dict(num_chs=304, reduction=8, module='features.6'),
dict(num_chs=512, reduction=16, module='features.12'),
])
# Head can be replaced with alternative configurations depending on the problem
cfg['head'] = [
(512, 960, 3, 2),
(960, 1024, 3, 1),
(1024, 1024, 3, 2),
(1024, 1280, 3, 1),
]
cfg['num_features'] = 1280
feature_info.extend([
dict(num_chs=1024, reduction=32, module='head.1'),
dict(num_chs=1280, reduction=64, module='head.3')
])
else:
raise ValueError('Invalid net configuration ' + variant + ' !!!')
cfg['feature_info'] = feature_info
# this model can do 6 feature levels by default, unlike most others, leave as 0-4 to avoid surprises?
return build_model_with_cfg(
SelecSls,
variant,
pretrained,
model_cfg=cfg,
feature_cfg=dict(out_indices=(0, 1, 2, 3, 4), flatten_sequential=True),
**kwargs,
)
def _cfg(url='', **kwargs):
return {
'url': url,
'num_classes': 1000, 'input_size': (3, 224, 224), 'pool_size': (4, 4),
'crop_pct': 0.875, 'interpolation': 'bilinear',View on GitHub (pinned to 9a5261e31b)
Solutions
- Use one of the registered variants: selecsls42, selecsls42b, selecsls60, selecsls60b, selecsls84
- If adding a new variant, add a matching branch in _create_selecsls that populates cfg and feature_info
Example fix
# before
model = timm.create_model('selecsls42c', pretrained=False)
# after
model = timm.create_model('selecsls42b', pretrained=False) Defensive patterns
Strategy: validation
Validate before calling
from timm.models.selecsls import selecsls_variants if False else None
valid = {'selecsls42','selecsls42b','selecsls60','selecsls60b','selecsls84'}
assert variant in valid Prevention
- Use timm.create_model with exact registered variant names
- Extend _create_selecsls when adding variants
When it happens
Trigger: Calling build_model_with_cfg(SelecSls, 'selecsls42c', ...) or a custom factory with a variant not in the if/elif chain of _create_selecsls.
Common situations: Adding a new SelecSls width/depth variant by copying a factory without extending _create_selecsls, or renaming variants inconsistently.
Related errors
- batch_sizes must contain at least one value.
- Model architecture ({arch_name}) has no pretrained cfg regis
- Cannot initialize position embeddings without grid_size.Plea
- Unknown rope_type: {cfg.rope_type}
- Unrecognized union:
AI-assisted analysis of huggingface/pytorch-image-models@9a5261e31b (2026-08-27).
Data as JSON: /api/errors/7792ce9dcfa27b9a.
Report an issue: GitHub.