{"record":{"id":"56bf20670d952739","repo":"huggingface/pytorch-image-models","slug":"importing-from-name-is-deprecated-please-im-56bf20","errorCode":null,"errorMessage":"Importing from {__name__} is deprecated, please import via timm.layers","messagePattern":"Importing from (.+?) is deprecated, please import via timm\\.layers","errorType":"console","errorClass":"FutureWarning","httpStatus":null,"severity":"warning","filePath":"timm/models/layers/__init__.py","lineNumber":49,"sourceCode":"from timm.layers.non_local_attn import NonLocalAttn, BatNonLocalAttn\nfrom timm.layers.norm import GroupNorm, GroupNorm1, LayerNorm, LayerNorm2d\nfrom timm.layers.norm_act import BatchNormAct2d, GroupNormAct, convert_sync_batchnorm\nfrom timm.layers.padding import get_padding, get_same_padding, pad_same\nfrom timm.layers.patch_embed import PatchEmbed\nfrom timm.layers.pool2d_same import AvgPool2dSame, create_pool2d\nfrom timm.layers.pos_embed_sincos import RotaryEmbedding\nfrom timm.layers.squeeze_excite import SEModule, SqueezeExcite, EffectiveSEModule, EffectiveSqueezeExcite\nfrom timm.layers.selective_kernel import SelectiveKernel\nfrom timm.layers.separable_conv import SeparableConv2d, SeparableConvNormAct\nfrom timm.layers.split_attn import SplitAttn\nfrom timm.layers.split_batchnorm import SplitBatchNorm2d, convert_splitbn_model\nfrom timm.layers.std_conv import StdConv2d, StdConv2dSame, ScaledStdConv2d, ScaledStdConv2dSame\nfrom timm.layers.test_time_pool import TestTimePoolHead, apply_test_time_pool\nfrom timm.layers.trace_utils import _assert, _float_to_int\nfrom timm.layers.weight_init import trunc_normal_, trunc_normal_tf_, variance_scaling_, lecun_normal_\n\nimport warnings\nwarnings.warn(f\"Importing from {__name__} is deprecated, please import via timm.layers\", FutureWarning)\n","sourceCodeStart":31,"sourceCodeEnd":50,"githubUrl":"https://github.com/huggingface/pytorch-image-models/blob/9a5261e31b3b5128526eb2658333b4c0a54464ae/timm/models/layers/__init__.py#L31-L50","documentation":"Importing timm.models.layers is deprecated: the layers package moved to timm.layers and this shim re-exports its contents with a FutureWarning. All layer classes (conv, norm, attention, etc.) should come from timm.layers.","triggerScenarios":"from timm.models.layers import StdConv2d, trunc_normal_, DropPath; import timm.models.layers.* in custom model code — one of the most common imports in the timm ecosystem.","commonSituations":"Nearly every downstream repo, tutorial, and custom ViT/ConvNet model written before timm 0.9; coupling to timm.models.layers paths breaks after upgrade.","solutions":["Replace with from timm.layers import ... everywhere (grep 'timm.models.layers')","For plugin modules registered with timm, also update module paths accordingly","If you must keep old paths short-term, filter the FutureWarning, but schedule the rename"],"exampleFix":"# before\nfrom timm.models.layers import DropPath, trunc_normal_\n# after\nfrom timm.layers import DropPath, trunc_normal_","handlingStrategy":"validation","validationCode":"from timm.layers import DropPath, trunc_normal_  # modern path\n# transitional suppression:\nimport warnings\nwith warnings.catch_warnings():\n    warnings.simplefilter('ignore', FutureWarning)\n    from timm.models.layers import StdConv2d","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do a project-wide sed from 'timm.models.layers' to 'timm.layers'","Keep a shim requirements note that timm>=0.9 renamed layers","Enable -W error::FutureWarning in CI to force migration"],"tags":["timm","deprecation","import","layers"],"backgroundTag":"deprecated-module-import","analyzedSha":"9a5261e31b3b5128526eb2658333b4c0a54464ae","analyzedAt":"2026-08-27T02:34:25.417Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}