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/timm
hf_public_repos/pytorch-image-models/timm/models/_factory.py
import os from typing import Any, Dict, Optional, Union from urllib.parse import urlsplit from timm.layers import set_layer_config from ._helpers import load_checkpoint from ._hub import load_model_config_from_hf from ._pretrained import PretrainedCfg from ._registry import is_model, model_entrypoint, split_model_name...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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 """ import math import torch ...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/models/features.py
from ._features import * import warnings warnings.warn(f"Importing from {__name__} is deprecated, please import via timm.models", DeprecationWarning)
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/models/res2net.py
""" Res2Net and Res2NeXt Adapted from Official Pytorch impl at: https://github.com/gasvn/Res2Net/ Paper: `Res2Net: A New Multi-scale Backbone Architecture` - https://arxiv.org/abs/1904.01169 """ import math import torch import torch.nn as nn from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD from ._bui...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/models/_features_fx.py
""" PyTorch FX Based Feature Extraction Helpers Using https://pytorch.org/vision/stable/feature_extraction.html """ from typing import Callable, List, Dict, Union, Type import torch from torch import nn from ._features import _get_feature_info, _get_return_layers try: from torchvision.models.feature_extraction i...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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....
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/models/factory.py
from ._factory import * import warnings warnings.warn(f"Importing from {__name__} is deprecated, please import via timm.models", DeprecationWarning)
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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 import torch import torch.nn as nn import tor...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/models/hub.py
from ._hub import * import warnings warnings.warn(f"Importing from {__name__} is deprecated, please import via timm.models", DeprecationWarning)
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/models/_registry.py
""" Model Registry Hacked together by / Copyright 2020 Ross Wightman """ import fnmatch import re import sys import warnings from collections import defaultdict, deque from copy import deepcopy from dataclasses import replace from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Sequence, Union, Tuple...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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 import torch import torch...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/models/_builder.py
import dataclasses import logging import os from copy import deepcopy from typing import Optional, Dict, Callable, Any, Tuple from torch import nn as nn from torch.hub import load_state_dict_from_url from timm.models._features import FeatureListNet, FeatureHookNet from timm.models._features_fx import FeatureGraphNet ...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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 import torch import torch.nn as nn import torch.nn.functional as F from timm.data import IMAGENET_DEFAULT_STD, IMAGENET_DEFAULT_MEAN, IMAGENET_IN...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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, ...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/models/sknet.py
""" Selective Kernel Networks (ResNet base) Paper: Selective Kernel Networks (https://arxiv.org/abs/1903.06586) This was inspired by reading 'Compounding the Performance Improvements...' (https://arxiv.org/abs/2001.06268) and a streamlined impl at https://github.com/clovaai/assembled-cnn but I ended up building somet...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/models/eva.py
""" EVA EVA from https://github.com/baaivision/EVA , paper: https://arxiv.org/abs/2211.07636 @article{EVA, title={EVA: Exploring the Limits of Masked Visual Representation Learning at Scale}, author={Fang, Yuxin and Wang, Wen and Xie, Binhui and Sun, Quan and Wu, Ledell and Wang, Xinggang and Huang, Tiejun and ...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/models/pvt_v2.py
""" Pyramid Vision Transformer v2 @misc{wang2021pvtv2, title={PVTv2: Improved Baselines with Pyramid Vision Transformer}, author={Wenhai Wang and Enze Xie and Xiang Li and Deng-Ping Fan and Kaitao Song and Ding Liang and Tong Lu and Ping Luo and Ling Shao}, year={2021}, eprint={2106.137...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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 Callable, List, Optional, Tuple import torch imp...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/models/fx_features.py
from ._features_fx import * import warnings warnings.warn(f"Importing from {__name__} is deprecated, please import via timm.models", DeprecationWarning)
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/models/_hub.py
import hashlib import json import logging import os from functools import partial from pathlib import Path from tempfile import TemporaryDirectory from typing import Iterable, Optional, Union import torch from torch.hub import HASH_REGEX, download_url_to_file, urlparse try: from torch.hub import get_dir except Im...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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 """ import torch import torch.nn as nn from timm.data import IMAGENET_DEFAU...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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 import torch import torch.nn as nn from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD from timm.layers import trunc_normal_, Drop...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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): layer = layer.split('.') module = model ...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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", DeprecationWarning)
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/models/swin_transformer_v2_cr.py
""" Swin Transformer V2 A PyTorch impl of : `Swin Transformer V2: Scaling Up Capacity and Resolution` - https://arxiv.org/pdf/2111.09883 Code adapted from https://github.com/ChristophReich1996/Swin-Transformer-V2, original copyright/license info below This implementation is experimental and subject to change in ...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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 import torch import torch.nn as nn import torch.nn.functional as F from timm.layers import ConvNormAct, create_conv2d, create_pool2d, create_...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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}...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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, Tuple, Type, Union import torch from torch import nn as nn from torch.utils.checkpoint import checkpoint __all__ = ['model_parameters', 'named_apply', 'named_m...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/models/_helpers.py
""" Model creation / weight loading / state_dict helpers Hacked together by / Copyright 2020 Ross Wightman """ import logging import os from collections import OrderedDict from typing import Any, Callable, Dict, Optional, Union import torch try: import safetensors.torch _has_safetensors = True except ImportEr...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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/...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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 functools import partial from typing import Tuple, List, Union import torch import torch.nn...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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...
0
hf_public_repos/pytorch-image-models/timm/models
hf_public_repos/pytorch-image-models/timm/models/_pruned/efficientnet_b3_pruned.txt
conv_stem.weight:[40, 3, 3, 3]***bn1.weight:[40]***bn1.bias:[40]***bn1.running_mean:[40]***bn1.running_var:[40]***bn1.num_batches_tracked:[]***blocks.0.0.conv_dw.weight:[40, 1, 3, 3]***blocks.0.0.bn1.weight:[40]***blocks.0.0.bn1.bias:[40]***blocks.0.0.bn1.running_mean:[40]***blocks.0.0.bn1.running_var:[40]***blocks.0.0...
0
hf_public_repos/pytorch-image-models/timm/models
hf_public_repos/pytorch-image-models/timm/models/_pruned/efficientnet_b1_pruned.txt
conv_stem.weight:[32, 3, 3, 3]***bn1.weight:[32]***bn1.bias:[32]***bn1.running_mean:[32]***bn1.running_var:[32]***bn1.num_batches_tracked:[]***blocks.0.0.conv_dw.weight:[32, 1, 3, 3]***blocks.0.0.bn1.weight:[32]***blocks.0.0.bn1.bias:[32]***blocks.0.0.bn1.running_mean:[32]***blocks.0.0.bn1.running_var:[32]***blocks.0.0...
0
hf_public_repos/pytorch-image-models/timm/models
hf_public_repos/pytorch-image-models/timm/models/_pruned/ecaresnet101d_pruned.txt
conv1.0.weight:[32, 3, 3, 3]***conv1.1.weight:[32]***conv1.3.weight:[32, 32, 3, 3]***conv1.4.weight:[32]***conv1.6.weight:[64, 32, 3, 3]***bn1.weight:[64]***layer1.0.conv1.weight:[45, 64, 1, 1]***layer1.0.bn1.weight:[45]***layer1.0.conv2.weight:[25, 45, 3, 3]***layer1.0.bn2.weight:[25]***layer1.0.conv3.weight:[26, 25, ...
0
hf_public_repos/pytorch-image-models/timm/models
hf_public_repos/pytorch-image-models/timm/models/_pruned/efficientnet_b2_pruned.txt
conv_stem.weight:[32, 3, 3, 3]***bn1.weight:[32]***bn1.bias:[32]***bn1.running_mean:[32]***bn1.running_var:[32]***bn1.num_batches_tracked:[]***blocks.0.0.conv_dw.weight:[32, 1, 3, 3]***blocks.0.0.bn1.weight:[32]***blocks.0.0.bn1.bias:[32]***blocks.0.0.bn1.running_mean:[32]***blocks.0.0.bn1.running_var:[32]***blocks.0.0...
0
hf_public_repos/pytorch-image-models/timm/models
hf_public_repos/pytorch-image-models/timm/models/_pruned/ecaresnet50d_pruned.txt
conv1.0.weight:[32, 3, 3, 3]***conv1.1.weight:[32]***conv1.3.weight:[32, 32, 3, 3]***conv1.4.weight:[32]***conv1.6.weight:[64, 32, 3, 3]***bn1.weight:[64]***layer1.0.conv1.weight:[47, 64, 1, 1]***layer1.0.bn1.weight:[47]***layer1.0.conv2.weight:[18, 47, 3, 3]***layer1.0.bn2.weight:[18]***layer1.0.conv3.weight:[19, 18, ...
0
hf_public_repos/pytorch-image-models/timm/models
hf_public_repos/pytorch-image-models/timm/models/layers/__init__.py
# NOTE timm.models.layers is DEPRECATED, please use timm.layers, this is here to reduce breakages in transition from timm.layers.activations import * from timm.layers.adaptive_avgmax_pool import \ adaptive_avgmax_pool2d, select_adaptive_pool2d, AdaptiveAvgMaxPool2d, SelectAdaptivePool2d from timm.layers.attention_p...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/data/auto_augment.py
""" AutoAugment, RandAugment, AugMix, and 3-Augment for PyTorch This code implements the searched ImageNet policies with various tweaks and improvements and does not include any of the search code. AA and RA Implementation adapted from: https://github.com/tensorflow/tpu/blob/master/models/official/efficientnet/au...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/data/transforms.py
import math import numbers import random import warnings from typing import List, Sequence import torch import torchvision.transforms.functional as F try: from torchvision.transforms.functional import InterpolationMode has_interpolation_mode = True except ImportError: has_interpolation_mode = False from PI...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/data/real_labels.py
""" Real labels evaluator for ImageNet Paper: `Are we done with ImageNet?` - https://arxiv.org/abs/2006.07159 Based on Numpy example at https://github.com/google-research/reassessed-imagenet Hacked together by / Copyright 2020 Ross Wightman """ import os import json import numpy as np import pkgutil class RealLabels...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/data/config.py
import logging from .constants import * _logger = logging.getLogger(__name__) def resolve_data_config( args=None, pretrained_cfg=None, model=None, use_test_size=False, verbose=False ): assert model or args or pretrained_cfg, "At least one of model, args, or pretrained_cfg...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/data/dataset_info.py
from abc import ABC, abstractmethod from typing import Dict, List, Optional, Union class DatasetInfo(ABC): def __init__(self): pass @abstractmethod def num_classes(self): pass @abstractmethod def label_names(self): pass @abstractmethod def label_descriptions(sel...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/data/mixup.py
""" Mixup and Cutmix Papers: mixup: Beyond Empirical Risk Minimization (https://arxiv.org/abs/1710.09412) CutMix: Regularization Strategy to Train Strong Classifiers with Localizable Features (https://arxiv.org/abs/1905.04899) Code Reference: CutMix: https://github.com/clovaai/CutMix-PyTorch Hacked together by / Co...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/data/imagenet_info.py
import csv import os import pkgutil import re from typing import Dict, List, Optional, Union from .dataset_info import DatasetInfo # NOTE no ambiguity wrt to mapping from # classes to ImageNet subset so far, but likely to change _NUM_CLASSES_TO_SUBSET = { 1000: 'imagenet-1k', 11221: 'imagenet-21k-miil', # m...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/data/transforms_factory.py
""" Transforms Factory Factory methods for building image transforms for use with TIMM (PyTorch Image Models) Hacked together by / Copyright 2019, Ross Wightman """ import math import torch from torchvision import transforms from timm.data.constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD, DEFAULT_CROP_PC...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/data/constants.py
DEFAULT_CROP_PCT = 0.875 DEFAULT_CROP_MODE = 'center' IMAGENET_DEFAULT_MEAN = (0.485, 0.456, 0.406) IMAGENET_DEFAULT_STD = (0.229, 0.224, 0.225) IMAGENET_INCEPTION_MEAN = (0.5, 0.5, 0.5) IMAGENET_INCEPTION_STD = (0.5, 0.5, 0.5) IMAGENET_DPN_MEAN = (124 / 255, 117 / 255, 104 / 255) IMAGENET_DPN_STD = tuple([1 / (.0167 *...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/data/__init__.py
from .auto_augment import RandAugment, AutoAugment, rand_augment_ops, auto_augment_policy,\ rand_augment_transform, auto_augment_transform from .config import resolve_data_config, resolve_model_data_config from .constants import * from .dataset import ImageDataset, IterableImageDataset, AugMixDataset from .dataset_...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/data/tf_preprocessing.py
""" Tensorflow Preprocessing Adapter Allows use of Tensorflow preprocessing pipeline in PyTorch Transform Copyright of original Tensorflow code below. Hacked together by / Copyright 2020 Ross Wightman """ # Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2....
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/data/dataset_factory.py
""" Dataset Factory Hacked together by / Copyright 2021, Ross Wightman """ import os from torchvision.datasets import CIFAR100, CIFAR10, MNIST, KMNIST, FashionMNIST, ImageFolder try: from torchvision.datasets import Places365 has_places365 = True except ImportError: has_places365 = False try: from tor...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/data/dataset.py
""" Quick n Simple Image Folder, Tarfile based DataSet Hacked together by / Copyright 2019, Ross Wightman """ import io import logging from typing import Optional import torch import torch.utils.data as data from PIL import Image from .readers import create_reader _logger = logging.getLogger(__name__) _ERROR_RETR...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/data/loader.py
""" Loader Factory, Fast Collate, CUDA Prefetcher Prefetcher and Fast Collate inspired by NVIDIA APEX example at https://github.com/NVIDIA/apex/commit/d5e2bb4bdeedd27b1dfaf5bb2b24d6c000dee9be#diff-cf86c282ff7fba81fad27a559379d5bf Hacked together by / Copyright 2019, Ross Wightman """ import logging import random from...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/data/random_erasing.py
""" Random Erasing (Cutout) Originally inspired by impl at https://github.com/zhunzhong07/Random-Erasing, Apache 2.0 Copyright Zhun Zhong & Liang Zheng Hacked together by / Copyright 2019, Ross Wightman """ import random import math import torch def _get_pixels(per_pixel, rand_color, patch_size, dtype=torch.float3...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/data/distributed_sampler.py
import math import torch from torch.utils.data import Sampler import torch.distributed as dist class OrderedDistributedSampler(Sampler): """Sampler that restricts data loading to a subset of the dataset. It is especially useful in conjunction with :class:`torch.nn.parallel.DistributedDataParallel`. In suc...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/_info/imagenet22k_ms_to_22k_indices.txt
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 ...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/_info/imagenet22k_ms_synsets.txt
n01440764 n01443537 n01484850 n01491361 n01494475 n01496331 n01498041 n01514668 n01514859 n01518878 n01530575 n01531178 n01532829 n01534433 n01537544 n01558993 n01560419 n01580077 n01582220 n01592084 n01601694 n01608432 n01614925 n01616318 n01622779 n01629819 n01630670 n01631663 n01632458 n01632777 n01641577 n01644373 ...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/_info/imagenet21k_miil_synsets.txt
n00005787 n00006484 n00007846 n00015388 n00017222 n00021265 n00021939 n00120010 n00141669 n00288000 n00288384 n00324978 n00326094 n00433458 n00433661 n00433802 n00434075 n00439826 n00440039 n00440382 n00440509 n00440747 n00440941 n00441073 n00441824 n00442115 n00442437 n00442847 n00442981 n00443231 n00443692 n00443803 ...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/_info/imagenet21k_miil_w21_synsets.txt
n00005787 n00006484 n00007846 n00015388 n00017222 n00021265 n00021939 n00120010 n00141669 n00288000 n00288384 n00324978 n00326094 n00433458 n00433661 n00433802 n00434075 n00439826 n00440039 n00440382 n00440509 n00440747 n00440941 n00441073 n00441824 n00442115 n00442437 n00442847 n00442981 n00443231 n00443692 n00443803 ...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/_info/imagenet_synset_to_lemma.txt
n00004475 organism, being n00005787 benthos n00006024 heterotroph n00006484 cell n00007846 person, individual, someone, somebody, mortal, soul n00015388 animal, animate being, beast, brute, creature, fauna n00017222 plant, flora, plant life n00021265 food, nutrient n00021939 artifact, artefact n00120010 hop n00141669 c...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/_info/imagenet22k_ms_to_12k_indices.txt
1001 1003 1004 1005 1006 1007 1008 1009 1010 1011 1013 1014 1015 1016 1017 1018 1019 1020 1021 1023 1024 1026 1027 1028 1029 1030 1031 1032 1033 1034 1037 1038 1041 1043 1044 1045 1046 1047 1048 1049 1050 1051 1053 1055 1056 1057 1058 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 ...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/_info/imagenet_r_synsets.txt
n01443537 n01484850 n01494475 n01498041 n01514859 n01518878 n01531178 n01534433 n01614925 n01616318 n01630670 n01632777 n01644373 n01677366 n01694178 n01748264 n01770393 n01774750 n01784675 n01806143 n01820546 n01833805 n01843383 n01847000 n01855672 n01860187 n01882714 n01910747 n01944390 n01983481 n01986214 n02007558 ...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/_info/imagenet12k_synsets.txt
n00005787 n00006484 n00007846 n00015388 n00017222 n00021265 n00021939 n00120010 n00141669 n00288000 n00288384 n00324978 n00326094 n00433458 n00433661 n00433802 n00434075 n00439826 n00440039 n00440382 n00440509 n00440747 n00440941 n00441073 n00441824 n00442115 n00442437 n00442847 n00442981 n00443231 n00443692 n00443803 ...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/_info/imagenet21k_goog_synsets.txt
n00004475 n00005787 n00006024 n00006484 n00007846 n00015388 n00017222 n00021265 n00021939 n00120010 n00141669 n00288000 n00288190 n00288384 n00324978 n00326094 n00433458 n00433661 n00433802 n00434075 n00439826 n00440039 n00440218 n00440382 n00440509 n00440643 n00440747 n00440941 n00441073 n00441824 n00442115 n00442437 ...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/_info/imagenet22k_synsets.txt
n00004475 n00005787 n00006024 n00006484 n00007846 n00015388 n00017222 n00021265 n00021939 n00120010 n00141669 n00288000 n00288190 n00288384 n00324978 n00326094 n00433458 n00433661 n00433802 n00434075 n00439826 n00440039 n00440218 n00440382 n00440509 n00440643 n00440747 n00440941 n00441073 n00441824 n00442115 n00442437 ...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/_info/imagenet_synsets.txt
n01440764 n01443537 n01484850 n01491361 n01494475 n01496331 n01498041 n01514668 n01514859 n01518878 n01530575 n01531178 n01532829 n01534433 n01537544 n01558993 n01560419 n01580077 n01582220 n01592084 n01601694 n01608432 n01614925 n01616318 n01622779 n01629819 n01630670 n01631663 n01632458 n01632777 n01641577 n01644373 ...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/_info/imagenet_a_synsets.txt
n01498041 n01531178 n01534433 n01558993 n01580077 n01614925 n01616318 n01631663 n01641577 n01669191 n01677366 n01687978 n01694178 n01698640 n01735189 n01770081 n01770393 n01774750 n01784675 n01819313 n01820546 n01833805 n01843383 n01847000 n01855672 n01882714 n01910747 n01914609 n01924916 n01944390 n01985128 n01986214 ...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/_info/imagenet22k_to_12k_indices.txt
1 3 4 5 6 7 8 9 10 11 13 14 15 16 17 18 19 20 21 23 24 26 27 28 29 30 31 32 33 34 37 38 41 43 44 45 46 47 48 49 50 51 53 55 56 57 58 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 89 90 91 93 94 95 96 97 99 100 101 102 103 105 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/_info/imagenet_r_indices.txt
1 2 4 6 8 9 11 13 22 23 26 29 31 39 47 63 71 76 79 84 90 94 96 97 99 100 105 107 113 122 125 130 132 144 145 147 148 150 151 155 160 161 162 163 171 172 178 187 195 199 203 207 208 219 231 232 234 235 242 245 247 250 251 254 259 260 263 265 267 269 276 277 281 288 289 291 292 293 296 299 301 308 309 310 311 314 315 319...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/_info/imagenet_synset_to_definition.txt
n00004475 a living thing that has (or can develop) the ability to act or function independently n00005787 organisms (plants and animals) that live at or near the bottom of a sea n00006024 an organism that depends on complex organic substances for nutrition n00006484 (biology) the basic structural and functional unit of...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/_info/imagenet_a_indices.txt
6 11 13 15 17 22 23 27 30 37 39 42 47 50 57 70 71 76 79 89 90 94 96 97 99 105 107 108 110 113 124 125 130 132 143 144 150 151 207 234 235 254 277 283 287 291 295 298 301 306 307 308 309 310 311 313 314 315 317 319 323 324 326 327 330 334 335 336 347 361 363 372 378 386 397 400 401 402 404 407 411 416 417 420 425 428 43...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/_info/imagenet21k_goog_to_12k_indices.txt
1 3 4 5 6 7 8 9 10 11 13 14 15 16 17 18 19 20 21 23 24 26 27 28 29 30 31 32 33 34 37 38 41 43 44 45 46 47 48 49 50 51 53 55 56 57 58 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 89 90 91 93 94 95 96 97 99 100 101 102 103 105 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/_info/imagenet_real_labels.json
[[], [970, 795], [230, 231], [809], [516, 850], [57], [334], [700], [674], [332], [109], [286], [370], [757], [595], [147], [327, 108], [21, 22], [478], [517], [334], [], [948], [727], [23], [619, 526, 846], [270], [167], [64, 55], [858], [324], [573], [150], [981], [586], [887], [], [398], [], [74], [516], [756], [129...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/_info/imagenet21k_goog_to_22k_indices.txt
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 10...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/readers/reader_image_tar.py
""" A dataset reader that reads single tarfile based datasets This reader can read datasets consisting if a single tarfile containing images. I am planning to deprecated it in favour of ParerImageInTar. Hacked together by / Copyright 2020 Ross Wightman """ import os import tarfile from timm.utils.misc import natural...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/readers/img_extensions.py
from copy import deepcopy __all__ = ['get_img_extensions', 'is_img_extension', 'set_img_extensions', 'add_img_extensions', 'del_img_extensions'] IMG_EXTENSIONS = ('.png', '.jpg', '.jpeg') # singleton, kept public for bwd compat use _IMG_EXTENSIONS_SET = set(IMG_EXTENSIONS) # set version, private, kept in sync de...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/readers/__init__.py
from .reader_factory import create_reader from .img_extensions import *
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/readers/reader_wds.py
""" Dataset reader for webdataset Hacked together by / Copyright 2022 Ross Wightman """ import io import json import logging import math import os import random import sys from dataclasses import dataclass from functools import partial from itertools import islice from typing import Any, Callable, Dict, List, Optional...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/readers/reader_tfds.py
""" Dataset reader that wraps TFDS datasets Wraps many (most?) TFDS image-classification datasets from https://github.com/tensorflow/datasets https://www.tensorflow.org/datasets/catalog/overview#image_classification Hacked together by / Copyright 2020 Ross Wightman """ import math import os from typing import Optiona...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/readers/reader.py
from abc import abstractmethod class Reader: def __init__(self): pass @abstractmethod def _filename(self, index, basename=False, absolute=False): pass def filename(self, index, basename=False, absolute=False): return self._filename(index, basename=basename, absolute=absolute)...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/readers/reader_image_in_tar.py
""" A dataset reader that reads tarfile based datasets This reader can extract image samples from: * a single tar of image files * a folder of multiple tarfiles containing imagefiles * a tar of tars containing image files Labels are based on the combined folder and/or tar name structure. Hacked together by / Copyrig...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/readers/shared_count.py
from multiprocessing import Value class SharedCount: def __init__(self, epoch: int = 0): self.shared_epoch = Value('i', epoch) @property def value(self): return self.shared_epoch.value @value.setter def value(self, epoch): self.shared_epoch.value = epoch
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/readers/reader_factory.py
import os from .reader_image_folder import ReaderImageFolder from .reader_image_in_tar import ReaderImageInTar def create_reader(name, root, split='train', **kwargs): name = name.lower() name = name.split('/', 1) prefix = '' if len(name) > 1: prefix = name[0] name = name[-1] # FIXME ...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/readers/class_map.py
import os import pickle def load_class_map(map_or_filename, root=''): if isinstance(map_or_filename, dict): assert dict, 'class_map dict must be non-empty' return map_or_filename class_map_path = map_or_filename if not os.path.exists(class_map_path): class_map_path = os.path.join(r...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/readers/reader_hfds.py
""" Dataset reader that wraps Hugging Face datasets Hacked together by / Copyright 2022 Ross Wightman """ import io import math import torch import torch.distributed as dist from PIL import Image try: import datasets except ImportError as e: print("Please install Hugging Face datasets package `pip install dat...
0
hf_public_repos/pytorch-image-models/timm/data
hf_public_repos/pytorch-image-models/timm/data/readers/reader_image_folder.py
""" A dataset reader that extracts images from folders Folders are scanned recursively to find image files. Labels are based on the folder hierarchy, just leaf folders by default. Hacked together by / Copyright 2020 Ross Wightman """ import os from typing import Dict, List, Optional, Set, Tuple, Union from timm.util...
0
hf_public_repos/pytorch-image-models
hf_public_repos/pytorch-image-models/hfdocs/README.md
# Hugging Face Timm Docs ## Getting Started ``` pip install git+https://github.com/huggingface/doc-builder.git@main#egg=hf-doc-builder pip install watchdog black ``` ## Preview the Docs Locally ``` doc-builder preview timm hfdocs/source ```
0