From 4f6e4af7959cd3cc80a42fc4ebe23d15a825f65b Mon Sep 17 00:00:00 2001 From: Ross Wightman Date: Wed, 5 Aug 2020 16:09:09 -0800 Subject: [PATCH] Deployed 80c3051 with MkDocs version: 1.1.2 --- 404.html | 72 +- archived_changes/index.html | 726 ++++++++++ changes/index.html | 209 +-- feature_extraction/index.html | 785 +++++++++++ index.html | 157 ++- javascripts/tables.js | 6 + models/index.html | 2019 ++++++--------------------- results/index.html | 1797 ++++++++++++++++++++++++ scripts/index.html | 482 +++++++ search/search_index.json | 2 +- sitemap.xml | 26 +- sitemap.xml.gz | Bin 194 -> 197 bytes training_hparam_examples/index.html | 591 ++++++++ 13 files changed, 5197 insertions(+), 1675 deletions(-) create mode 100644 archived_changes/index.html create mode 100644 feature_extraction/index.html create mode 100644 javascripts/tables.js create mode 100644 results/index.html create mode 100644 scripts/index.html create mode 100644 training_hparam_examples/index.html diff --git a/404.html b/404.html index b08f0f7f..d07c61f4 100644 --- a/404.html +++ b/404.html @@ -186,8 +186,8 @@
  • - - Models + + Model Architectures
  • @@ -198,8 +198,68 @@
  • - - Changes + + Results + +
  • + + + + + + + +
  • + + Scripts + +
  • + + + + + + + +
  • + + Training Examples + +
  • + + + + + + + +
  • + + Feature Extraction + +
  • + + + + + + + +
  • + + Recent Changes + +
  • + + + + + + + +
  • + + Archived Changes
  • @@ -261,6 +321,10 @@ + + + + \ No newline at end of file diff --git a/archived_changes/index.html b/archived_changes/index.html new file mode 100644 index 00000000..53cb788e --- /dev/null +++ b/archived_changes/index.html @@ -0,0 +1,726 @@ + + + + + + + + + + + + + + + + + + + + Archived Changes - Pytorch Image Models + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + Skip to content + + +
    +
    + +
    + +
    + +
    + +
    + + + + + + +
    +
    + + +
    +
    +
    + +
    +
    +
    + + +
    +
    +
    + + +
    +
    +
    + + +
    +
    + + + + + + + + + + +

    Archived Changes

    +

    Feb 29, 2020

    +
      +
    • New MobileNet-V3 Large weights trained from stratch with this code to 75.77% top-1
    • +
    • IMPORTANT CHANGE - default weight init changed for all MobilenetV3 / EfficientNet / related models
    • +
    • overall results similar to a bit better training from scratch on a few smaller models tried
    • +
    • performance early in training seems consistently improved but less difference by end
    • +
    • set fix_group_fanout=False in _init_weight_goog fn if you need to reproducte past behaviour
    • +
    • Experimental LR noise feature added applies a random perturbation to LR each epoch in specified range of training
    • +
    +

    Feb 18, 2020

    +
      +
    • Big refactor of model layers and addition of several attention mechanisms. Several additions motivated by 'Compounding the Performance Improvements...' (https://arxiv.org/abs/2001.06268):
    • +
    • Move layer/module impl into layers subfolder/module of models and organize in a more granular fashion
    • +
    • ResNet downsample paths now properly support dilation (output stride != 32) for avg_pool ('D' variant) and 3x3 (SENets) networks
    • +
    • Add Selective Kernel Nets on top of ResNet base, pretrained weights
        +
      • skresnet18 - 73% top-1
      • +
      • skresnet34 - 76.9% top-1
      • +
      • skresnext50_32x4d (equiv to SKNet50) - 80.2% top-1
      • +
      +
    • +
    • ECA and CECA (circular padding) attention layer contributed by Chris Ha
    • +
    • CBAM attention experiment (not the best results so far, may remove)
    • +
    • Attention factory to allow dynamically selecting one of SE, ECA, CBAM in the .se position for all ResNets
    • +
    • Add DropBlock and DropPath (formerly DropConnect for EfficientNet/MobileNetv3) support to all ResNet variants
    • +
    • Full dataset results updated that incl NoisyStudent weights and 2 of the 3 SK weights
    • +
    +

    Feb 12, 2020

    +
      +
    • Add EfficientNet-L2 and B0-B7 NoisyStudent weights ported from Tensorflow TPU
    • +
    +

    Feb 6, 2020

    +
      +
    • Add RandAugment trained EfficientNet-ES (EdgeTPU-Small) weights with 78.1 top-1. Trained by Andrew Lavin (see Training section for hparams)
    • +
    +

    Feb ½, 2020

    +
      +
    • Port new EfficientNet-B8 (RandAugment) weights, these are different than the B8 AdvProp, different input normalization.
    • +
    • Update results csv files on all models for ImageNet validation and three other test sets
    • +
    • Push PyPi package update
    • +
    +

    Jan 31, 2020

    +
      +
    • Update ResNet50 weights with a new 79.038 result from further JSD / AugMix experiments. Full command line for reproduction in training section below.
    • +
    +

    Jan 11/12, 2020

    +
      +
    • Master may be a bit unstable wrt to training, these changes have been tested but not all combos
    • +
    • Implementations of AugMix added to existing RA and AA. Including numerous supporting pieces like JSD loss (Jensen-Shannon divergence + CE), and AugMixDataset
    • +
    • SplitBatchNorm adaptation layer added for implementing Auxiliary BN as per AdvProp paper
    • +
    • ResNet-50 AugMix trained model w/ 79% top-1 added
    • +
    • seresnext26tn_32x4d - 77.99 top-1, 93.75 top-5 added to tiered experiment, higher img/s than 't' and 'd'
    • +
    +

    Jan 3, 2020

    +
      +
    • Add RandAugment trained EfficientNet-B0 weight with 77.7 top-1. Trained by Michael Klachko with this code and recent hparams (see Training section)
    • +
    • Add avg_checkpoints.py script for post training weight averaging and update all scripts with header docstrings and shebangs.
    • +
    +

    Dec 30, 2019

    + +

    Dec 28, 2019

    +
      +
    • Add new model weights and training hparams (see Training Hparams section)
    • +
    • efficientnet_b3 - 81.5 top-1, 95.7 top-5 at default res/crop, 81.9, 95.8 at 320x320 1.0 crop-pct
        +
      • trained with RandAugment, ended up with an interesting but less than perfect result (see training section)
      • +
      +
    • +
    • seresnext26d_32x4d- 77.6 top-1, 93.6 top-5
        +
      • deep stem (32, 32, 64), avgpool downsample
      • +
      • stem/dowsample from bag-of-tricks paper
      • +
      +
    • +
    • seresnext26t_32x4d- 78.0 top-1, 93.7 top-5
        +
      • deep tiered stem (24, 48, 64), avgpool downsample (a modified 'D' variant)
      • +
      • stem sizing mods from Jeremy Howard and fastai devs discussing ResNet architecture experiments
      • +
      +
    • +
    +

    Dec 23, 2019

    +
      +
    • Add RandAugment trained MixNet-XL weights with 80.48 top-1.
    • +
    • --dist-bn argument added to train.py, will distribute BN stats between nodes after each train epoch, before eval
    • +
    +

    Dec 4, 2019

    +
      +
    • Added weights from the first training from scratch of an EfficientNet (B2) with my new RandAugment implementation. Much better than my previous B2 and very close to the official AdvProp ones (80.4 top-1, 95.08 top-5).
    • +
    +

    Nov 29, 2019

    +
      +
    • Brought EfficientNet and MobileNetV3 up to date with my https://github.com/rwightman/gen-efficientnet-pytorch code. Torchscript and ONNX export compat excluded.
    • +
    • AdvProp weights added
    • +
    • Official TF MobileNetv3 weights added
    • +
    • EfficientNet and MobileNetV3 hook based 'feature extraction' classes added. Will serve as basis for using models as backbones in obj detection/segmentation tasks. Lots more to be done here...
    • +
    • HRNet classification models and weights added from https://github.com/HRNet/HRNet-Image-Classification
    • +
    • Consistency in global pooling, reset_classifer, and forward_features across models
    • +
    • forward_features always returns unpooled feature maps now
    • +
    • Reasonable chance I broke something... let me know
    • +
    +

    Nov 22, 2019

    +
      +
    • Add ImageNet training RandAugment implementation alongside AutoAugment. PyTorch Transform compatible format, using PIL. Currently training two EfficientNet models from scratch with promising results... will update.
    • +
    • drop-connect cmd line arg finally added to train.py, no need to hack model fns. Works for efficientnet/mobilenetv3 based models, ignored otherwise.
    • +
    + + + + + + + +
    +
    +
    +
    + + + + +
    + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/changes/index.html b/changes/index.html index cb1117da..78c6ddce 100644 --- a/changes/index.html +++ b/changes/index.html @@ -17,7 +17,7 @@ - Changes - Pytorch Image Models + Recent Changes - Pytorch Image Models @@ -51,7 +51,7 @@
    - + Skip to content @@ -79,7 +79,7 @@ - Changes + Recent Changes
    @@ -191,8 +191,56 @@
  • - - Models + + Model Architectures + +
  • + + + + + + + +
  • + + Results + +
  • + + + + + + + +
  • + + Scripts + +
  • + + + + + + + +
  • + + Training Examples + +
  • + + + + + + + +
  • + + Feature Extraction
  • @@ -208,22 +256,26 @@ + + - - Changes + + Recent Changes @@ -317,6 +367,8 @@ @@ -551,6 +586,10 @@ + + + + \ No newline at end of file diff --git a/feature_extraction/index.html b/feature_extraction/index.html new file mode 100644 index 00000000..68c89673 --- /dev/null +++ b/feature_extraction/index.html @@ -0,0 +1,785 @@ + + + + + + + + + + + + + + + + + + + + Feature Extraction - Pytorch Image Models + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + Skip to content + + +
    +
    + +
    + +
    + +
    + +
    + + + + + + +
    +
    + + +
    +
    +
    + +
    +
    +
    + + + + + +
    +
    + + + + + + + + + + +

    Feature Extraction

    +

    All of the models in timm have consistent mechanisms for obtaining various types of features from the model for tasks besides classification.

    +

    Penultimate Layer Features (Pre-Classifier Features)

    +

    The features from the penultimate model layer can be obtained in severay ways without requiring model surgery (although feel free to do surgery). One must first decide if they want pooled or un-pooled features.

    +

    Unpooled

    +

    There are three ways to obtain unpooled features.

    +

    Without modifying the network, one can call model.forward_features(input) on any model instead of the usual model(input). This will bypass the head classifier and global pooling for networks.

    +

    If one wants to explicitly modify the network to return unpooled features, they can either create the model without a classifier and pooling, or remove it later. Both paths remove the parameters associated with the classifier from the network.

    +

    forward_features()

    +

    import torch
    +import timm
    +m = timm.create_model('xception41', pretrained=True)
    +o = m(torch.randn(2, 3, 299, 299))
    +print(f'Original shape: {o.shape}')
    +o = m.forward_features(torch.randn(2, 3, 299, 299))
    +print(f'Unpooled shape: {o.shape}')
    +
    +Output: +
    Original shape: torch.Size([2, 1000])
    +Unpooled shape: torch.Size([2, 2048, 10, 10])
    +

    +

    Create with no classifier and pooling

    +

    import torch
    +import timm
    +m = timm.create_model('resnet50', pretrained=True, num_classes=0, global_pool='')
    +o = m(torch.randn(2, 3, 224, 224))
    +print(f'Unpooled shape: {o.shape}')
    +
    +Output: +
    Unpooled shape: torch.Size([2, 2048, 7, 7])
    +

    +

    Remove it later

    +

    import torch
    +import timm
    +m = timm.create_model('densenet121', pretrained=True)
    +o = m(torch.randn(2, 3, 224, 224))
    +print(f'Original shape: {o.shape}')
    +m.reset_classifier(0, '')
    +o = m(torch.randn(2, 3, 224, 224))
    +print(f'Unpooled shape: {o.shape}')
    +
    +Output: +
    Original shape: torch.Size([2, 1000])
    +Unpooled shape: torch.Size([2, 1024, 7, 7])
    +

    +

    Pooled

    +

    To modify the network to return pooled features, one can use forward_features() and pool/flatten the result themselves, or modify the network like above but keep pooling intact.

    +

    Create with no classifier

    +

    import torch
    +import timm
    +m = timm.create_model('resnet50', pretrained=True, num_classes=0)
    +o = m(torch.randn(2, 3, 224, 224))
    +print(f'Pooled shape: {o.shape}')
    +
    +Output: +
    Pooled shape: torch.Size([2, 2048])
    +

    +

    Remove it later

    +

    import torch
    +import timm
    +m = timm.create_model('ese_vovnet19b_dw', pretrained=True)
    +o = m(torch.randn(2, 3, 224, 224))
    +print(f'Original shape: {o.shape}')
    +m.reset_classifier(0)
    +o = m(torch.randn(2, 3, 224, 224))
    +print(f'Pooled shape: {o.shape}')
    +
    +Output: +
    Pooled shape: torch.Size([2, 1024])
    +

    +

    Multi-scale Feature Maps (Feature Pyramid)

    +

    Object detection, segmentation, keypoint, and a variety of dense pixel tasks require access to feature maps from the backbone network at multiple scales. This is often done by modifying the original classification network. Since each network varies quite a bit in structure, it's not uncommon to see only a few backbones supported in any given obj detection or segmentation library.

    +

    timm allows a consistent interface for creating any of the included models as feature backbones that output feature maps for selected levels.

    +

    A feature backbone can be created by adding the argument features_only=True to any create_model call. By default 5 strides will be output from most models (not all have that many), with the first starting at 2 (some start at 1 or 4).

    +

    Create a feature map extraction model

    +

    import torch
    +import timm
    +m = timm.create_model('resnest26d', features_only=True, pretrained=True)
    +o = m(torch.randn(2, 3, 224, 224))
    +for x in o:
    +  print(x.shape)
    +
    +Output: +
    torch.Size([2, 64, 112, 112])
    +torch.Size([2, 256, 56, 56])
    +torch.Size([2, 512, 28, 28])
    +torch.Size([2, 1024, 14, 14])
    +torch.Size([2, 2048, 7, 7])
    +

    +

    Query the feature information

    +

    After a feature backbone has been created, it can be queried to provide channel or resolution reduction information to the downstream heads without requiring static config or hardcoded constants. The .feature_info attribute is a class encapsulating the information about the feature extraction points.

    +

    import torch
    +import timm
    +m = timm.create_model('regnety_032', features_only=True, pretrained=True)
    +print(f'Feature channels: {m.feature_info.channels()}')
    +o = m(torch.randn(2, 3, 224, 224))
    +for x in o:
    +  print(x.shape)
    +
    +Output: +
    Feature channels: [32, 72, 216, 576, 1512]
    +torch.Size([2, 32, 112, 112])
    +torch.Size([2, 72, 56, 56])
    +torch.Size([2, 216, 28, 28])
    +torch.Size([2, 576, 14, 14])
    +torch.Size([2, 1512, 7, 7])
    +

    +

    Select specific feature levels or limit the stride

    +

    There are to additional creation arguments impacting the output features.

    +
      +
    • out_indices selects which indices to output
    • +
    • output_stride limits the feature output stride of the network (also works in classification mode BTW)
    • +
    +

    out_indices is supported by all models, but not all models have the same index to feature stride mapping. Look at the code or check feature_info to compare. The out indices generally correspond to the C(i+1)th feature level (a 2^(i+1) reduction). For most models, index 0 is the stride 2 features, and index 4 is stride 32.

    +

    output_stride is achieved by converting layers to use dilated convolutions. Doing so is not always straightforward, some networks only support output_stride=32.

    +

    import torch
    +import timm
    +m = timm.create_model('ecaresnet101d', features_only=True, output_stride=8, out_indices=(2, 4), pretrained=True)
    +print(f'Feature channels: {m.feature_info.channels()}')
    +print(f'Feature reduction: {m.feature_info.reduction()}')
    +o = m(torch.randn(2, 3, 320, 320))
    +for x in o:
    +  print(x.shape)
    +
    +Output: +
    Feature channels: [512, 2048]
    +Feature reduction: [8, 8]
    +torch.Size([2, 512, 40, 40])
    +torch.Size([2, 2048, 40, 40])
    +

    + + + + + + + +
    +
    +
    +
    + + + + +
    + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/index.html b/index.html index 64a871a8..8fe534ea 100644 --- a/index.html +++ b/index.html @@ -221,8 +221,22 @@
  • - - Load Pretrained Model + + Load a Pretrained Model + + +
  • + +
  • + + List Models with Pretrained Weights + + +
  • + +
  • + + List Model Architectures by Wildcard
  • @@ -240,8 +254,20 @@
  • - - Models + + Model Architectures + +
  • + + + + + + + +
  • + + Results
  • @@ -252,8 +278,56 @@
  • - - Changes + + Scripts + +
  • + + + + + + + +
  • + + Training Examples + +
  • + + + + + + + +
  • + + Feature Extraction + +
  • + + + + + + + +
  • + + Recent Changes + +
  • + + + + + + + +
  • + + Archived Changes
  • @@ -291,8 +365,22 @@
  • - - Load Pretrained Model + + Load a Pretrained Model + + +
  • + +
  • + + List Models with Pretrained Weights + + +
  • + +
  • + + List Model Architectures by Wildcard
  • @@ -325,17 +413,17 @@

    Conda Environment

    -

    All development and testing has been done in Conda Python 3 environments - on Linux x86-64 systems, specifically Python 3.6.x and 3.7.x.

    -

    To install timm in a conda environment: +

    All development and testing has been done in Conda Python 3 environments on Linux x86-64 systems, specifically Python 3.6.x, 3.7.x., 3.8.x.

    +

    Little to no care has been taken to be Python 2.x friendly and will not support it. If you run into any challenges running on Windows, or other OS, I'm definitely open to looking into those issues so long as it's in a reproducible (read Conda) environment.

    +

    PyTorch versions 1.4, 1.5.x, and 1.6 have been tested with this code.

    +

    I've tried to keep the dependencies minimal, the setup is as per the PyTorch default install instructions for Conda:

    conda create -n torch-env
     conda activate torch-env
    -conda install -c pytorch pytorch torchvision cudatoolkit=10.1
    +conda install -c pytorch pytorch torchvision cudatoolkit=10.2
     conda install pyyaml
    -pip install timm
     

    -

    Load Pretrained Model

    +

    Load a Pretrained Model

    Pretrained models can be loaded using timm.create_model

    import timm
     
    @@ -343,8 +431,37 @@ pip install timm
     m.eval()
     
    -

    To load a different model see the list of pretrained weights.

    +

    List Models with Pretrained Weights

    +
    import timm
    +from pprint import pprint
    +model_names = timm.list_models(pretrained=True)
    +pprint(model_names)
    +>>> ['adv_inception_v3',
    + 'cspdarknet53',
    + 'cspresnext50',
    + 'densenet121',
    + 'densenet161',
    + 'densenet169',
    + 'densenet201',
    + 'densenetblur121d',
    + 'dla34',
    + 'dla46_c',
    +...
    +]
    +
    + +

    List Model Architectures by Wildcard

    +
    import timm
    +from pprint import pprint
    +model_names = timm.list_models('*resne*t*')
    +pprint(model_names)
    +>>> ['cspresnet50',
    + 'cspresnet50d',
    + 'cspresnet50w',
    + 'cspresnext50',
    +...
    +]
    +
    @@ -364,13 +481,13 @@ pip install timm