repo_id stringlengths 15 89 | file_path stringlengths 27 180 | content stringlengths 1 2.23M | __index_level_0__ int64 0 0 |
|---|---|---|---|
hf_public_repos/pytorch-image-models/docs/models/.templates | hf_public_repos/pytorch-image-models/docs/models/.templates/models/mnasnet.md | # MnasNet
**MnasNet** is a type of convolutional neural network optimized for mobile devices that is discovered through mobile neural architecture search, which explicitly incorporates model latency into the main objective so that the search can identify a model that achieves a good trade-off between accuracy and late... | 0 |
hf_public_repos/pytorch-image-models/docs/models/.templates | hf_public_repos/pytorch-image-models/docs/models/.templates/models/adversarial-inception-v3.md | # Adversarial Inception v3
**Inception v3** is a convolutional neural network architecture from the Inception family that makes several improvements including using [Label Smoothing](https://paperswithcode.com/method/label-smoothing), Factorized 7 x 7 convolutions, and the use of an [auxiliary classifer](https://paper... | 0 |
hf_public_repos/pytorch-image-models/docs/models/.templates | hf_public_repos/pytorch-image-models/docs/models/.templates/models/rexnet.md | # RexNet
**Rank Expansion Networks** (ReXNets) follow a set of new design principles for designing bottlenecks in image classification models. Authors refine each layer by 1) expanding the input channel size of the convolution layer and 2) replacing the [ReLU6s](https://www.paperswithcode.com/method/relu6).
{% includ... | 0 |
hf_public_repos/pytorch-image-models/docs/models/.templates | hf_public_repos/pytorch-image-models/docs/models/.templates/models/selecsls.md | # SelecSLS
**SelecSLS** uses novel selective long and short range skip connections to improve the information flow allowing for a drastically faster network without compromising accuracy.
{% include 'code_snippets.md' %}
## How do I train this model?
You can follow the [timm recipe scripts](https://rwightman.github... | 0 |
hf_public_repos/pytorch-image-models/docs/models/.templates | hf_public_repos/pytorch-image-models/docs/models/.templates/models/csp-darknet.md | # CSP-DarkNet
**CSPDarknet53** is a convolutional neural network and backbone for object detection that uses [DarkNet-53](https://paperswithcode.com/method/darknet-53). It employs a CSPNet strategy to partition the feature map of the base layer into two parts and then merges them through a cross-stage hierarchy. The u... | 0 |
hf_public_repos/pytorch-image-models/docs/models/.templates | hf_public_repos/pytorch-image-models/docs/models/.templates/models/res2net.md | # Res2Net
**Res2Net** is an image model that employs a variation on bottleneck residual blocks, [Res2Net Blocks](https://paperswithcode.com/method/res2net-block). The motivation is to be able to represent features at multiple scales. This is achieved through a novel building block for CNNs that constructs hierarchical... | 0 |
hf_public_repos/pytorch-image-models/docs/models/.templates | hf_public_repos/pytorch-image-models/docs/models/.templates/models/legacy-senet.md | # (Legacy) SENet
A **SENet** is a convolutional neural network architecture that employs [squeeze-and-excitation blocks](https://paperswithcode.com/method/squeeze-and-excitation-block) to enable the network to perform dynamic channel-wise feature recalibration.
The weights from this model were ported from Gluon.
{% ... | 0 |
hf_public_repos/pytorch-image-models/docs/models/.templates | hf_public_repos/pytorch-image-models/docs/models/.templates/models/big-transfer.md | # Big Transfer (BiT)
**Big Transfer (BiT)** is a type of pretraining recipe that pre-trains on a large supervised source dataset, and fine-tunes the weights on the target task. Models are trained on the JFT-300M dataset. The finetuned models contained in this collection are finetuned on ImageNet.
{% include 'code_sn... | 0 |
hf_public_repos/pytorch-image-models/docs/models/.templates | hf_public_repos/pytorch-image-models/docs/models/.templates/models/csp-resnext.md | # CSP-ResNeXt
**CSPResNeXt** is a convolutional neural network where we apply the Cross Stage Partial Network (CSPNet) approach to [ResNeXt](https://paperswithcode.com/method/resnext). The CSPNet partitions the feature map of the base layer into two parts and then merges them through a cross-stage hierarchy. The use o... | 0 |
hf_public_repos/pytorch-image-models/docs/models/.templates | hf_public_repos/pytorch-image-models/docs/models/.templates/models/dla.md | # Deep Layer Aggregation
Extending “shallow” skip connections, **Dense Layer Aggregation (DLA)** incorporates more depth and sharing. The authors introduce two structures for deep layer aggregation (DLA): iterative deep aggregation (IDA) and hierarchical deep aggregation (HDA). These structures are expressed through ... | 0 |
hf_public_repos/pytorch-image-models/docs/models/.templates | hf_public_repos/pytorch-image-models/docs/models/.templates/models/efficientnet.md | # EfficientNet
**EfficientNet** is a convolutional neural network architecture and scaling method that uniformly scales all dimensions of depth/width/resolution using a *compound coefficient*. Unlike conventional practice that arbitrary scales these factors, the EfficientNet scaling method uniformly scales network wi... | 0 |
hf_public_repos/pytorch-image-models/docs/models/.templates | hf_public_repos/pytorch-image-models/docs/models/.templates/models/legacy-se-resnext.md | # (Legacy) SE-ResNeXt
**SE ResNeXt** is a variant of a [ResNeXt](https://www.paperswithcode.com/method/resnext) that employs [squeeze-and-excitation blocks](https://paperswithcode.com/method/squeeze-and-excitation-block) to enable the network to perform dynamic channel-wise feature recalibration.
{% include 'code_sni... | 0 |
hf_public_repos/pytorch-image-models/docs/models/.templates | hf_public_repos/pytorch-image-models/docs/models/.templates/models/res2next.md | # Res2NeXt
**Res2NeXt** is an image model that employs a variation on [ResNeXt](https://paperswithcode.com/method/resnext) bottleneck residual blocks. The motivation is to be able to represent features at multiple scales. This is achieved through a novel building block for CNNs that constructs hierarchical residual-li... | 0 |
hf_public_repos/pytorch-image-models/docs/models/.templates | hf_public_repos/pytorch-image-models/docs/models/.templates/models/csp-resnet.md | # CSP-ResNet
**CSPResNet** is a convolutional neural network where we apply the Cross Stage Partial Network (CSPNet) approach to [ResNet](https://paperswithcode.com/method/resnet). The CSPNet partitions the feature map of the base layer into two parts and then merges them through a cross-stage hierarchy. The use of a ... | 0 |
hf_public_repos/pytorch-image-models/docs/models/.templates | hf_public_repos/pytorch-image-models/docs/models/.templates/models/densenet.md | # DenseNet
**DenseNet** is a type of convolutional neural network that utilises dense connections between layers, through [Dense Blocks](http://www.paperswithcode.com/method/dense-block), where we connect *all layers* (with matching feature-map sizes) directly with each other. To preserve the feed-forward nature, each... | 0 |
hf_public_repos/pytorch-image-models/docs/models/.templates | hf_public_repos/pytorch-image-models/docs/models/.templates/models/resnest.md | # ResNeSt
A **ResNeSt** is a variant on a [ResNet](https://paperswithcode.com/method/resnet), which instead stacks [Split-Attention blocks](https://paperswithcode.com/method/split-attention). The cardinal group representations are then concatenated along the channel dimension: $V = \text{Concat}${$V^{1},V^{2},\cdots{V... | 0 |
hf_public_repos/pytorch-image-models/docs/models/.templates | hf_public_repos/pytorch-image-models/docs/models/.templates/models/mixnet.md | # MixNet
**MixNet** is a type of convolutional neural network discovered via AutoML that utilises [MixConvs](https://paperswithcode.com/method/mixconv) instead of regular [depthwise convolutions](https://paperswithcode.com/method/depthwise-convolution).
{% include 'code_snippets.md' %}
## How do I train this model?
... | 0 |
hf_public_repos/pytorch-image-models/docs | hf_public_repos/pytorch-image-models/docs/javascripts/tables.js | app.location$.subscribe(function() {
var tables = document.querySelectorAll("article table")
tables.forEach(function(table) {
new Tablesort(table)
})
}) | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/results/benchmark-infer-amp-nchw-pt111-cu113-rtx3090.csv | model,infer_samples_per_sec,infer_step_time,infer_batch_size,infer_img_size,param_count
tinynet_e,47972.76,21.335,1024,106,2.04
mobilenetv3_small_050,42473.43,24.099,1024,224,1.59
lcnet_035,39739.31,25.756,1024,224,1.64
lcnet_050,35211.0,29.071,1024,224,1.88
mobilenetv3_small_075,31410.3,32.589,1024,224,2.04
mobilenetv... | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/results/benchmark-train-amp-nhwc-pt111-cu113-rtx3090.csv | model,train_samples_per_sec,train_step_time,train_batch_size,train_img_size,param_count
tinynet_e,10725.36,46.047,512,106,2.04
mobilenetv3_small_050,9864.52,50.786,512,224,1.59
lcnet_035,9593.72,52.888,512,224,1.64
lcnet_050,8283.82,61.296,512,224,1.88
tf_mobilenetv3_small_minimal_100,8178.73,62.055,512,224,2.04
tinyne... | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/results/benchmark-infer-amp-nchw-pt210-cu121-rtx3090.csv | model,infer_img_size,infer_batch_size,infer_samples_per_sec,infer_step_time,infer_gmacs,infer_macts,param_count
tinynet_e,106,1024.0,50604.03,20.225,0.03,0.69,2.04
mobilenetv3_small_050,224,1024.0,46069.42,22.217,0.03,0.92,1.59
lcnet_035,224,1024.0,41190.64,24.85,0.03,1.04,1.64
lcnet_050,224,1024.0,37663.82,27.178,0.05... | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/results/generate_csv_results.py | import numpy as np
import pandas as pd
results = {
'results-imagenet.csv': [
'results-imagenet-real.csv',
'results-imagenetv2-matched-frequency.csv',
'results-sketch.csv'
],
'results-imagenet-a-clean.csv': [
'results-imagenet-a.csv',
],
'results-imagenet-r-clean.csv... | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/results/results-imagenet-real.csv | model,top1,top1_err,top5,top5_err,param_count,img_size,crop_pct,interpolation,top1_diff,top5_diff,rank_diff
eva02_large_patch14_448.mim_m38m_ft_in22k_in1k,91.129,8.871,98.713,1.287,305.08,448,1.000,bicubic,+1.077,-0.335,0
eva_giant_patch14_336.clip_ft_in1k,91.058,8.942,98.602,1.399,"1,013.01",336,1.000,bicubic,+1.592,-... | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/results/results-imagenet-r.csv | model,top1,top1_err,top5,top5_err,param_count,img_size,crop_pct,interpolation,top1_diff,top5_diff,rank_diff
convnext_xxlarge.clip_laion2b_soup_ft_in1k,90.623,9.377,97.913,2.087,846.47,256,1.000,bicubic,-7.127,-1.897,+18
eva_giant_patch14_336.clip_ft_in1k,90.550,9.450,97.230,2.770,"1,013.01",336,1.000,bicubic,-7.310,-2.... | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/results/results-imagenet-a-clean.csv | model,top1,top1_err,top5,top5_err,param_count,img_size,crop_pct,interpolation
eva02_large_patch14_448.mim_in22k_ft_in22k_in1k,98.930,1.070,99.910,0.090,305.08,448,1.000,bicubic
eva02_large_patch14_448.mim_m38m_ft_in22k_in1k,98.850,1.150,99.880,0.120,305.08,448,1.000,bicubic
eva02_large_patch14_448.mim_in22k_ft_in1k,98.... | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/results/benchmark-infer-amp-nhwc-pt113-cu117-rtx3090.csv | model,infer_samples_per_sec,infer_step_time,infer_batch_size,infer_img_size,infer_gmacs,infer_macts,param_count
tinynet_e,72737.62,14.068,1024,106,0.03,0.69,2.04
mobilenetv3_small_050,54822.3,18.668,1024,224,0.03,0.92,1.59
lcnet_035,53629.35,19.084,1024,224,0.03,1.04,1.64
lcnet_050,45492.41,22.499,1024,224,0.05,1.26,1.... | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/results/results-imagenet-a.csv | model,top1,top1_err,top5,top5_err,param_count,img_size,crop_pct,interpolation,top1_diff,top5_diff,rank_diff
eva02_large_patch14_448.mim_m38m_ft_in22k_in1k,88.227,11.773,97.093,2.907,305.08,448,1.000,bicubic,-10.623,-2.787,+1
eva02_large_patch14_448.mim_in22k_ft_in22k_in1k,87.893,12.107,96.920,3.080,305.08,448,1.000,bic... | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/results/benchmark-infer-amp-nchw-pt112-cu113-rtx3090.csv | model,infer_samples_per_sec,infer_step_time,infer_batch_size,infer_img_size,infer_gmacs,infer_macts,param_count
tinynet_e,49285.12,20.767,1024,106,0.03,0.69,2.04
mobilenetv3_small_050,43905.96,23.312,1024,224,0.03,0.92,1.59
lcnet_035,40961.84,24.988,1024,224,0.03,1.04,1.64
lcnet_050,36451.18,28.081,1024,224,0.05,1.26,1... | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/results/results-imagenet-r-clean.csv | model,top1,top1_err,top5,top5_err,param_count,img_size,crop_pct,interpolation
eva02_large_patch14_448.mim_in22k_ft_in22k_in1k,98.150,1.850,99.880,0.120,305.08,448,1.000,bicubic
eva02_large_patch14_448.mim_m38m_ft_in22k_in1k,98.030,1.970,99.890,0.110,305.08,448,1.000,bicubic
eva_giant_patch14_560.m30m_ft_in22k_in1k,98.0... | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/results/benchmark-train-amp-nhwc-pt112-cu113-rtx3090.csv | model,train_samples_per_sec,train_step_time,train_batch_size,train_img_size,param_count
tinynet_e,11915.85,41.681,512,106,2.04
mobilenetv3_small_050,11290.99,44.293,512,224,1.59
lcnet_035,10015.98,50.125,512,224,1.64
lcnet_050,9286.37,54.37,512,224,1.88
tf_mobilenetv3_small_minimal_100,9042.22,55.986,512,224,2.04
mobil... | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/results/README.md | # Validation and Benchmark Results
This folder contains validation and benchmark results for the models in this collection. Validation scores are currently only run for models with pretrained weights and ImageNet-1k heads, benchmark numbers are run for all.
## Datasets
There are currently results for the ImageNet va... | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/results/results-imagenetv2-matched-frequency.csv | model,top1,top1_err,top5,top5_err,param_count,img_size,crop_pct,interpolation,top1_diff,top5_diff,rank_diff
eva_giant_patch14_336.clip_ft_in1k,82.200,17.800,96.290,3.710,"1,013.01",336,1.000,bicubic,-7.266,-2.536,+6
eva02_large_patch14_448.mim_in22k_ft_in1k,82.130,17.870,96.260,3.740,305.08,448,1.000,bicubic,-7.492,-2.... | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/results/model_metadata-in1k.csv | model,pretrain
adv_inception_v3,in1k-adv
bat_resnext26ts,in1k
beit_base_patch16_224,in21k-selfsl
beit_base_patch16_384,in21k-selfsl
beit_large_patch16_224,in21k-selfsl
beit_large_patch16_384,in21k-selfsl
beit_large_patch16_512,in21k-selfsl
botnet26t_256,in1k
cait_m36_384,in1k-dist
cait_m48_448,in1k-dist
cait_s24_224,in... | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/results/benchmark-infer-amp-nhwc-pt210-cu121-rtx3090.csv | model,infer_img_size,infer_batch_size,infer_samples_per_sec,infer_step_time,infer_gmacs,infer_macts,param_count
tinynet_e,106,1024.0,75290.96,13.591,0.03,0.69,2.04
mobilenetv3_small_050,224,1024.0,56785.93,18.023,0.03,0.92,1.59
efficientvit_m0,224,1024.0,50656.23,20.205,0.08,0.91,2.35
lcnet_035,224,1024.0,48853.22,20.9... | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/results/benchmark-train-amp-nchw-pt111-cu113-rtx3090.csv | model,train_samples_per_sec,train_step_time,train_batch_size,train_img_size,param_count
tinynet_e,9380.97,53.881,512,106,2.04
mobilenetv3_small_050,7276.68,69.643,512,224,1.59
tf_mobilenetv3_small_minimal_100,6334.14,80.291,512,224,2.04
mobilenetv3_small_075,5920.21,85.765,512,224,2.04
lcnet_035,5760.61,88.397,512,224,... | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/results/benchmark-infer-amp-nhwc-pt111-cu113-rtx3090.csv | model,infer_samples_per_sec,infer_step_time,infer_batch_size,infer_img_size,param_count
tinynet_e,68298.73,14.982,1024,106,2.04
mobilenetv3_small_050,48773.32,20.985,1024,224,1.59
lcnet_035,47045.94,21.755,1024,224,1.64
lcnet_050,41541.83,24.639,1024,224,1.88
mobilenetv3_small_075,37803.23,27.076,1024,224,2.04
mobilene... | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/results/benchmark-train-amp-nchw-pt112-cu113-rtx3090.csv | model,train_samples_per_sec,train_step_time,train_batch_size,train_img_size,param_count
tinynet_e,10001.12,50.423,512,106,2.04
mobilenetv3_small_050,7406.47,68.392,512,224,1.59
tf_mobilenetv3_small_minimal_100,6438.14,78.983,512,224,2.04
mobilenetv3_small_075,6186.83,82.006,512,224,2.04
tf_mobilenetv3_small_075,5783.46... | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/results/benchmark-infer-amp-nhwc-pt112-cu113-rtx3090.csv | model,infer_samples_per_sec,infer_step_time,infer_batch_size,infer_img_size,infer_gmacs,infer_macts,param_count
tinynet_e,70939.06,14.424,1024,106,0.03,0.69,2.04
mobilenetv3_small_050,53363.87,19.179,1024,224,0.03,0.92,1.59
lcnet_035,39908.29,25.648,1024,224,0.03,1.04,1.64
mobilenetv3_small_075,38048.72,26.902,1024,224... | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/results/benchmark-infer-amp-nchw-pt113-cu117-rtx3090.csv | model,infer_samples_per_sec,infer_step_time,infer_batch_size,infer_img_size,infer_gmacs,infer_macts,param_count
tinynet_e,49277.65,20.77,1024,106,0.03,0.69,2.04
mobilenetv3_small_050,45562.75,22.464,1024,224,0.03,0.92,1.59
lcnet_035,41026.68,24.949,1024,224,0.03,1.04,1.64
lcnet_050,37575.13,27.242,1024,224,0.05,1.26,1.... | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/results/results-imagenet.csv | model,top1,top1_err,top5,top5_err,param_count,img_size,crop_pct,interpolation
eva02_large_patch14_448.mim_m38m_ft_in22k_in1k,90.052,9.948,99.048,0.952,305.08,448,1.000,bicubic
eva02_large_patch14_448.mim_in22k_ft_in22k_in1k,89.970,10.030,99.012,0.988,305.08,448,1.000,bicubic
eva_giant_patch14_560.m30m_ft_in22k_in1k,89.... | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/results/results-sketch.csv | model,top1,top1_err,top5,top5_err,param_count,img_size,crop_pct,interpolation,top1_diff,top5_diff,rank_diff
eva_giant_patch14_336.clip_ft_in1k,71.177,28.823,90.299,9.701,"1,013.01",336,1.000,bicubic,-18.289,-8.527,+6
eva02_large_patch14_448.mim_m38m_ft_in22k_in1k,70.662,29.338,89.856,10.144,305.08,448,1.000,bicubic,-19... | 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/timm/version.py | __version__ = '0.9.13dev0'
| 0 |
hf_public_repos/pytorch-image-models | hf_public_repos/pytorch-image-models/timm/__init__.py | from .version import __version__
from .layers import is_scriptable, is_exportable, set_scriptable, set_exportable
from .models import create_model, list_models, list_pretrained, is_model, list_modules, model_entrypoint, \
is_model_pretrained, get_pretrained_cfg, get_pretrained_cfg_value
| 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/ml_decoder.py | from typing import Optional
import torch
from torch import nn
from torch import nn, Tensor
from torch.nn.modules.transformer import _get_activation_fn
def add_ml_decoder_head(model):
if hasattr(model, 'global_pool') and hasattr(model, 'fc'): # most CNN models, like Resnet50
model.global_pool = nn.Identi... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/std_conv.py | """ Convolution with Weight Standardization (StdConv and ScaledStdConv)
StdConv:
@article{weightstandardization,
author = {Siyuan Qiao and Huiyu Wang and Chenxi Liu and Wei Shen and Alan Yuille},
title = {Weight Standardization},
journal = {arXiv preprint arXiv:1903.10520},
year = {2019},
}
Code:... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/squeeze_excite.py | """ Squeeze-and-Excitation Channel Attention
An SE implementation originally based on PyTorch SE-Net impl.
Has since evolved with additional functionality / configuration.
Paper: `Squeeze-and-Excitation Networks` - https://arxiv.org/abs/1709.01507
Also included is Effective Squeeze-Excitation (ESE).
Paper: `CenterMa... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/conv2d_same.py | """ Conv2d w/ Same Padding
Hacked together by / Copyright 2020 Ross Wightman
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
from typing import Tuple, Optional
from .config import is_exportable, is_scriptable
from .padding import pad_same, pad_same_arg, get_padding_value
_USE_EXPORT_CONV = Fa... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/classifier.py | """ Classifier head and layer factory
Hacked together by / Copyright 2020 Ross Wightman
"""
from collections import OrderedDict
from functools import partial
from typing import Optional, Union, Callable
import torch
import torch.nn as nn
from torch.nn import functional as F
from .adaptive_avgmax_pool import SelectAd... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/config.py | """ Model / Layer Config singleton state
"""
import os
import warnings
from typing import Any, Optional
import torch
__all__ = [
'is_exportable', 'is_scriptable', 'is_no_jit', 'use_fused_attn',
'set_exportable', 'set_scriptable', 'set_no_jit', 'set_layer_config', 'set_fused_attn'
]
# Set to True if prefer to... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/mixed_conv2d.py | """ PyTorch Mixed Convolution
Paper: MixConv: Mixed Depthwise Convolutional Kernels (https://arxiv.org/abs/1907.09595)
Hacked together by / Copyright 2020 Ross Wightman
"""
import torch
from torch import nn as nn
from .conv2d_same import create_conv2d_pad
def _split_channels(num_chan, num_groups):
split = [nu... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/attention_pool2d.py | """ Attention Pool 2D
Implementations of 2D spatial feature pooling using multi-head attention instead of average pool.
Based on idea in CLIP by OpenAI, licensed Apache 2.0
https://github.com/openai/CLIP/blob/3b473b0e682c091a9e53623eebc1ca1657385717/clip/model.py
Hacked together by / Copyright 2021 Ross Wightman
"""... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/space_to_depth.py | import torch
import torch.nn as nn
class SpaceToDepth(nn.Module):
bs: torch.jit.Final[int]
def __init__(self, block_size=4):
super().__init__()
assert block_size == 4
self.bs = block_size
def forward(self, x):
N, C, H, W = x.size()
x = x.view(N, C, H // self.bs, s... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/grn.py | """ Global Response Normalization Module
Based on the GRN layer presented in
`ConvNeXt-V2 - Co-designing and Scaling ConvNets with Masked Autoencoders` - https://arxiv.org/abs/2301.00808
This implementation
* works for both NCHW and NHWC tensor layouts
* uses affine param names matching existing torch norm layers
* s... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/create_act.py | """ Activation Factory
Hacked together by / Copyright 2020 Ross Wightman
"""
from typing import Union, Callable, Type
from .activations import *
from .activations_jit import *
from .activations_me import *
from .config import is_exportable, is_scriptable, is_no_jit
# PyTorch has an optimized, native 'silu' (aka 'swis... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/activations_me.py | """ Activations (memory-efficient w/ custom autograd)
A collection of activations fn and modules with a common interface so that they can
easily be swapped. All have an `inplace` arg even if not used.
These activations are not compatible with jit scripting or ONNX export of the model, please use either
the JIT or bas... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/pos_embed_sincos.py | """ Sin-cos, fourier, rotary position embedding modules and functions
Hacked together by / Copyright 2022 Ross Wightman
"""
import math
from typing import List, Tuple, Optional, Union
import torch
from torch import nn as nn
from .trace_utils import _assert
def pixel_freq_bands(
num_bands: int,
max_... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/activations.py | """ Activations
A collection of activations fn and modules with a common interface so that they can
easily be swapped. All have an `inplace` arg even if not used.
Hacked together by / Copyright 2020 Ross Wightman
"""
import torch
from torch import nn as nn
from torch.nn import functional as F
def swish(x, inplace:... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/create_norm.py | """ Norm Layer Factory
Create norm modules by string (to mirror create_act and creat_norm-act fns)
Copyright 2022 Ross Wightman
"""
import functools
import types
from typing import Type
import torch.nn as nn
from .norm import GroupNorm, GroupNorm1, LayerNorm, LayerNorm2d, RmsNorm
from torchvision.ops.misc import Fr... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/linear.py | """ Linear layer (alternate definition)
"""
import torch
import torch.nn.functional as F
from torch import nn as nn
class Linear(nn.Linear):
r"""Applies a linear transformation to the incoming data: :math:`y = xA^T + b`
Wraps torch.nn.Linear to support AMP + torchscript usage by manually casting
weight &... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/separable_conv.py | """ Depthwise Separable Conv Modules
Basic DWS convs. Other variations of DWS exist with batch norm or activations between the
DW and PW convs such as the Depthwise modules in MobileNetV2 / EfficientNet and Xception.
Hacked together by / Copyright 2020 Ross Wightman
"""
from torch import nn as nn
from .create_conv2d... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/trace_utils.py | try:
from torch import _assert
except ImportError:
def _assert(condition: bool, message: str):
assert condition, message
def _float_to_int(x: float) -> int:
"""
Symbolic tracing helper to substitute for inbuilt `int`.
Hint: Inbuilt `int` can't accept an argument of type `Proxy`
"""
... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/norm.py | """ Normalization layers and wrappers
Norm layer definitions that support fast norm and consistent channel arg order (always first arg).
Hacked together by / Copyright 2022 Ross Wightman
"""
import numbers
from typing import Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from .fast_norm im... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/gather_excite.py | """ Gather-Excite Attention Block
Paper: `Gather-Excite: Exploiting Feature Context in CNNs` - https://arxiv.org/abs/1810.12348
Official code here, but it's only partial impl in Caffe: https://github.com/hujie-frank/GENet
I've tried to support all of the extent both w/ and w/o params. I don't believe I've seen anoth... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/create_conv2d.py | """ Create Conv2d Factory Method
Hacked together by / Copyright 2020 Ross Wightman
"""
from .mixed_conv2d import MixedConv2d
from .cond_conv2d import CondConv2d
from .conv2d_same import create_conv2d_pad
def create_conv2d(in_channels, out_channels, kernel_size, **kwargs):
""" Select a 2d convolution implementat... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/non_local_attn.py | """ Bilinear-Attention-Transform and Non-Local Attention
Paper: `Non-Local Neural Networks With Grouped Bilinear Attentional Transforms`
- https://openaccess.thecvf.com/content_CVPR_2020/html/Chi_Non-Local_Neural_Networks_With_Grouped_Bilinear_Attentional_Transforms_CVPR_2020_paper.html
Adapted from original code:... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/__init__.py | from .activations import *
from .adaptive_avgmax_pool import \
adaptive_avgmax_pool2d, select_adaptive_pool2d, AdaptiveAvgMaxPool2d, SelectAdaptivePool2d
from .attention_pool import AttentionPoolLatent
from .attention_pool2d import AttentionPool2d, RotAttentionPool2d, RotaryEmbedding
from .blur_pool import BlurPool... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/format.py | from enum import Enum
from typing import Union
import torch
class Format(str, Enum):
NCHW = 'NCHW'
NHWC = 'NHWC'
NCL = 'NCL'
NLC = 'NLC'
FormatT = Union[str, Format]
def get_spatial_dim(fmt: FormatT):
fmt = Format(fmt)
if fmt is Format.NLC:
dim = (1,)
elif fmt is Format.NCL:
... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/pool2d_same.py | """ AvgPool2d w/ Same Padding
Hacked together by / Copyright 2020 Ross Wightman
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
from typing import List, Tuple, Optional
from .helpers import to_2tuple
from .padding import pad_same, get_padding_value
def avg_pool2d_same(x, kernel_size: List[int... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/bottleneck_attn.py | """ Bottleneck Self Attention (Bottleneck Transformers)
Paper: `Bottleneck Transformers for Visual Recognition` - https://arxiv.org/abs/2101.11605
@misc{2101.11605,
Author = {Aravind Srinivas and Tsung-Yi Lin and Niki Parmar and Jonathon Shlens and Pieter Abbeel and Ashish Vaswani},
Title = {Bottleneck Transformers f... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/lambda_layer.py | """ Lambda Layer
Paper: `LambdaNetworks: Modeling Long-Range Interactions Without Attention`
- https://arxiv.org/abs/2102.08602
@misc{2102.08602,
Author = {Irwan Bello},
Title = {LambdaNetworks: Modeling Long-Range Interactions Without Attention},
Year = {2021},
}
Status:
This impl is a WIP. Code snippets in the... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/attention_pool.py | from typing import Optional
import torch
import torch.nn as nn
import torch.nn.functional as F
from .config import use_fused_attn
from .mlp import Mlp
from .weight_init import trunc_normal_tf_
class AttentionPoolLatent(nn.Module):
""" Attention pooling w/ latent query
"""
fused_attn: torch.jit.Final[boo... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/pos_embed_rel.py | """ Relative position embedding modules and functions
Hacked together by / Copyright 2022 Ross Wightman
"""
import math
import os
from typing import Optional, Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from .interpolate import RegularGridInterpolator
from .mlp import Mlp
from .weight_in... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/fast_norm.py | """ 'Fast' Normalization Functions
For GroupNorm and LayerNorm these functions bypass typical AMP upcast to float32.
Additionally, for LayerNorm, the APEX fused LN is used if available (which also does not upcast)
Hacked together by / Copyright 2022 Ross Wightman
"""
from typing import List, Optional
import torch
f... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/mlp.py | """ MLP module w/ dropout and configurable activation layer
Hacked together by / Copyright 2020 Ross Wightman
"""
from functools import partial
from torch import nn as nn
from .grn import GlobalResponseNorm
from .helpers import to_2tuple
class Mlp(nn.Module):
""" MLP as used in Vision Transformer, MLP-Mixer an... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/adaptive_avgmax_pool.py | """ PyTorch selectable adaptive pooling
Adaptive pooling with the ability to select the type of pooling from:
* 'avg' - Average pooling
* 'max' - Max pooling
* 'avgmax' - Sum of average and max pooling re-scaled by 0.5
* 'avgmaxc' - Concatenation of average and max pooling along feature dim, doubles fea... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/inplace_abn.py | import torch
from torch import nn as nn
try:
from inplace_abn.functions import inplace_abn, inplace_abn_sync
has_iabn = True
except ImportError:
has_iabn = False
def inplace_abn(x, weight, bias, running_mean, running_var,
training=True, momentum=0.1, eps=1e-05, activation="leaky_re... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/pos_embed.py | """ Position Embedding Utilities
Hacked together by / Copyright 2022 Ross Wightman
"""
import logging
import math
from typing import List, Tuple, Optional, Union
import torch
import torch.nn.functional as F
from .helpers import to_2tuple
_logger = logging.getLogger(__name__)
def resample_abs_pos_embed(
po... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/conv_bn_act.py | """ Conv2d + BN + Act
Hacked together by / Copyright 2020 Ross Wightman
"""
import functools
from torch import nn as nn
from .create_conv2d import create_conv2d
from .create_norm_act import get_norm_act_layer
class ConvNormAct(nn.Module):
def __init__(
self,
in_channels,
out_... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/halo_attn.py | """ Halo Self Attention
Paper: `Scaling Local Self-Attention for Parameter Efficient Visual Backbones`
- https://arxiv.org/abs/2103.12731
@misc{2103.12731,
Author = {Ashish Vaswani and Prajit Ramachandran and Aravind Srinivas and Niki Parmar and Blake Hechtman and
Jonathon Shlens},
Title = {Scaling Local Self... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/evo_norm.py | """ EvoNorm in PyTorch
Based on `Evolving Normalization-Activation Layers` - https://arxiv.org/abs/2004.02967
@inproceedings{NEURIPS2020,
author = {Liu, Hanxiao and Brock, Andy and Simonyan, Karen and Le, Quoc},
booktitle = {Advances in Neural Information Processing Systems},
editor = {H. Larochelle and M. Ranzato ... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/split_batchnorm.py | """ Split BatchNorm
A PyTorch BatchNorm layer that splits input batch into N equal parts and passes each through
a separate BN layer. The first split is passed through the parent BN layers with weight/bias
keys the same as the original BN. All other splits pass through BN sub-layers under the '.aux_bn'
namespace.
Thi... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/create_norm_act.py | """ NormAct (Normalizaiton + Activation Layer) Factory
Create norm + act combo modules that attempt to be backwards compatible with separate norm + act
isntances in models. Where these are used it will be possible to swap separate BN + act layers with
combined modules like IABN or EvoNorms.
Hacked together by / Copyr... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/filter_response_norm.py | """ Filter Response Norm in PyTorch
Based on `Filter Response Normalization Layer` - https://arxiv.org/abs/1911.09737
Hacked together by / Copyright 2021 Ross Wightman
"""
import torch
import torch.nn as nn
from .create_act import create_act_layer
from .trace_utils import _assert
def inv_instance_rms(x, eps: float... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/patch_embed.py | """ Image to Patch Embedding using Conv2d
A convolution based approach to patchifying a 2D image w/ embedding projection.
Based on code in:
* https://github.com/google-research/vision_transformer
* https://github.com/google-research/big_vision/tree/main/big_vision
Hacked together by / Copyright 2020 Ross Wightma... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/patch_dropout.py | from typing import Optional, Tuple, Union
import torch
import torch.nn as nn
class PatchDropout(nn.Module):
"""
https://arxiv.org/abs/2212.00794
"""
return_indices: torch.jit.Final[bool]
def __init__(
self,
prob: float = 0.5,
num_prefix_tokens: int = 1,
... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/blur_pool.py | """
BlurPool layer inspired by
- Kornia's Max_BlurPool2d
- Making Convolutional Networks Shift-Invariant Again :cite:`zhang2019shiftinvar`
Hacked together by Chris Ha and Ross Wightman
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from .padding import get_padding
class ... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/interpolate.py | """ Interpolation helpers for timm layers
RegularGridInterpolator from https://github.com/sbarratt/torch_interpolations
Copyright Shane Barratt, Apache 2.0 license
"""
import torch
from itertools import product
class RegularGridInterpolator:
""" Interpolate data defined on a rectilinear grid with even or uneven ... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/eca.py | """
ECA module from ECAnet
paper: ECA-Net: Efficient Channel Attention for Deep Convolutional Neural Networks
https://arxiv.org/abs/1910.03151
Original ECA model borrowed from https://github.com/BangguWu/ECANet
Modified circular ECA implementation and adaption for use in timm package
by Chris Ha https://github.com/V... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/global_context.py | """ Global Context Attention Block
Paper: `GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond`
- https://arxiv.org/abs/1904.11492
Official code consulted as reference: https://github.com/xvjiarui/GCNet
Hacked together by / Copyright 2021 Ross Wightman
"""
from torch import nn as nn
import torc... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/typing.py | from typing import Callable, Tuple, Type, Union
import torch
LayerType = Union[str, Callable, Type[torch.nn.Module]]
PadType = Union[str, int, Tuple[int, int]]
| 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/median_pool.py | """ Median Pool
Hacked together by / Copyright 2020 Ross Wightman
"""
import torch.nn as nn
import torch.nn.functional as F
from .helpers import to_2tuple, to_4tuple
class MedianPool2d(nn.Module):
""" Median pool (usable as median filter when stride=1) module.
Args:
kernel_size: size of pooling kern... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/split_attn.py | """ Split Attention Conv2d (for ResNeSt Models)
Paper: `ResNeSt: Split-Attention Networks` - /https://arxiv.org/abs/2004.08955
Adapted from original PyTorch impl at https://github.com/zhanghang1989/ResNeSt
Modified for torchscript compat, performance, and consistency with timm by Ross Wightman
"""
import torch
impor... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/selective_kernel.py | """ Selective Kernel Convolution/Attention
Paper: Selective Kernel Networks (https://arxiv.org/abs/1903.06586)
Hacked together by / Copyright 2020 Ross Wightman
"""
import torch
from torch import nn as nn
from .conv_bn_act import ConvNormActAa
from .helpers import make_divisible
from .trace_utils import _assert
de... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/helpers.py | """ Layer/Module Helpers
Hacked together by / Copyright 2020 Ross Wightman
"""
from itertools import repeat
import collections.abc
# From PyTorch internals
def _ntuple(n):
def parse(x):
if isinstance(x, collections.abc.Iterable) and not isinstance(x, str):
return tuple(x)
return tuple... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/activations_jit.py | """ Activations
A collection of jit-scripted activations fn and modules with a common interface so that they can
easily be swapped. All have an `inplace` arg even if not used.
All jit scripted activations are lacking in-place variations on purpose, scripted kernel fusion does not
currently work across in-place op bou... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/create_attn.py | """ Attention Factory
Hacked together by / Copyright 2021 Ross Wightman
"""
import torch
from functools import partial
from .bottleneck_attn import BottleneckAttn
from .cbam import CbamModule, LightCbamModule
from .eca import EcaModule, CecaModule
from .gather_excite import GatherExcite
from .global_context import Gl... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/padding.py | """ Padding Helpers
Hacked together by / Copyright 2020 Ross Wightman
"""
import math
from typing import List, Tuple
import torch
import torch.nn.functional as F
# Calculate symmetric padding for a convolution
def get_padding(kernel_size: int, stride: int = 1, dilation: int = 1, **_) -> int:
padding = ((stride ... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/cbam.py | """ CBAM (sort-of) Attention
Experimental impl of CBAM: Convolutional Block Attention Module: https://arxiv.org/abs/1807.06521
WARNING: Results with these attention layers have been mixed. They can significantly reduce performance on
some tasks, especially fine-grained it seems. I may end up removing this impl.
Hack... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/cond_conv2d.py | """ PyTorch Conditionally Parameterized Convolution (CondConv)
Paper: CondConv: Conditionally Parameterized Convolutions for Efficient Inference
(https://arxiv.org/abs/1904.04971)
Hacked together by / Copyright 2020 Ross Wightman
"""
import math
from functools import partial
import numpy as np
import torch
from torc... | 0 |
hf_public_repos/pytorch-image-models/timm | hf_public_repos/pytorch-image-models/timm/layers/drop.py | """ DropBlock, DropPath
PyTorch implementations of DropBlock and DropPath (Stochastic Depth) regularization layers.
Papers:
DropBlock: A regularization method for convolutional networks (https://arxiv.org/abs/1810.12890)
Deep Networks with Stochastic Depth (https://arxiv.org/abs/1603.09382)
Code:
DropBlock impl ins... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.