opensi·si

timm/models/swintransformerv2cr.py

Swin Transformer V2 (CR)

Category: ViT · Code: timm/models/swin_transformer_v2_cr.py · Architectures: 16 · Pretrained weights: 3 (3 with ImageNet-1k results)

An alternative Swin Transformer V2 implementation adapted from Christoph Reich's code, designed for changing the image size together with the window size, including non-square sizes. The module docstring marks it as experimental.

Papers

  • Swin Transformer V2: Scaling Up Capacity and Resolution

Usage

See the Quickstart for loading pretrained weights, image preprocessing and fine-tuning, and Feature Extraction for using the models as backbones.

>>> import timm
>>> model = timm.create_model('swinv2_cr_tiny_ns_224.sw_in1k', pretrained=True)
>>> data_config = timm.data.resolve_model_data_config(model)

Model API support

Feature SwinTransformerV2Cr
features_only=True feature maps ✓ (strides 4, 8, 16, 32)
forward_intermediates() ✓
prune_intermediate_layers() ✓
Any input size, no changes needed ✗
set_input_size() ✓
dynamic_img_size=True ✓
set_grad_checkpointing() ✓
Layer-wise LR decay (group_matcher()) ✓
reset_classifier() ✓

✓ supported, ✓ (square) works for square sizes only, ✗ not supported, – not needed (the model already accepts any input size). Checked by running each feature on a randomly initialized model (SwinTransformerV2Cr with swinv2_cr_tiny_224 at 224), other architectures of the same class are expected to behave the same. See the Model API page for details.

Architectures

Tabla (17 filas)
Architecture Params (M) GMACs Input size Pretrained weights
swinv2_cr_base_224 87.88 15.86 224 0
swinv2_cr_base_384 87.88 50.57 384 0
swinv2_cr_base_ns_224 87.88 15.86 224 0
swinv2_cr_giant_224 2598.76 483.85 224 0
swinv2_cr_giant_384 2598.76 1450.71 384 0
swinv2_cr_huge_224 657.83 115.97 224 0
swinv2_cr_huge_384 657.94 352.04 384 0
swinv2_cr_large_224 196.68 35.10 224 0
swinv2_cr_large_384 196.68 108.96 384 0
swinv2_cr_small_224 49.70 9.07 224 1
swinv2_cr_small_384 49.70 29.70 384 0
swinv2_cr_small_ns_224 49.70 9.08 224 1
swinv2_cr_small_ns_256 49.70 12.07 256 0
swinv2_cr_tiny_224 28.33 4.66 224 0
swinv2_cr_tiny_384 28.33 15.34 384 0
swinv2_cr_tiny_ns_224 28.33 4.66 224 1

GMACs and parameter counts are for the default input size and classifier of each architecture, from the benchmark results.

Pretrained weights

Top-1 is ImageNet-1k validation accuracy from results-imagenet.csv at the listed eval size, - if the weight has no ImageNet-1k result (e.g. pretraining or image-text weights). Classes is the size of the pretrained classifier, none for weights without one.

Weight Input size Top-1 (%) Eval size Classes License Hub
swinv2_cr_small_224.sw_in1k 224 83.126 224 1000 apache-2.0 timm
swinv2_cr_small_ns_224.sw_in1k 224 83.490 224 1000 apache-2.0 timm
swinv2_cr_tiny_ns_224.sw_in1k 224 81.796 224 1000 apache-2.0 timm

Source and license

Source: timm documentation, adapted for this site. Licensing and attribution follow the terms of the upstream project.