huggingface/pytorch-image-models · info
Mapping deprecated model name {deprecated_name} to current {
Error message
Mapping deprecated model name {deprecated_name} to current {current_name}. What it means
This warning is emitted when you instantiate a model whose name has been deprecated and mapped to its replacement. The shim warns you that the old name now builds the current model, then forwards pretrained/kwargs to the replacement function.
Source
Thrown at timm/models/_registry.py:143
if tag:
_model_pretrained_cfgs[model_name_tag] = pretrained_cfg
if pretrained_cfg.has_weights:
# add model w/ tag if tag is valid
_model_has_pretrained.add(model_name_tag)
_model_with_tags[model_name].append(model_name_tag)
else:
_model_with_tags[model_name].append(model_name) # has empty tag (to slowly remove these instances)
_model_default_cfgs[model_name] = default_cfg
return fn
def _deprecated_model_shim(deprecated_name: str, current_fn: Callable = None, current_tag: str = ''):
def _fn(pretrained=False, **kwargs):
assert current_fn is not None, f'Model {deprecated_name} has been removed with no replacement.'
current_name = '.'.join([current_fn.__name__, current_tag]) if current_tag else current_fn.__name__
warnings.warn(f'Mapping deprecated model name {deprecated_name} to current {current_name}.', stacklevel=2)
pretrained_cfg = kwargs.pop('pretrained_cfg', None)
return current_fn(pretrained=pretrained, pretrained_cfg=pretrained_cfg or current_tag, **kwargs)
return _fn
def register_model_deprecations(module_name: str, deprecation_map: Dict[str, Optional[str]]):
mod = sys.modules[module_name]
module_name_split = module_name.split('.')
module_name = module_name_split[-1] if len(module_name_split) else ''
for deprecated, current in deprecation_map.items():
if hasattr(mod, '__all__'):
mod.__all__.append(deprecated)
current_fn = None
current_tag = ''
if current:
current_name, current_tag = split_model_name_tag(current)
current_fn = getattr(mod, current_name)View on GitHub (pinned to 9a5261e31b)
Solutions
- Update the model name string to the current name shown in the warning
- List available names with timm.list_models() to find the replacement
- Suppress the FutureWarning if the mapping is acceptable and you cannot change the name yet
Example fix
# before
model = timm.create_model('xception', pretrained=True)
# after
model = timm.create_model('xception.tf_in1k' if 'xception.tf_in1k' in timm.list_models() else 'xception', pretrained=True) Defensive patterns
Strategy: validation
Validate before calling
import warnings, timm
name = 'inception_v3_old'
valid = timm.list_models()
if name not in valid:
# will fall back to deprecated shim if mapped, warn, or fail
raise ValueError(f'{name} not in timm model list') Try / catch
with warnings.catch_warnings():
warnings.filterwarnings('ignore', message='Mapping deprecated model name')
model = timm.create_model('old_name', pretrained=True) Prevention
- Pin model names from timm.list_models() in configs
- Prefer pretrained-tag names (e.g. 'vit_small_patch16_224.augreg_in1k')
- Run a periodic deprecation-name audit when upgrading timm
When it happens
Trigger: Calling timm.create_model('inception_v3_old') or another name present in a module's deprecation map; passing a deprecated name that maps to a tagged variant (e.g. a .in1k tag) via _deprecated_model_shim.
Common situations: Old training/inference scripts pinning legacy model names; tutorials referencing renamed weights; upgrading timm where models were consolidated.
Related errors
- Importing from {__name__} is deprecated, please import via t
- Importing from {__name__} is deprecated, please import via t
- Importing from {__name__} is deprecated, please import via t
- Importing from {__name__} is deprecated, please import via t
- Importing from {__name__} is deprecated, please import via t
AI-assisted analysis of huggingface/pytorch-image-models@9a5261e31b (2026-08-27).
Data as JSON: /api/errors/a7f28f43cdfd8e15.
Report an issue: GitHub.