timm documentation

NaFlex ViT

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

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

Referenced by pretrained weights:

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

FeatureNaFlexVit
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

ArchitectureParams (M)GMACsInput sizePretrained weights
naflexvit_base_patch16_gap86.6355.863841
naflexvit_base_patch16_map93.7256.233840
naflexvit_base_patch16_par_gap86.6355.863841
naflexvit_base_patch16_parfac_gap86.4655.863841
naflexvit_base_patch16_radio_v398.25-5121
naflexvit_base_patch16_siglip92.9356.123841
naflexvit_giant_patch16_radio_v31159.62-5121
naflexvit_huge_patch16_radio_v3651.64-5121
naflexvit_huge_patch16_radio_v4651.65-5121
naflexvit_large_patch16_radio_v3319.93-5121
naflexvit_so150m2_patch16_reg1_gap136.0689.533840
naflexvit_so150m2_patch16_reg1_map142.4690.333840
naflexvit_so400m_patch16_radio_v4431.24-5121
naflexvit_so400m_patch16_siglip427.89259.653841

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.

WeightInput sizeTop-1 (%)Eval sizeClassesLicenseHub
naflexvit_base_patch16_radio_v3.c_radio512--nonenvidia-open-model-licensetimm
naflexvit_giant_patch16_radio_v3.c_radio512--nonenvidia-open-model-licensetimm
naflexvit_huge_patch16_radio_v3.c_radio512--nonenvidia-open-model-licensetimm
naflexvit_large_patch16_radio_v3.c_radio512--nonenvidia-open-model-licensetimm

v2 tags

WeightInput sizeTop-1 (%)Eval sizeClassesLicenseHub
naflexvit_base_patch16_siglip.v2_webli384--noneapache-2.0timm
naflexvit_so400m_patch16_siglip.v2_webli384--noneapache-2.0timm

arXiv:2601.17237

Pretrained configs reference arXiv:2601.17237.

WeightInput sizeTop-1 (%)Eval sizeClassesLicenseHub
naflexvit_huge_patch16_radio_v4.c_radio512--nonenvidia-open-model-licensetimm
naflexvit_so400m_patch16_radio_v4.c_radio512--nonenvidia-open-model-licensetimm

Other

WeightInput sizeTop-1 (%)Eval sizeClassesLicenseHub
naflexvit_base_patch16_gap.e300_s576_in1k38483.3403841000apache-2.0timm
naflexvit_base_patch16_par_gap.e300_s576_in1k38483.5083841000apache-2.0timm
naflexvit_base_patch16_parfac_gap.e300_s576_in1k38483.4683841000apache-2.0timm
Update on GitHub