From 656757d26b78cbf35f526b454e4333b3cfda7012 Mon Sep 17 00:00:00 2001 From: Ross Wightman Date: Wed, 12 Jan 2022 16:18:18 -0800 Subject: [PATCH] Fix MobileNetV2 head conv size for multiplier < 1.0. Add some missing modification copyrights, fix starting date of some old ones. --- timm/data/auto_augment.py | 2 +- timm/data/dataset.py | 2 +- timm/data/dataset_factory.py | 4 ++++ timm/data/loader.py | 2 +- timm/data/mixup.py | 2 +- timm/data/random_erasing.py | 2 +- timm/data/transforms_factory.py | 2 +- timm/models/cait.py | 1 + timm/models/convit.py | 2 ++ timm/models/crossvit.py | 2 ++ timm/models/cspnet.py | 2 +- timm/models/efficientnet.py | 4 ++-- timm/models/efficientnet_blocks.py | 2 +- timm/models/efficientnet_builder.py | 2 +- timm/models/layers/__init__.py | 2 +- timm/models/levit.py | 2 +- timm/models/mobilenetv3.py | 3 +-- timm/models/resnet.py | 3 ++- timm/models/swin_transformer.py | 1 + timm/models/vgg.py | 2 +- timm/models/visformer.py | 1 + timm/models/vision_transformer.py | 2 +- timm/models/vision_transformer_hybrid.py | 2 +- timm/models/xcit.py | 8 +++++--- 24 files changed, 35 insertions(+), 22 deletions(-) diff --git a/timm/data/auto_augment.py b/timm/data/auto_augment.py index 8907e504..121a3fc6 100644 --- a/timm/data/auto_augment.py +++ b/timm/data/auto_augment.py @@ -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 diff --git a/timm/data/dataset.py b/timm/data/dataset.py index d3603a23..20b663ce 100644 --- a/timm/data/dataset.py +++ b/timm/data/dataset.py @@ -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 diff --git a/timm/data/dataset_factory.py b/timm/data/dataset_factory.py index e86bcc29..194a597e 100644 --- a/timm/data/dataset_factory.py +++ b/timm/data/dataset_factory.py @@ -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 diff --git a/timm/data/loader.py b/timm/data/loader.py index a02399a3..67d8cd83 100644 --- a/timm/data/loader.py +++ b/timm/data/loader.py @@ -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 diff --git a/timm/data/mixup.py b/timm/data/mixup.py index 7e382c52..c8789a0c 100644 --- a/timm/data/mixup.py +++ b/timm/data/mixup.py @@ -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 diff --git a/timm/data/random_erasing.py b/timm/data/random_erasing.py index 2fa63153..98108488 100644 --- a/timm/data/random_erasing.py +++ b/timm/data/random_erasing.py @@ -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 diff --git a/timm/data/transforms_factory.py b/timm/data/transforms_factory.py index d4815d95..a5facbf5 100644 --- a/timm/data/transforms_factory.py +++ b/timm/data/transforms_factory.py @@ -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 diff --git a/timm/models/cait.py b/timm/models/cait.py index 69b4ba06..978db1ab 100644 --- a/timm/models/cait.py +++ b/timm/models/cait.py @@ -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. diff --git a/timm/models/convit.py b/timm/models/convit.py index 6ef1da72..1a4c1810 100644 --- a/timm/models/convit.py +++ b/timm/models/convit.py @@ -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. diff --git a/timm/models/crossvit.py b/timm/models/crossvit.py index ddc4f64c..acf9a47d 100644 --- a/timm/models/crossvit.py +++ b/timm/models/crossvit.py @@ -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. diff --git a/timm/models/cspnet.py b/timm/models/cspnet.py index 8465e97d..4feb341c 100644 --- a/timm/models/cspnet.py +++ b/timm/models/cspnet.py @@ -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], diff --git a/timm/models/efficientnet.py b/timm/models/efficientnet.py index 30d6fd6a..87e033e0 100644 --- a/timm/models/efficientnet.py +++ b/timm/models/efficientnet.py @@ -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, diff --git a/timm/models/efficientnet_blocks.py b/timm/models/efficientnet_blocks.py index b1fec449..aef66295 100644 --- a/timm/models/efficientnet_blocks.py +++ b/timm/models/efficientnet_blocks.py @@ -1,6 +1,6 @@ """ EfficientNet, MobileNetV3, etc Blocks -Hacked together by / Copyright 2020 Ross Wightman +Hacked together by / Copyright 2019, Ross Wightman """ import torch diff --git a/timm/models/efficientnet_builder.py b/timm/models/efficientnet_builder.py index 7a05c890..8192f4e5 100644 --- a/timm/models/efficientnet_builder.py +++ b/timm/models/efficientnet_builder.py @@ -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 diff --git a/timm/models/layers/__init__.py b/timm/models/layers/__init__.py index 4831af9a..706d9dc8 100644 --- a/timm/models/layers/__init__.py +++ b/timm/models/layers/__init__.py @@ -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 diff --git a/timm/models/levit.py b/timm/models/levit.py index 9987e4ba..4f400fd1 100644 --- a/timm/models/levit.py +++ b/timm/models/levit.py @@ -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. diff --git a/timm/models/mobilenetv3.py b/timm/models/mobilenetv3.py index 4b9bcc09..6f991988 100644 --- a/timm/models/mobilenetv3.py +++ b/timm/models/mobilenetv3.py @@ -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 diff --git a/timm/models/resnet.py b/timm/models/resnet.py index bbcae9a3..8989f300 100644 --- a/timm/models/resnet.py +++ b/timm/models/resnet.py @@ -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 diff --git a/timm/models/swin_transformer.py b/timm/models/swin_transformer.py index 92057902..584d5649 100644 --- a/timm/models/swin_transformer.py +++ b/timm/models/swin_transformer.py @@ -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 diff --git a/timm/models/vgg.py b/timm/models/vgg.py index b2fe07c8..ccaa21da 100644 --- a/timm/models/vgg.py +++ b/timm/models/vgg.py @@ -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], diff --git a/timm/models/visformer.py b/timm/models/visformer.py index 3a9be06f..62f77304 100644 --- a/timm/models/visformer.py +++ b/timm/models/visformer.py @@ -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 diff --git a/timm/models/vision_transformer.py b/timm/models/vision_transformer.py index 6e568abf..fec44334 100644 --- a/timm/models/vision_transformer.py +++ b/timm/models/vision_transformer.py @@ -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 diff --git a/timm/models/vision_transformer_hybrid.py b/timm/models/vision_transformer_hybrid.py index d5f0a537..d46297ef 100644 --- a/timm/models/vision_transformer_hybrid.py +++ b/timm/models/vision_transformer_hybrid.py @@ -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 diff --git a/timm/models/xcit.py b/timm/models/xcit.py index ac5e802c..9ad162ed 100644 --- a/timm/models/xcit.py +++ b/timm/models/xcit.py @@ -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.