opensi·si

timm/models/naflexvit.py ·

NaFlex ViT

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

A Vision Transformer with the patch embedding and position encoding in one module, supporting pre-patchified inputs with variable aspect ratio and resolution (NaFlex), FlexiViT variable patch size and NaViT factorized position embeddings.

Papers

  • An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
  • FlexiViT: One Model for All Patch Sizes
  • Patch n' Pack: NaViT, a Vision Transformer for any Aspect Ratio and Resolution
  • SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features

Referenced by pretrained weights:

  • arXiv:2412.07679
  • arXiv:2601.17237

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('naflexvit_base_patch16_parfac_gap.e300_s576_in1k', pretrained=True)
>>> data_config = timm.data.resolve_model_data_config(model)

Model API support

Feature NaFlexVit
features_only=True feature maps ✓ (strides 16, 16, 16)
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 (NaFlexVit with naflexvit_base_patch16_parfac_gap at 384), other architectures of the same class are expected to behave the same. See the Model API page for details.

Architectures

표 (15행)
Architecture Params (M) GMACs Input size Pretrained weights
naflexvit_base_patch16_gap 86.63 55.86 384 1
naflexvit_base_patch16_map 93.72 56.23 384 0
naflexvit_base_patch16_par_gap 86.63 55.86 384 1
naflexvit_base_patch16_parfac_gap 86.46 55.86 384 1
naflexvit_base_patch16_radio_v3 98.25 - 512 1
naflexvit_base_patch16_siglip 92.93 56.12 384 1
naflexvit_giant_patch16_radio_v3 1159.62 - 512 1
naflexvit_huge_patch16_radio_v3 651.64 - 512 1
naflexvit_huge_patch16_radio_v4 651.65 - 512 1
naflexvit_large_patch16_radio_v3 319.93 - 512 1
naflexvit_so150m2_patch16_reg1_gap 136.06 89.53 384 0
naflexvit_so150m2_patch16_reg1_map 142.46 90.33 384 0
naflexvit_so400m_patch16_radio_v4 431.24 - 512 1
naflexvit_so400m_patch16_siglip 427.89 259.65 384 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.

Weights are grouped by source: the paper or origin given in the pretrained config, else a Hub organization other than timm, else the first part of the pretrained tag (architecture.tag). Sources with a single weight are listed under other.

arXiv:2412.07679

Pretrained configs reference arXiv:2412.07679.

Weight Input size Top-1 (%) Eval size Classes License Hub
naflexvit_base_patch16_radio_v3.c_radio 512 - - none nvidia-open-model-license timm
naflexvit_giant_patch16_radio_v3.c_radio 512 - - none nvidia-open-model-license timm
naflexvit_huge_patch16_radio_v3.c_radio 512 - - none nvidia-open-model-license timm
naflexvit_large_patch16_radio_v3.c_radio 512 - - none nvidia-open-model-license timm

v2 tags

Weight Input size Top-1 (%) Eval size Classes License Hub
naflexvit_base_patch16_siglip.v2_webli 384 - - none apache-2.0 timm
naflexvit_so400m_patch16_siglip.v2_webli 384 - - none apache-2.0 timm

arXiv:2601.17237

Pretrained configs reference arXiv:2601.17237.

Weight Input size Top-1 (%) Eval size Classes License Hub
naflexvit_huge_patch16_radio_v4.c_radio 512 - - none nvidia-open-model-license timm
naflexvit_so400m_patch16_radio_v4.c_radio 512 - - none nvidia-open-model-license timm

Other

Weight Input size Top-1 (%) Eval size Classes License Hub
naflexvit_base_patch16_gap.e300_s576_in1k 384 83.340 384 1000 apache-2.0 timm
naflexvit_base_patch16_par_gap.e300_s576_in1k 384 83.508 384 1000 apache-2.0 timm
naflexvit_base_patch16_parfac_gap.e300_s576_in1k 384 83.468 384 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.