Fix MobileNetV2 head conv size for multiplier < 1.0. Add some missing modification copyrights, fix starting date of some old ones.

pull/1083/head
Ross Wightman 3 years ago
parent ccfeb06936
commit 61ce0d7daf

@ -15,7 +15,7 @@ Papers:
RandAugment: Practical automated data augmentation... - https://arxiv.org/abs/1909.13719
AugMix: A Simple Data Processing Method to Improve Robustness and Uncertainty - https://arxiv.org/abs/1912.02781
Hacked together by / Copyright 2020 Ross Wightman
Hacked together by / Copyright 2019, Ross Wightman
"""
import random
import math

@ -1,6 +1,6 @@
""" Quick n Simple Image Folder, Tarfile based DataSet
Hacked together by / Copyright 2020 Ross Wightman
Hacked together by / Copyright 2019, Ross Wightman
"""
import torch.utils.data as data
import os

@ -1,3 +1,7 @@
""" Dataset Factory
Hacked together by / Copyright 2021, Ross Wightman
"""
import os
from torchvision.datasets import CIFAR100, CIFAR10, MNIST, QMNIST, KMNIST, FashionMNIST, ImageNet, ImageFolder

@ -3,7 +3,7 @@
Prefetcher and Fast Collate inspired by NVIDIA APEX example at
https://github.com/NVIDIA/apex/commit/d5e2bb4bdeedd27b1dfaf5bb2b24d6c000dee9be#diff-cf86c282ff7fba81fad27a559379d5bf
Hacked together by / Copyright 2021 Ross Wightman
Hacked together by / Copyright 2019, Ross Wightman
"""
import random
from functools import partial

@ -8,7 +8,7 @@ CutMix: Regularization Strategy to Train Strong Classifiers with Localizable Fea
Code Reference:
CutMix: https://github.com/clovaai/CutMix-PyTorch
Hacked together by / Copyright 2020 Ross Wightman
Hacked together by / Copyright 2019, Ross Wightman
"""
import numpy as np
import torch

@ -3,7 +3,7 @@
Originally inspired by impl at https://github.com/zhunzhong07/Random-Erasing, Apache 2.0
Copyright Zhun Zhong & Liang Zheng
Hacked together by / Copyright 2020 Ross Wightman
Hacked together by / Copyright 2019, Ross Wightman
"""
import random
import math

@ -1,7 +1,7 @@
""" Transforms Factory
Factory methods for building image transforms for use with TIMM (PyTorch Image Models)
Hacked together by / Copyright 2020 Ross Wightman
Hacked together by / Copyright 2019, Ross Wightman
"""
import math

@ -4,6 +4,7 @@ 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
"""
# Copyright (c) 2015-present, Facebook, Inc.
# All rights reserved.

@ -9,6 +9,8 @@
Paper link: https://arxiv.org/abs/2103.10697
Original code: https://github.com/facebookresearch/convit, original copyright below
Modifications and additions for timm hacked together by / Copyright 2021, Ross Wightman
"""
# Copyright (c) 2015-present, Facebook, Inc.
# All rights reserved.

@ -12,6 +12,8 @@ Paper link: https://arxiv.org/abs/2103.14899
Original code: https://github.com/IBM/CrossViT/blob/main/models/crossvit.py
NOTE: model names have been renamed from originals to represent actual input res all *_224 -> *_240 and *_384 -> *_408
Modifications and additions for timm hacked together by / Copyright 2021, Ross Wightman
"""
# Copyright IBM All Rights Reserved.

@ -409,7 +409,7 @@ class CspNet(nn.Module):
def _create_cspnet(variant, pretrained=False, **kwargs):
cfg_variant = variant.split('_')[0]
# NOTE: DarkNet is one of few models with stride==1 features w/ 6 out_indices [0..5]
out_indices = kwargs.get('out_indices', (0, 1, 2, 3, 4, 5) if 'darknet' in variant else (0, 1, 2, 3, 4))
out_indices = kwargs.pop('out_indices', (0, 1, 2, 3, 4, 5) if 'darknet' in variant else (0, 1, 2, 3, 4))
return build_model_with_cfg(
CspNet, variant, pretrained,
default_cfg=default_cfgs[variant],

@ -33,7 +33,7 @@ The majority of the above models (EfficientNet*, MixNet, MnasNet) and original w
by Mingxing Tan, Quoc Le, and other members of their Google Brain team. Thanks for consistently releasing
the models and weights open source!
Hacked together by / Copyright 2021 Ross Wightman
Hacked together by / Copyright 2019, Ross Wightman
"""
from functools import partial
from typing import List
@ -718,7 +718,7 @@ def _gen_mobilenet_v2(
round_chs_fn = partial(round_channels, multiplier=channel_multiplier)
model_kwargs = dict(
block_args=decode_arch_def(arch_def, depth_multiplier=depth_multiplier, fix_first_last=fix_stem_head),
num_features=1280 if fix_stem_head else round_chs_fn(1280),
num_features=1280 if fix_stem_head else max(1280, round_chs_fn(1280)),
stem_size=32,
fix_stem=fix_stem_head,
round_chs_fn=round_chs_fn,

@ -1,6 +1,6 @@
""" EfficientNet, MobileNetV3, etc Blocks
Hacked together by / Copyright 2020 Ross Wightman
Hacked together by / Copyright 2019, Ross Wightman
"""
import torch

@ -3,7 +3,7 @@
Assembles EfficieNet and related network feature blocks from string definitions.
Handles stride, dilation calculations, and selects feature extraction points.
Hacked together by / Copyright 2020 Ross Wightman
Hacked together by / Copyright 2019, Ross Wightman
"""
import logging

@ -21,7 +21,7 @@ from .helpers import to_ntuple, to_2tuple, to_3tuple, to_4tuple, make_divisible
from .inplace_abn import InplaceAbn
from .linear import Linear
from .mixed_conv2d import MixedConv2d
from .mlp import Mlp, GluMlp, GatedMlp
from .mlp import Mlp, GluMlp, GatedMlp, ConvMlp
from .non_local_attn import NonLocalAttn, BatNonLocalAttn
from .norm import GroupNorm, LayerNorm2d
from .norm_act import BatchNormAct2d, GroupNormAct

@ -14,7 +14,7 @@ Adapted from official impl at https://github.com/facebookresearch/LeViT, origina
This version combines both conv/linear models and fixes torchscript compatibility.
Modifications by/coyright Copyright 2021 Ross Wightman
Modifications and additions for timm hacked together by / Copyright 2021, Ross Wightman
"""
# Copyright (c) 2015-present, Facebook, Inc.

@ -1,11 +1,10 @@
""" 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 2021 Ross Wightman
Hacked together by / Copyright 2019, Ross Wightman
"""
from functools import partial
from typing import List

@ -4,7 +4,8 @@ This started as a copy of https://github.com/pytorch/vision 'resnet.py' (BSD-3-C
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 2020 Ross Wightman
Copyright 2019, Ross Wightman
"""
import math
from functools import partial

@ -4,6 +4,7 @@ A PyTorch impl of : `Swin Transformer: Hierarchical Vision Transformer using Shi
Code/weights from https://github.com/microsoft/Swin-Transformer, original copyright/license info below
Modifications and additions for timm hacked together by / Copyright 2021, Ross Wightman
"""
# --------------------------------------------------------
# Swin Transformer

@ -180,7 +180,7 @@ def _filter_fn(state_dict):
def _create_vgg(variant: str, pretrained: bool, **kwargs: Any) -> VGG:
cfg = variant.split('_')[0]
# NOTE: VGG is one of few models with stride==1 features w/ 6 out_indices [0..5]
out_indices = kwargs.get('out_indices', (0, 1, 2, 3, 4, 5))
out_indices = kwargs.pop('out_indices', (0, 1, 2, 3, 4, 5))
model = build_model_with_cfg(
VGG, variant, pretrained,
default_cfg=default_cfgs[variant],

@ -4,6 +4,7 @@ Paper: Visformer: The Vision-friendly Transformer - https://arxiv.org/abs/2104.1
From original at https://github.com/danczs/Visformer
Modifications and additions for timm hacked together by / Copyright 2021, Ross Wightman
"""
from copy import deepcopy

@ -20,7 +20,7 @@ for some einops/einsum fun
* Simple transformer style inspired by Andrej Karpathy's https://github.com/karpathy/minGPT
* Bert reference code checks against Huggingface Transformers and Tensorflow Bert
Hacked together by / Copyright 2021 Ross Wightman
Hacked together by / Copyright 2020, Ross Wightman
"""
import math
import logging

@ -11,7 +11,7 @@ A PyTorch implement of the Hybrid Vision Transformers as described in:
NOTE These hybrid model definitions depend on code in vision_transformer.py.
They were moved here to keep file sizes sane.
Hacked together by / Copyright 2021 Ross Wightman
Hacked together by / Copyright 2020, Ross Wightman
"""
from copy import deepcopy
from functools import partial

@ -1,10 +1,12 @@
""" Cross-Covariance Image Transformer (XCiT) in PyTorch
Same as the official implementation, with some minor adaptations.
- https://github.com/facebookresearch/xcit/blob/master/xcit.py
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 / Copyright 2021, Ross Wightman
"""
# Copyright (c) 2015-present, Facebook, Inc.
# All rights reserved.

Loading…
Cancel
Save