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/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 ...
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/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...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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...
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/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 Optional, Tuple import torch import torch.nn as nn from torch.jit impo...
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/_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/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 Tuple ...
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/_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/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...
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/_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/__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 .cspnet import * from .davit import * from .deit import * from .densenet import * from .dla import * from .dpn imp...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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 List import torch import torch.nn as...
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/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/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 # ...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/models/_efficientnet_blocks.py
""" EfficientNet, MobileNetV3, etc Blocks Hacked together by / Copyright 2019, Ross Wightman """ import torch import torch.nn as nn from torch.nn import functional as F from timm.layers import create_conv2d, DropPath, make_divisible, create_act_layer, get_norm_act_layer __all__ = [ 'SqueezeExcite', 'ConvBnAct',...
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/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...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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 ...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/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...
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/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/_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/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_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
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/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/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/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/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/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/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/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
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/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/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/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/__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/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/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/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_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_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/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/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/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_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/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/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/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_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/_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/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/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/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/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_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/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_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/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/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_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_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_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_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/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/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/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/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/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
hf_public_repos/pytorch-image-models/timm/scheduler/scheduler.py
import abc from abc import ABC from typing import Any, Dict, Optional import torch class Scheduler(ABC): """ Parameter Scheduler Base Class A scheduler base class that can be used to schedule any optimizer parameter groups. Unlike the builtin PyTorch schedulers, this is intended to be consistently calle...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/scheduler/scheduler_factory.py
""" Scheduler Factory Hacked together by / Copyright 2021 Ross Wightman """ from typing import List, Union from torch.optim import Optimizer from .cosine_lr import CosineLRScheduler from .multistep_lr import MultiStepLRScheduler from .plateau_lr import PlateauLRScheduler from .poly_lr import PolyLRScheduler from .ste...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/scheduler/cosine_lr.py
""" Cosine Scheduler Cosine LR schedule with warmup, cycle/restarts, noise, k-decay. Hacked together by / Copyright 2021 Ross Wightman """ import logging import math import numpy as np import torch from .scheduler import Scheduler _logger = logging.getLogger(__name__) class CosineLRScheduler(Scheduler): """ ...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/scheduler/step_lr.py
""" Step Scheduler Basic step LR schedule with warmup, noise. Hacked together by / Copyright 2020 Ross Wightman """ import math import torch from .scheduler import Scheduler class StepLRScheduler(Scheduler): """ """ def __init__( self, optimizer: torch.optim.Optimizer, ...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/scheduler/multistep_lr.py
""" MultiStep LR Scheduler Basic multi step LR schedule with warmup, noise. """ import torch import bisect from timm.scheduler.scheduler import Scheduler from typing import List class MultiStepLRScheduler(Scheduler): """ """ def __init__( self, optimizer: torch.optim.Optimizer, ...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/scheduler/plateau_lr.py
""" Plateau Scheduler Adapts PyTorch plateau scheduler and allows application of noise, warmup. Hacked together by / Copyright 2020 Ross Wightman """ import torch from .scheduler import Scheduler class PlateauLRScheduler(Scheduler): """Decay the LR by a factor every time the validation loss plateaus.""" d...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/scheduler/tanh_lr.py
""" TanH Scheduler TanH schedule with warmup, cycle/restarts, noise. Hacked together by / Copyright 2021 Ross Wightman """ import logging import math import numpy as np import torch from .scheduler import Scheduler _logger = logging.getLogger(__name__) class TanhLRScheduler(Scheduler): """ Hyberbolic-Tan...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/scheduler/poly_lr.py
""" Polynomial Scheduler Polynomial LR schedule with warmup, noise. Hacked together by / Copyright 2021 Ross Wightman """ import math import logging import torch from .scheduler import Scheduler _logger = logging.getLogger(__name__) class PolyLRScheduler(Scheduler): """ Polynomial LR Scheduler w/ warmup, no...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/scheduler/__init__.py
from .cosine_lr import CosineLRScheduler from .multistep_lr import MultiStepLRScheduler from .plateau_lr import PlateauLRScheduler from .poly_lr import PolyLRScheduler from .step_lr import StepLRScheduler from .tanh_lr import TanhLRScheduler from .scheduler_factory import create_scheduler, create_scheduler_v2, schedul...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/utils/model_ema.py
""" Exponential Moving Average (EMA) of model updates Hacked together by / Copyright 2020 Ross Wightman """ import logging from collections import OrderedDict from copy import deepcopy import torch import torch.nn as nn _logger = logging.getLogger(__name__) class ModelEma: """ Model Exponential Moving Average ...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/utils/onnx.py
from typing import Optional, Tuple, List import torch def onnx_forward(onnx_file, example_input): import onnxruntime sess_options = onnxruntime.SessionOptions() session = onnxruntime.InferenceSession(onnx_file, sess_options) input_name = session.get_inputs()[0].name output = session.run([], {inp...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/utils/misc.py
""" Misc utils Hacked together by / Copyright 2020 Ross Wightman """ import argparse import ast import re def natural_key(string_): """See http://www.codinghorror.com/blog/archives/001018.html""" return [int(s) if s.isdigit() else s for s in re.split(r'(\d+)', string_.lower())] def add_bool_arg(parser, nam...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/utils/agc.py
""" Adaptive Gradient Clipping An impl of AGC, as per (https://arxiv.org/abs/2102.06171): @article{brock2021high, author={Andrew Brock and Soham De and Samuel L. Smith and Karen Simonyan}, title={High-Performance Large-Scale Image Recognition Without Normalization}, journal={arXiv preprint arXiv:}, year={2021...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/utils/decay_batch.py
""" Batch size decay and retry helpers. Copyright 2022 Ross Wightman """ import math def decay_batch_step(batch_size, num_intra_steps=2, no_odd=False): """ power of two batch-size decay with intra steps Decay by stepping between powers of 2: * determine power-of-2 floor of current batch size (base batch...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/utils/model.py
""" Model / state_dict utils Hacked together by / Copyright 2020 Ross Wightman """ import fnmatch from copy import deepcopy import torch from torchvision.ops.misc import FrozenBatchNorm2d from timm.layers import BatchNormAct2d, SyncBatchNormAct, FrozenBatchNormAct2d,\ freeze_batch_norm_2d, unfreeze_batch_norm_2d...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/utils/summary.py
""" Summary utilities Hacked together by / Copyright 2020 Ross Wightman """ import csv import os from collections import OrderedDict try: import wandb except ImportError: pass def get_outdir(path, *paths, inc=False): outdir = os.path.join(path, *paths) if not os.path.exists(outdir): os.maked...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/utils/clip_grad.py
import torch from timm.utils.agc import adaptive_clip_grad def dispatch_clip_grad(parameters, value: float, mode: str = 'norm', norm_type: float = 2.0): """ Dispatch to gradient clipping method Args: parameters (Iterable): model parameters to clip value (float): clipping value/factor/norm, m...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/utils/log.py
""" Logging helpers Hacked together by / Copyright 2020 Ross Wightman """ import logging import logging.handlers class FormatterNoInfo(logging.Formatter): def __init__(self, fmt='%(levelname)s: %(message)s'): logging.Formatter.__init__(self, fmt) def format(self, record): if record.levelno =...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/utils/jit.py
""" JIT scripting/tracing utils Hacked together by / Copyright 2020 Ross Wightman """ import os import torch def set_jit_legacy(): """ Set JIT executor to legacy w/ support for op fusion This is hopefully a temporary need in 1.5/1.5.1/1.6 to restore performance due to changes in the JIT exectutor. These...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/utils/metrics.py
""" Eval metrics and related Hacked together by / Copyright 2020 Ross Wightman """ class AverageMeter: """Computes and stores the average and current value""" def __init__(self): self.reset() def reset(self): self.val = 0 self.avg = 0 self.sum = 0 self.count = 0 ...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/utils/distributed.py
""" Distributed training/validation utils Hacked together by / Copyright 2020 Ross Wightman """ import os import torch from torch import distributed as dist try: import horovod.torch as hvd except ImportError: hvd = None from .model import unwrap_model def reduce_tensor(tensor, n): rt = tensor.clone()...
0
hf_public_repos/pytorch-image-models/timm
hf_public_repos/pytorch-image-models/timm/utils/__init__.py
from .agc import adaptive_clip_grad from .checkpoint_saver import CheckpointSaver from .clip_grad import dispatch_clip_grad from .cuda import ApexScaler, NativeScaler from .decay_batch import decay_batch_step, check_batch_size_retry from .distributed import distribute_bn, reduce_tensor, init_distributed_device,\ wo...
0