huggingface/pytorch-image-models · warning · FutureWarning

Importing from {__name__} is deprecated, please import via t

Error message

Importing from {__name__} is deprecated, please import via timm.models

What it means

Importing timm.models.hub is deprecated: the module moved to timm.models._hub and this shim re-exports it with a FutureWarning. Use timm.models (or timm.models._hub) for pretrained-config and checkpoint loading helpers.

Source

Thrown at timm/models/hub.py:4

from ._hub import *

import warnings
warnings.warn(f"Importing from {__name__} is deprecated, please import via timm.models", FutureWarning)

View on GitHub (pinned to 9a5261e31b)

Solutions

  1. Import from timm.models: from timm.models import load_state_dict_from_hf, load_state_dict_from_url
  2. Or use timm.models._hub for module-level access
  3. Prefer higher-level APIs: timm.create_model(..., pretrained=True) handles loading for you

Example fix

# before
from timm.models.hub import load_state_dict_from_url
# after
from timm.models import load_state_dict_from_url
Defensive patterns

Strategy: validation

Validate before calling

from timm.models import load_state_dict_from_url, load_state_dict_from_hf  # modern path

Prevention

When it happens

Trigger: from timm.models.hub import load_state_dict_from_hf, load_state_dict_from_url; import timm.models.hub in weight-loading code.

Common situations: Scripts loading weights from HuggingFace Hub or custom URLs written against old timm; model zoos with custom loading logic.

Related errors


AI-assisted analysis of huggingface/pytorch-image-models@9a5261e31b (2026-08-27). Data as JSON: /api/errors/78fc117310356764. Report an issue: GitHub.