Skip to main content
Back

Hugging Face Adds RepVGG-A0 to timm With 9M Parameters and One-Line Deployment

The compact RepVGG-A0 checkpoint is live on the Hugging Face Hub via timm, offering a 9M-parameter plain-conv backbone trained on ImageNet-1k.

Pro

  • RepVGG-A0 pretrained weights are now available on Hugging Face via timm.
  • 9.1M params, 1.5 GMACs, 224x224 input, trained on ImageNet-1k, MIT licensed.
  • Inference graph is pure 3x3 conv plus ReLU after structural re-parameterization.
  • Multi-branch training blocks collapse into a single 3x3 conv via BN folding.
  • Loadable in one line through timm.create_model or Transformers pipeline.
  • Underpins the backbone design used in YOLOv6 and YOLOv7.

Hugging Face now hosts a RepVGG-A0 checkpoint that timm can download and instantiate with one create_model call. The 9.1-million-parameter weights came from the paper’s authors and were trained for 1,000-class ImageNet classification on 224 × 224 RGB images.

RepVGG addresses a practical hardware constraint. Multi-branch blocks optimize effectively during training, and homogeneous stacks of 3 × 3 convolutions map efficiently to common inference kernels. Structural reparameterization combines those properties by training with several branches and later folding each block into a single convolution.

Nine million parameters, one standard API

Property Value
Parameters 9.1 million
Compute 1.5 GMACs per 224 × 224 image
Activations 3.6 million
Input 3 × 224 × 224
Classifier output 1,000 ImageNet logits
Checkpoint source Original RepVGG authors
License MIT

The timm implementation uses its configurable BYOBNet implementation. That scaffold supports custom stages, stems, normalization layers, output strides, gradient checkpointing, stochastic depth, classifier removal, and per-stage feature extraction without changing the checkpoint-loading interface.

Load the saved recipe

Installing current versions of timm and the Hub client provides the model loader and checkpoint download path:

python -m pip install -U timm huggingface_hub

The model’s saved data configuration supplies its resize, crop, interpolation, normalization, and input-size settings:

import timm
import torch
from PIL import Image

model = timm.create_model(
    "hf-hub:timm/repvgg_a0.rvgg_in1k",
    pretrained=True,
).eval()

data_config = timm.data.resolve_model_data_config(model)
transform = timm.data.create_transform(
    **data_config,
    is_training=False,
)

image = Image.open("image.jpg").convert("RGB")
batch = transform(image).unsqueeze(0)

with torch.inference_mode():
    logits = model(batch)
    probabilities = logits.softmax(dim=1)
    scores, class_ids = probabilities.topk(5)

The first call downloads the checkpoint into the local Hugging Face cache. The returned class_ids use ImageNet-1k class ordering, so applications need the corresponding label map when displaying names.

Turn logits into feature maps

A batch containing one 224 × 224 image produces five feature maps when the model is created with features_only=True:

backbone = timm.create_model(
    "hf-hub:timm/repvgg_a0.rvgg_in1k",
    pretrained=True,
    features_only=True,
).eval()

with torch.inference_mode():
    feature_maps = backbone(batch)

print([tuple(x.shape) for x in feature_maps])
# [
#   (1, 48, 112, 112),
#   (1, 48, 56, 56),
#   (1, 96, 28, 28),
#   (1, 192, 14, 14),
#   (1, 1280, 7, 7),
# ]

Those resolutions correspond to strides of 2, 4, 8, 16, and 32, giving detection and segmentation heads a conventional multiscale pyramid. Applications that need one vector per image can remove the classifier and retain the global pooling layer:

encoder = timm.create_model(
    "hf-hub:timm/repvgg_a0.rvgg_in1k",
    pretrained=True,
    num_classes=0,
).eval()

with torch.inference_mode():
    embeddings = encoder(batch)

print(embeddings.shape)
# torch.Size([1, 1280])

Fuse the graph before export

Each training block combines a 3 × 3 convolution branch, a 1 × 1 branch, and an identity branch when the input and output shapes match. Batch normalization sits on those branches before their outputs are summed and passed through the activation.

Conversion pads the 1 × 1 kernel to 3 × 3, represents the identity path as a fixed 3 × 3 kernel, and folds each batch-normalization scale and offset into its convolution. Summing the resulting kernels and biases reproduces the block’s preactivation output within floating-point precision, leaving one 3 × 3 convolution for deployment.

with torch.inference_mode():
    reference_logits = model(batch)

deploy_model = timm.models.reparameterize_model(model).eval()

with torch.inference_mode():
    deploy_logits = deploy_model(batch)

torch.testing.assert_close(
    deploy_logits,
    reference_logits,
    rtol=1e-4,
    atol=1e-5,
)

Fine-tuning should finish before conversion because fusion removes the separate branches and their train-time normalization layers. Export and latency tests should use the fused model, with final throughput measured on the target runtime and hardware.

Branches buy measurable accuracy

The RepVGG paper isolates the contribution of each training branch in its B0 ablation:

B0 configuration ImageNet top-1 accuracy
Plain baseline 72.39%
Baseline with 1 × 1 branch 73.15%
Baseline with identity branch 74.79%
Full RepVGG-B0 75.14%

These B0 results attribute a 2.75-percentage-point gain to the complete training structure. The paper’s larger variants exceed 80% top-1 accuracy, while A0 reduces capacity and computation for deployments with tighter resource limits. Checkpoint accuracy should be validated with the intended preprocessing, dataset, precision, and runtime.

Where A0 fits

RepVGG-A0 provides a compact backbone for workloads that benefit from common convolution operators and a predictable feature hierarchy:

  • Image classification on edge or mobile hardware after target-device benchmarking
  • Detection and segmentation through the five multiscale feature outputs
  • Retrieval, clustering, and similarity search with 1,280-dimensional embeddings
  • ONNX, TensorRT, and quantization experiments using the fused graph
  • Comparisons with later reparameterized architectures such as DBB and DyRep

Rep-style blocks later appeared in YOLOv6 and YOLOv7, extending the same training-to-deployment strategy to object detection. The Hub checkpoint places that design behind the standard timm interface while preserving the preprocessing metadata, output modes, and fusion path needed for production evaluation.