repo stringlengths 7 90 | file_url stringlengths 81 315 | file_path stringlengths 4 228 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 14:38:15 2026-01-05 02:33:18 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/loss/asymmetric_loss.py | timm/loss/asymmetric_loss.py | import torch
import torch.nn as nn
class AsymmetricLossMultiLabel(nn.Module):
def __init__(self, gamma_neg=4, gamma_pos=1, clip=0.05, eps=1e-8, disable_torch_grad_focal_loss=False):
super(AsymmetricLossMultiLabel, self).__init__()
self.gamma_neg = gamma_neg
self.gamma_pos = gamma_pos
... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/loss/jsd.py | timm/loss/jsd.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from .cross_entropy import LabelSmoothingCrossEntropy
class JsdCrossEntropy(nn.Module):
""" Jensen-Shannon Divergence + Cross-Entropy Loss
Based on impl here: https://github.com/google-research/augmix/blob/master/imagenet.py
From paper: ... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/loss/cross_entropy.py | timm/loss/cross_entropy.py | """ Cross Entropy w/ smoothing or soft targets
Hacked together by / Copyright 2021 Ross Wightman
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
class LabelSmoothingCrossEntropy(nn.Module):
""" NLL loss with label smoothing.
"""
def __init__(self, smoothing=0.1):
super(Lab... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/loss/__init__.py | timm/loss/__init__.py | from .asymmetric_loss import AsymmetricLossMultiLabel, AsymmetricLossSingleLabel
from .binary_cross_entropy import BinaryCrossEntropy
from .cross_entropy import LabelSmoothingCrossEntropy, SoftTargetCrossEntropy
from .jsd import JsdCrossEntropy
| python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/loss/binary_cross_entropy.py | timm/loss/binary_cross_entropy.py | """ Binary Cross Entropy w/ a few extras
Hacked together by / Copyright 2021 Ross Wightman
"""
from typing import Optional, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
class BinaryCrossEntropy(nn.Module):
""" BCE with optional one-hot from dense targets, label smoothing, thresholdin... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/efficientnet.py | timm/models/efficientnet.py | """ The EfficientNet Family in PyTorch
An implementation of EfficienNet that covers variety of related models with efficient architectures:
* EfficientNet-V2
- `EfficientNetV2: Smaller Models and Faster Training` - https://arxiv.org/abs/2104.00298
* EfficientNet (B0-B8, L2 + Tensorflow pretrained AutoAug/RandAug/A... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/hieradet_sam2.py | timm/models/hieradet_sam2.py | import math
from copy import deepcopy
from functools import partial
from typing import Dict, List, Optional, Tuple, Type, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
from timm.layers import (
PatchEmbed,
Mlp,
Dr... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/resnetv2.py | timm/models/resnetv2.py | """Pre-Activation ResNet v2 with GroupNorm and Weight Standardization.
A PyTorch implementation of ResNetV2 adapted from the Google Big-Transfer (BiT) source code
at https://github.com/google-research/big_transfer to match timm interfaces. The BiT weights have
been included here as pretrained models from their origina... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/vovnet.py | timm/models/vovnet.py | """ VoVNet (V1 & V2)
Papers:
* `An Energy and GPU-Computation Efficient Backbone Network` - https://arxiv.org/abs/1904.09730
* `CenterMask : Real-Time Anchor-Free Instance Segmentation` - https://arxiv.org/abs/1911.06667
Looked at https://github.com/youngwanLEE/vovnet-detectron2 &
https://github.com/stigma0617/VoVNe... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/vision_transformer_relpos.py | timm/models/vision_transformer_relpos.py | """ Relative Position Vision Transformer (ViT) in PyTorch
NOTE: these models are experimental / WIP, expect changes
Hacked together by / Copyright 2022, Ross Wightman
"""
import logging
import math
from functools import partial
from typing import List, Optional, Tuple, Type, Union
try:
from typing import Literal... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/convmixer.py | timm/models/convmixer.py | """ ConvMixer
"""
from typing import Optional, Type
import torch
import torch.nn as nn
from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
from timm.layers import SelectAdaptivePool2d
from ._registry import register_model, generate_default_cfgs
from ._builder import build_model_with_cfg
from ._manipula... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/_factory.py | timm/models/_factory.py | import os
from pathlib import Path
from typing import Any, Dict, Optional, Tuple, Union
from urllib.parse import urlsplit
from torch import nn
from timm.layers import set_layer_config
from ._helpers import load_checkpoint
from ._hub import load_model_config_from_hf, load_model_config_from_path
from ._pretrained impor... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/resnest.py | timm/models/resnest.py | """ ResNeSt Models
Paper: `ResNeSt: Split-Attention Networks` - https://arxiv.org/abs/2004.08955
Adapted from original PyTorch impl w/ weights at https://github.com/zhanghang1989/ResNeSt by Hang Zhang
Modified for torchscript compat, and consistency with timm by Ross Wightman
"""
from typing import Optional, Type
f... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/hrnet.py | timm/models/hrnet.py | """ HRNet
Copied from https://github.com/HRNet/HRNet-Image-Classification
Original header:
Copyright (c) Microsoft
Licensed under the MIT License.
Written by Bin Xiao (Bin.Xiao@microsoft.com)
Modified by Ke Sun (sunk@mail.ustc.edu.cn)
"""
import logging
from typing import Dict, List, Type, Optional, Tuple
im... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/repvit.py | timm/models/repvit.py | """ RepViT
Paper: `RepViT: Revisiting Mobile CNN From ViT Perspective`
- https://arxiv.org/abs/2307.09283
@misc{wang2023repvit,
title={RepViT: Revisiting Mobile CNN From ViT Perspective},
author={Ao Wang and Hui Chen and Zijia Lin and Hengjun Pu and Guiguang Ding},
year={2023},
eprint={230... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/byobnet.py | timm/models/byobnet.py | """ Bring-Your-Own-Blocks Network
A flexible network w/ dataclass based config for stacking those NN blocks.
This model is currently used to implement the following networks:
GPU Efficient (ResNets) - gernet_l/m/s (original versions called genet, but this was already used (by SENet author)).
Paper: `Neural Architect... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/fastvit.py | timm/models/fastvit.py | # FastViT for PyTorch
#
# Original implementation and weights from https://github.com/apple/ml-fastvit
#
# For licensing see accompanying LICENSE file at https://github.com/apple/ml-fastvit/tree/main
# Original work is copyright (C) 2023 Apple Inc. All Rights Reserved.
#
import os
from functools import partial
from typ... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/_efficientnet_blocks.py | timm/models/_efficientnet_blocks.py | """ EfficientNet, MobileNetV3, etc Blocks
Hacked together by / Copyright 2019, Ross Wightman
"""
from typing import Callable, Dict, Optional, Type, Union
import torch
import torch.nn as nn
from torch.nn import functional as F
from timm.layers import (
create_conv2d,
DropPath,
make_divisible,
create_a... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/tnt.py | timm/models/tnt.py | """ Transformer in Transformer (TNT) in PyTorch
A PyTorch implement of TNT as described in
'Transformer in Transformer' - https://arxiv.org/abs/2103.00112
The official mindspore code is released and available at
https://gitee.com/mindspore/mindspore/tree/master/model_zoo/research/cv/TNT
The official pytorch code is ... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/fx_features.py | timm/models/fx_features.py | from ._features_fx import *
import warnings
warnings.warn(f"Importing from {__name__} is deprecated, please import via timm.models", FutureWarning)
| python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/vision_transformer_sam.py | timm/models/vision_transformer_sam.py | """ Vision Transformer (ViT) in PyTorch
A PyTorch implement of Vision Transformers as described in:
'Exploring Plain Vision Transformer Backbones for Object Detection'
- https://arxiv.org/abs/2203.16527
'Segment Anything Model (SAM)'
- https://github.com/facebookresearch/segment-anything/
"""
import logging... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/rexnet.py | timm/models/rexnet.py | """ ReXNet
A PyTorch impl of `ReXNet: Diminishing Representational Bottleneck on Convolutional Neural Network` -
https://arxiv.org/abs/2007.00992
Adapted from original impl at https://github.com/clovaai/rexnet
Copyright (c) 2020-present NAVER Corp. MIT license
Changes for timm, feature extraction, and rounded channe... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/vision_transformer_hybrid.py | timm/models/vision_transformer_hybrid.py | """ Hybrid Vision Transformer (ViT) in PyTorch
A PyTorch implement of the Hybrid Vision Transformers as described in:
'An Image Is Worth 16 x 16 Words: Transformers for Image Recognition at Scale'
- https://arxiv.org/abs/2010.11929
`How to train your ViT? Data, Augmentation, and Regularization in Vision Transfor... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/registry.py | timm/models/registry.py | from ._registry import *
import warnings
warnings.warn(f"Importing from {__name__} is deprecated, please import via timm.models", FutureWarning)
| python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/_manipulate.py | timm/models/_manipulate.py | import collections.abc
import math
import re
from collections import defaultdict
from itertools import chain
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Type, Union
import torch
import torch.utils.checkpoint
from torch import nn as nn
from torch import Tensor
from timm.layers import use_r... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/starnet.py | timm/models/starnet.py | """
Implementation of Prof-of-Concept Network: StarNet.
We make StarNet as simple as possible [to show the key contribution of element-wise multiplication]:
- like NO layer-scale in network design,
- and NO EMA during training,
- which would improve the performance further.
Created by: Xu Ma (Email: ma.xu... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/ghostnet.py | timm/models/ghostnet.py | """
An implementation of GhostNet & GhostNetV2 Models as defined in:
GhostNet: More Features from Cheap Operations. https://arxiv.org/abs/1911.11907
GhostNetV2: Enhance Cheap Operation with Long-Range Attention. https://proceedings.neurips.cc/paper_files/paper/2022/file/40b60852a4abdaa696b5a1a78da34635-Paper-Conference... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/vgg.py | timm/models/vgg.py | """VGG
Adapted from https://github.com/pytorch/vision 'vgg.py' (BSD-3-Clause) with a few changes for
timm functionality.
Copyright 2021 Ross Wightman
"""
from typing import Any, Dict, List, Optional, Type, Union, cast
import torch
import torch.nn as nn
import torch.nn.functional as F
from timm.data import IMAGENET_... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/swin_transformer.py | timm/models/swin_transformer.py | """ Swin Transformer
A PyTorch impl of : `Swin Transformer: Hierarchical Vision Transformer using Shifted Windows`
- https://arxiv.org/pdf/2103.14030
Code/weights from https://github.com/microsoft/Swin-Transformer, original copyright/license info below
S3 (AutoFormerV2, https://arxiv.org/abs/2111.14725) Swin weig... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/inception_v4.py | timm/models/inception_v4.py | """ Pytorch Inception-V4 implementation
Sourced from https://github.com/Cadene/tensorflow-model-zoo.torch (MIT License) which is
based upon Google's Tensorflow implementation and pretrained weights (Apache 2.0 License)
"""
from functools import partial
from typing import List, Optional, Tuple, Union, Type
import torch... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/pnasnet.py | timm/models/pnasnet.py | """
pnasnet5large implementation grabbed from Cadene's pretrained models
Additional credit to https://github.com/creafz
https://github.com/Cadene/pretrained-models.pytorch/blob/master/pretrainedmodels/models/pnasnet.py
"""
from collections import OrderedDict
from functools import partial
from typing import Type
i... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/eva.py | timm/models/eva.py | """ EVA
EVA ViT from https://github.com/baaivision/EVA , paper: https://arxiv.org/abs/2211.07636
This file contains a number of ViT variants the utilise ROPE position embeddings, SwiGLU and other additions:
* EVA & EVA02 model implementations that evolved from BEiT, additional models in vision_transformer.py.
* `ti... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/deit.py | timm/models/deit.py | """ DeiT - Data-efficient Image Transformers
DeiT model defs and weights from https://github.com/facebookresearch/deit, original copyright below
paper: `DeiT: Data-efficient Image Transformers` - https://arxiv.org/abs/2012.12877
paper: `DeiT III: Revenge of the ViT` - https://arxiv.org/abs/2204.07118
Modifications ... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/vision_transformer.py | timm/models/vision_transformer.py | """ Vision Transformer (ViT) in PyTorch
A PyTorch implement of Vision Transformers as described in:
'An Image Is Worth 16 x 16 Words: Transformers for Image Recognition at Scale'
- https://arxiv.org/abs/2010.11929
`How to train your ViT? Data, Augmentation, and Regularization in Vision Transformers`
- https:... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/_prune.py | timm/models/_prune.py | import os
import pkgutil
from copy import deepcopy
from torch import nn as nn
from timm.layers import Conv2dSame, BatchNormAct2d, Linear
__all__ = ['extract_layer', 'set_layer', 'adapt_model_from_string', 'adapt_model_from_file']
def extract_layer(model, layer):
"""Extract a layer from a model using dot-separa... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/nest.py | timm/models/nest.py | """ Nested Transformer (NesT) in PyTorch
A PyTorch implement of Aggregating Nested Transformers as described in:
'Aggregating Nested Transformers'
- https://arxiv.org/abs/2105.12723
The official Jax code is released and available at https://github.com/google-research/nested-transformer. The weights
have been con... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/dpn.py | timm/models/dpn.py | """ PyTorch implementation of DualPathNetworks
Based on original MXNet implementation https://github.com/cypw/DPNs with
many ideas from another PyTorch implementation https://github.com/oyam/pytorch-DPNs.
This implementation is compatible with the pretrained weights from cypw's MXNet implementation.
Hacked together b... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/mvitv2.py | timm/models/mvitv2.py | """ Multi-Scale Vision Transformer v2
@inproceedings{li2021improved,
title={MViTv2: Improved multiscale vision transformers for classification and detection},
author={Li, Yanghao and Wu, Chao-Yuan and Fan, Haoqi and Mangalam, Karttikeya and Xiong, Bo and Malik, Jitendra and Feichtenhofer, Christoph},
booktitle={... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/edgenext.py | timm/models/edgenext.py | """ EdgeNeXt
Paper: `EdgeNeXt: Efficiently Amalgamated CNN-Transformer Architecture for Mobile Vision Applications`
- https://arxiv.org/abs/2206.10589
Original code and weights from https://github.com/mmaaz60/EdgeNeXt
Modifications and additions for timm by / Copyright 2022, Ross Wightman
"""
import math
from funct... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/hardcorenas.py | timm/models/hardcorenas.py | from functools import partial
import torch.nn as nn
from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
from ._builder import build_model_with_cfg
from ._builder import pretrained_cfg_for_features
from ._efficientnet_blocks import SqueezeExcite
from ._efficientnet_builder import decode_arch_def, resolve... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/swin_transformer_v2.py | timm/models/swin_transformer_v2.py | """ Swin Transformer V2
A PyTorch impl of : `Swin Transformer V2: Scaling Up Capacity and Resolution`
- https://arxiv.org/abs/2111.09883
Code/weights from https://github.com/microsoft/Swin-Transformer, original copyright/license info below
Modifications and additions for timm hacked together by / Copyright 2022, ... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/selecsls.py | timm/models/selecsls.py | """PyTorch SelecSLS Net example for ImageNet Classification
License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/legalcode)
Author: Dushyant Mehta (@mehtadushy)
SelecSLS (core) Network Architecture as proposed in "XNect: Real-time Multi-person 3D
Human Pose Estimation with a Single RGB Camera, Mehta et al."... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/swiftformer.py | timm/models/swiftformer.py | """SwiftFormer
SwiftFormer: Efficient Additive Attention for Transformer-based Real-time Mobile Vision Applications
Code: https://github.com/Amshaker/SwiftFormer
Paper: https://arxiv.org/pdf/2303.15446
@InProceedings{Shaker_2023_ICCV,
author = {Shaker, Abdelrahman and Maaz, Muhammad and Rasheed, Hanoona and Kha... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/dla.py | timm/models/dla.py | """ Deep Layer Aggregation and DLA w/ Res2Net
DLA original adapted from Official Pytorch impl at: https://github.com/ucbdrive/dla
DLA Paper: `Deep Layer Aggregation` - https://arxiv.org/abs/1707.06484
Res2Net additions from: https://github.com/gasvn/Res2Net/
Res2Net Paper: `Res2Net: A New Multi-scale Backbone Architec... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/pit.py | timm/models/pit.py | """ Pooling-based Vision Transformer (PiT) in PyTorch
A PyTorch implement of Pooling-based Vision Transformers as described in
'Rethinking Spatial Dimensions of Vision Transformers' - https://arxiv.org/abs/2103.16302
This code was adapted from the original version at https://github.com/naver-ai/pit, original copyrigh... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/resnet.py | timm/models/resnet.py | """PyTorch ResNet
This started as a copy of https://github.com/pytorch/vision 'resnet.py' (BSD-3-Clause) with
additional dropout and dynamic global avg/max pool.
ResNeXt, SE-ResNeXt, SENet, and MXNet Gluon stem/downsample variants, tiered stems added by Ross Wightman
Copyright 2019, Ross Wightman
"""
import math
fro... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/hiera.py | timm/models/hiera.py | """ An PyTorch implementation of Hiera
Adapted for timm from originals at https://github.com/facebookresearch/hiera
"""
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/inception_v3.py | timm/models/inception_v3.py | """ Inception-V3
Originally from torchvision Inception3 model
Licensed BSD-Clause 3 https://github.com/pytorch/vision/blob/master/LICENSE
"""
from functools import partial
from typing import Optional, Type
import torch
import torch.nn as nn
import torch.nn.functional as F
from timm.data import IMAGENET_DEFAULT_STD, ... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/fasternet.py | timm/models/fasternet.py | """FasterNet
Run, Don't Walk: Chasing Higher FLOPS for Faster Neural Networks
- paper: https://arxiv.org/abs/2303.03667
- code: https://github.com/JierunChen/FasterNet
@article{chen2023run,
title={Run, Don't Walk: Chasing Higher FLOPS for Faster Neural Networks},
author={Chen, Jierun and Kao, Shiu-hong and He, Hao... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/levit.py | timm/models/levit.py | """ LeViT
Paper: `LeViT: a Vision Transformer in ConvNet's Clothing for Faster Inference`
- https://arxiv.org/abs/2104.01136
@article{graham2021levit,
title={LeViT: a Vision Transformer in ConvNet's Clothing for Faster Inference},
author={Benjamin Graham and Alaaeldin El-Nouby and Hugo Touvron and Pierre Stoc... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/nextvit.py | timm/models/nextvit.py | """ Next-ViT
As described in https://arxiv.org/abs/2207.05501
Next-ViT model defs and weights adapted from https://github.com/bytedance/Next-ViT, original copyright below
"""
# Copyright (c) ByteDance Inc. All rights reserved.
from functools import partial
from typing import List, Optional, Tuple, Union, Type
import... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/naflexvit.py | timm/models/naflexvit.py | """ NaFlex Vision Transformer
An improved version of the Vision Transformer with:
1. Encapsulated embedding and position encoding in a single module
2. Support for linear patch embedding on pre-patchified inputs
3. Support for NaFlex variable aspect, variable resolution
4. Support for FlexiViT variable patch size
5. S... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/byoanet.py | timm/models/byoanet.py | """ Bring-Your-Own-Attention Network
A flexible network w/ dataclass based config for stacking NN blocks including
self-attention (or similar) layers.
Currently used to implement experimental variants of:
* Bottleneck Transformers
* Lambda ResNets
* HaloNets
Consider all of the models definitions here as exper... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/repghost.py | timm/models/repghost.py | """
An implementation of RepGhostNet Model as defined in:
RepGhost: A Hardware-Efficient Ghost Module via Re-parameterization. https://arxiv.org/abs/2211.06088
Original implementation: https://github.com/ChengpengChen/RepGhost
"""
import copy
from functools import partial
from typing import List, Optional, Tuple, Unio... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/shvit.py | timm/models/shvit.py | """SHViT
SHViT: Single-Head Vision Transformer with Memory Efficient Macro Design
Code: https://github.com/ysj9909/SHViT
Paper: https://arxiv.org/abs/2401.16456
@inproceedings{yun2024shvit,
author={Yun, Seokju and Ro, Youngmin},
title={SHViT: Single-Head Vision Transformer with Memory Efficient Macro Design},
bo... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/mambaout.py | timm/models/mambaout.py | """
MambaOut models for image classification.
Some implementations are modified from:
timm (https://github.com/rwightman/pytorch-image-models),
MetaFormer (https://github.com/sail-sg/metaformer),
InceptionNeXt (https://github.com/sail-sg/inceptionnext)
"""
from collections import OrderedDict
from typing import List, Op... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/mobilenetv3.py | timm/models/mobilenetv3.py | """ MobileNet V3
A PyTorch impl of MobileNet-V3, compatible with TF weights from official impl.
Paper: Searching for MobileNetV3 - https://arxiv.org/abs/1905.02244
Hacked together by / Copyright 2019, Ross Wightman
"""
from functools import partial
from typing import Any, Dict, Callable, List, Optional, Tuple, Union... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/visformer.py | timm/models/visformer.py | """ Visformer
Paper: Visformer: The Vision-friendly Transformer - https://arxiv.org/abs/2104.12533
From original at https://github.com/danczs/Visformer
Modifications and additions for timm hacked together by / Copyright 2021, Ross Wightman
"""
from typing import Optional, Union, Type, Any
import torch
import torch.... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/_helpers.py | timm/models/_helpers.py | """ Model creation / weight loading / state_dict helpers
Hacked together by / Copyright 2020 Ross Wightman
"""
import logging
import os
from typing import Any, Callable, Dict, Optional, Union
import torch
try:
import safetensors.torch
_has_safetensors = True
except ImportError:
_has_safetensors = False
... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/maxxvit.py | timm/models/maxxvit.py | """ MaxVit and CoAtNet Vision Transformer - CNN Hybrids in PyTorch
This is a from-scratch implementation of both CoAtNet and MaxVit in PyTorch.
99% of the implementation was done from papers, however last minute some adjustments were made
based on the (as yet unfinished?) public code release https://github.com/google... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/helpers.py | timm/models/helpers.py | from ._builder import *
from ._helpers import *
from ._manipulate import *
from ._prune import *
import warnings
warnings.warn(f"Importing from {__name__} is deprecated, please import via timm.models", FutureWarning)
| python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/crossvit.py | timm/models/crossvit.py | """ CrossViT Model
@inproceedings{
chen2021crossvit,
title={{CrossViT: Cross-Attention Multi-Scale Vision Transformer for Image Classification}},
author={Chun-Fu (Richard) Chen and Quanfu Fan and Rameswar Panda},
booktitle={International Conference on Computer Vision (ICCV)},
year={2021}
}
Paper l... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/xception_aligned.py | timm/models/xception_aligned.py | """Pytorch impl of Aligned Xception 41, 65, 71
This is a correct, from scratch impl of Aligned Xception (Deeplab) models compatible with TF weights at
https://github.com/tensorflow/models/blob/master/research/deeplab/g3doc/model_zoo.md
Hacked together by / Copyright 2020 Ross Wightman
"""
from functools import partia... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/_pretrained.py | timm/models/_pretrained.py | import copy
from collections import deque, defaultdict
from dataclasses import dataclass, field, replace, asdict
from typing import Any, Deque, Dict, Tuple, Optional, Union
__all__ = ['PretrainedCfg', 'filter_pretrained_cfg', 'DefaultCfg']
@dataclass
class PretrainedCfg:
"""
"""
# weight source location... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/beit.py | timm/models/beit.py | """ BEiT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254)
Model from official source: https://github.com/microsoft/unilm/tree/master/beit
@inproceedings{beit,
title={{BEiT}: {BERT} Pre-Training of Image Transformers},
author={Hangbo Bao and Li Dong and Songhao Piao and Furu Wei},
booktitle=... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/xception.py | timm/models/xception.py | """
Ported to pytorch thanks to [tstandley](https://github.com/tstandley/Xception-PyTorch)
@author: tstandley
Adapted by cadene
Creates an Xception Model as defined in:
Francois Chollet
Xception: Deep Learning with Depthwise Separable Convolutions
https://arxiv.org/pdf/1610.02357.pdf
This weights ported from the Ke... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/hgnet.py | timm/models/hgnet.py | """ PP-HGNet (V1 & V2)
Reference:
https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/zh_CN/models/ImageNet1k/PP-HGNetV2.md
The Paddle Implement of PP-HGNet (https://github.com/PaddlePaddle/PaddleClas/blob/release/2.5.1/docs/en/models/PP-HGNet_en.md)
PP-HGNet: https://github.com/PaddlePaddle/PaddleClas/blob/r... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/cait.py | timm/models/cait.py | """ Class-Attention in Image Transformers (CaiT)
Paper: 'Going deeper with Image Transformers' - https://arxiv.org/abs/2103.17239
Original code and weights from https://github.com/facebookresearch/deit, copyright below
Modifications and additions for timm hacked together by / Copyright 2021, Ross Wightman
"""
# Copy... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/nasnet.py | timm/models/nasnet.py | """ NasNet-A (Large)
nasnetalarge implementation grabbed from Cadene's pretrained models
https://github.com/Cadene/pretrained-models.pytorch
"""
from functools import partial
from typing import Optional, Type
import torch
import torch.nn as nn
from timm.layers import ConvNormAct, create_conv2d, create_pool2d, creat... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/convnext.py | timm/models/convnext.py | """ ConvNeXt
Papers:
* `A ConvNet for the 2020s` - https://arxiv.org/pdf/2201.03545.pdf
@Article{liu2022convnet,
author = {Zhuang Liu and Hanzi Mao and Chao-Yuan Wu and Christoph Feichtenhofer and Trevor Darrell and Saining Xie},
title = {A ConvNet for the 2020s},
journal = {Proceedings of the IEEE/CVF Confer... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/nfnet.py | timm/models/nfnet.py | """ Normalization Free Nets. NFNet, NF-RegNet, NF-ResNet (pre-activation) Models
Paper: `Characterizing signal propagation to close the performance gap in unnormalized ResNets`
- https://arxiv.org/abs/2101.08692
Paper: `High-Performance Large-Scale Image Recognition Without Normalization`
- https://arxiv.org/... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/factory.py | timm/models/factory.py | from ._factory import *
import warnings
warnings.warn(f"Importing from {__name__} is deprecated, please import via timm.models", FutureWarning)
| python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/csatv2.py | timm/models/csatv2.py | """CSATv2
A frequency-domain vision model using DCT transforms with spatial attention.
Paper: TBD
This model created by members of MLPA Lab. Welcome feedback and suggestion, questions.
gusdlf93@naver.com
juno.demie.oh@gmail.com
Refined for timm by Ross Wightman
"""
import math
import warnings
from functools import ... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/tiny_vit.py | timm/models/tiny_vit.py | """ TinyViT
Paper: `TinyViT: Fast Pretraining Distillation for Small Vision Transformers`
- https://arxiv.org/abs/2207.10666
Adapted from official impl at https://github.com/microsoft/Cream/tree/main/TinyViT
"""
__all__ = ['TinyVit']
import itertools
from functools import partial
from typing import Dict, List, ... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/twins.py | timm/models/twins.py | """ Twins
A PyTorch impl of : `Twins: Revisiting the Design of Spatial Attention in Vision Transformers`
- https://arxiv.org/pdf/2104.13840.pdf
Code/weights from https://github.com/Meituan-AutoML/Twins, original copyright/license info below
"""
# --------------------------------------------------------
# Twins
# ... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/__init__.py | timm/models/__init__.py | from .beit import *
from .byoanet import *
from .byobnet import *
from .cait import *
from .coat import *
from .convit import *
from .convmixer import *
from .convnext import *
from .crossvit import *
from .csatv2 import *
from .cspnet import *
from .davit import *
from .deit import *
from .densenet import *
from .dla ... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/vitamin.py | timm/models/vitamin.py | """ ViTamin
Paper: Designing Scalable Vison Models in the Vision-Language Era
A family of model weights on Huggingface: https://huggingface.co/collections/jienengchen/vitamin-family-661048126b72debdaca060bf
@inproceedings{chen2024vitamin,
title={ViTamin: Designing Scalable Vision Models in the Vision-language Era},... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/mlp_mixer.py | timm/models/mlp_mixer.py | """ MLP-Mixer, ResMLP, and gMLP in PyTorch
This impl originally based on MLP-Mixer paper.
Official JAX impl: https://github.com/google-research/vision_transformer/blob/linen/vit_jax/models_mixer.py
Paper: 'MLP-Mixer: An all-MLP Architecture for Vision' - https://arxiv.org/abs/2105.01601
@article{tolstikhin2021,
t... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/davit.py | timm/models/davit.py | """ DaViT: Dual Attention Vision Transformers
As described in https://arxiv.org/abs/2204.03645
Input size invariant transformer architecture that combines channel and spacial
attention in each block. The attention mechanisms used are linear in complexity.
DaViT model defs and weights adapted from https://github.com/... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/focalnet.py | timm/models/focalnet.py | """ FocalNet
As described in `Focal Modulation Networks` - https://arxiv.org/abs/2203.11926
Significant modifications and refactoring from the original impl at https://github.com/microsoft/FocalNet
This impl is/has:
* fully convolutional, NCHW tensor layout throughout, seemed to have minimal performance impact but m... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/senet.py | timm/models/senet.py | """
SEResNet implementation from Cadene's pretrained models
https://github.com/Cadene/pretrained-models.pytorch/blob/master/pretrainedmodels/models/senet.py
Additional credit to https://github.com/creafz
Original model: https://github.com/hujie-frank/SENet
ResNet code gently borrowed from
https://github.com/pytorch/v... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/efficientvit_msra.py | timm/models/efficientvit_msra.py | """ EfficientViT (by MSRA)
Paper: `EfficientViT: Memory Efficient Vision Transformer with Cascaded Group Attention`
- https://arxiv.org/abs/2305.07027
Adapted from official impl at https://github.com/microsoft/Cream/tree/main/EfficientViT
"""
__all__ = ['EfficientVitMsra']
import itertools
from collections impor... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/xcit.py | timm/models/xcit.py | """ Cross-Covariance Image Transformer (XCiT) in PyTorch
Paper:
- https://arxiv.org/abs/2106.09681
Same as the official implementation, with some minor adaptations, original copyright below
- https://github.com/facebookresearch/xcit/blob/master/xcit.py
Modifications and additions for timm hacked together by ... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/convit.py | timm/models/convit.py | """ ConViT Model
@article{d2021convit,
title={ConViT: Improving Vision Transformers with Soft Convolutional Inductive Biases},
author={d'Ascoli, St{\'e}phane and Touvron, Hugo and Leavitt, Matthew and Morcos, Ari and Biroli, Giulio and Sagun, Levent},
journal={arXiv preprint arXiv:2103.10697},
year={2021}
}
P... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/metaformer.py | timm/models/metaformer.py | """
Poolformer from MetaFormer is Actually What You Need for Vision https://arxiv.org/abs/2111.11418
IdentityFormer, RandFormer, PoolFormerV2, ConvFormer, and CAFormer
from MetaFormer Baselines for Vision https://arxiv.org/abs/2210.13452
All implemented models support feature extraction and variable input resolution.... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/_features.py | timm/models/_features.py | """ PyTorch Feature Extraction Helpers
A collection of classes, functions, modules to help extract features from models
and provide a common interface for describing them.
The return_layers, module re-writing idea inspired by torchvision IntermediateLayerGetter
https://github.com/pytorch/vision/blob/d88d8961ae51507d0... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/_builder.py | timm/models/_builder.py | import dataclasses
import logging
import os
from copy import deepcopy
from pathlib import Path
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, TypeVar, Union
from torch import nn as nn
from torch.hub import load_state_dict_from_url
from timm.models._features import FeatureListNet, FeatureDictNet,... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/inception_resnet_v2.py | timm/models/inception_resnet_v2.py | """ Pytorch Inception-Resnet-V2 implementation
Sourced from https://github.com/Cadene/tensorflow-model-zoo.torch (MIT License) which is
based upon Google's Tensorflow implementation and pretrained weights (Apache 2.0 License)
"""
from functools import partial
from typing import Type, Optional
import torch
import torch.... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/volo.py | timm/models/volo.py | """ Vision OutLOoker (VOLO) implementation
Paper: `VOLO: Vision Outlooker for Visual Recognition` - https://arxiv.org/abs/2106.13112
Code adapted from official impl at https://github.com/sail-sg/volo, original copyright in comment below
Modifications and additions for timm by / Copyright 2022, Ross Wightman
"""
# Co... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/cspnet.py | timm/models/cspnet.py | """PyTorch CspNet
A PyTorch implementation of Cross Stage Partial Networks including:
* CSPResNet50
* CSPResNeXt50
* CSPDarkNet53
* and DarkNet53 for good measure
Based on paper `CSPNet: A New Backbone that can Enhance Learning Capability of CNN` - https://arxiv.org/abs/1911.11929
Reference impl via darknet cfg file... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/_features_fx.py | timm/models/_features_fx.py | """ PyTorch FX Based Feature Extraction Helpers
Using https://pytorch.org/vision/stable/feature_extraction.html
"""
from typing import Callable, Dict, List, Optional, Union, Tuple, Type
import torch
from torch import nn
from timm.layers import (
create_feature_extractor,
get_graph_node_names,
register_not... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/gcvit.py | timm/models/gcvit.py | """ Global Context ViT
From scratch implementation of GCViT in the style of timm swin_transformer_v2_cr.py
Global Context Vision Transformers -https://arxiv.org/abs/2206.09959
@article{hatamizadeh2022global,
title={Global Context Vision Transformers},
author={Hatamizadeh, Ali and Yin, Hongxu and Kautz, Jan and M... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/efficientformer.py | timm/models/efficientformer.py | """ EfficientFormer
@article{li2022efficientformer,
title={EfficientFormer: Vision Transformers at MobileNet Speed},
author={Li, Yanyu and Yuan, Geng and Wen, Yang and Hu, Eric and Evangelidis, Georgios and Tulyakov,
Sergey and Wang, Yanzhi and Ren, Jian},
journal={arXiv preprint arXiv:2206.01191},
year={20... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/mobilenetv5.py | timm/models/mobilenetv5.py | from functools import partial
from typing import Callable, Dict, List, Optional, Sequence, Tuple, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
from timm.data import IMAGENET_INCEPTION_MEAN, IMAGENET_INCEPTION_STD
from timm.layers import (
SelectAdaptivePool2d,
Linear,
LayerType... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | true |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/inception_next.py | timm/models/inception_next.py | """
InceptionNeXt paper: https://arxiv.org/abs/2303.16900
Original implementation & weights from: https://github.com/sail-sg/inceptionnext
"""
from functools import partial
from typing import List, Optional, Tuple, Union, Type
import torch
import torch.nn as nn
from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_D... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/sequencer.py | timm/models/sequencer.py | """ Sequencer
Paper: `Sequencer: Deep LSTM for Image Classification` - https://arxiv.org/pdf/2205.01972.pdf
"""
# Copyright (c) 2022. Yuki Tatsunami
# Licensed under the Apache License, Version 2.0 (the "License");
import math
from functools import partial
from itertools import accumulate
from typing import List, ... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/efficientformer_v2.py | timm/models/efficientformer_v2.py | """ EfficientFormer-V2
@article{
li2022rethinking,
title={Rethinking Vision Transformers for MobileNet Size and Speed},
author={Li, Yanyu and Hu, Ju and Wen, Yang and Evangelidis, Georgios and Salahi, Kamyar and Wang, Yanzhi and Tulyakov, Sergey and Ren, Jian},
journal={arXiv preprint arXiv:2212.08059}... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/_efficientnet_builder.py | timm/models/_efficientnet_builder.py | """ EfficientNet, MobileNetV3, etc Builder
Assembles EfficieNet and related network feature blocks from string definitions.
Handles stride, dilation calculations, and selects feature extraction points.
Hacked together by / Copyright 2019, Ross Wightman
"""
from typing import Callable, Optional
import logging
import ... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/mobilevit.py | timm/models/mobilevit.py | """ MobileViT
Paper:
V1: `MobileViT: Light-weight, General-purpose, and Mobile-friendly Vision Transformer` - https://arxiv.org/abs/2110.02178
V2: `Separable Self-attention for Mobile Vision Transformers` - https://arxiv.org/abs/2206.02680
MobileVitBlock and checkpoints adapted from https://github.com/apple/ml-cvnets... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
huggingface/pytorch-image-models | https://github.com/huggingface/pytorch-image-models/blob/31a85de79aad229c070c595c5ea0c43dfc95461e/timm/models/coat.py | timm/models/coat.py | """
CoaT architecture.
Paper: Co-Scale Conv-Attentional Image Transformers - https://arxiv.org/abs/2104.06399
Official CoaT code at: https://github.com/mlpc-ucsd/CoaT
Modified from timm/models/vision_transformer.py
"""
from typing import List, Optional, Tuple, Union, Type, Any
import torch
import torch.nn as nn
imp... | python | Apache-2.0 | 31a85de79aad229c070c595c5ea0c43dfc95461e | 2026-01-04T14:41:55.902905Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.