pvt-small-224 / README.md
IMvision12's picture
Upload README.md with huggingface_hub
27f3928 verified
|
Raw
History Blame Contribute Delete
4.07 kB
metadata
pipeline_tag: image-classification
license: apache-2.0
base_model: Zetatech/pvt-small-224
library_name: zeromodels
tags:
  - keras
  - zeromodels
  - image-classification
  - pvt
  - backbone
  - arxiv:2102.12122
  - pytorch
  - jax
  - tf

See our collection for all PVT and PVTv2 versions.

Run PVT with Keras 3: JAX, PyTorch, or TensorFlow

GitHub Docs Collection

zeromodels/pvt-small-224

Paper: Pyramid Vision Transformer: A Versatile Backbone for Dense Prediction without Convolutions (arXiv:2102.12122) · HF Papers

PVT is a hierarchical vision transformer: four pyramid stages with spatial-reduction attention over non-overlapping patches and learned position embeddings. Use PvtImageClassify for logits or PvtModel for tokens / per-stage features via as_backbone=True.

  • Parameters: ~24.5M
  • ImageNet-1k top-1: 79.8%

For more details on the model, see the upstream model card.

Pure-Keras 3 conversion of Zetatech/pvt-small-224 for zeromodels. One implementation runs unmodified on TensorFlow / Torch / JAX.

This is an image-classification / backbone checkpoint (PvtImageClassify / PvtModel).

✨ Quick start

import os

os.environ["KERAS_BACKEND"] = "torch"  # or "jax" / "tensorflow"

from PIL import Image
from zeromodels.models.pvt import PvtImageClassify, PvtModel, PvtImageProcessor

model = PvtImageClassify.from_weights("zeromodels/pvt-small-224")
processor = PvtImageProcessor.from_weights("zeromodels/pvt-small-224")

image = Image.open("your_image.jpg").convert("RGB")
pixels = processor(image)  # resize + normalize (normalization lives in the processor)
logits = model(pixels, training=False)
print(logits.shape)  # (1, num_classes)

# Feature extraction: the backbone without the classifier head
backbone = PvtModel.from_weights("zeromodels/pvt-small-224", as_backbone=True)
features = backbone(pixels, training=False)

Normalization is baked into the graph, so pass raw [0, 255] pixels. Load any PVT variant the same way with from_weights("zeromodels/<variant>"):

Variant ImageNet-1k top-1 Hub
pvt-tiny-224 75.1% zeromodels/pvt-tiny-224
pvt-small-224 79.8% zeromodels/pvt-small-224
pvt-medium-224 81.2% zeromodels/pvt-medium-224
pvt-large-224 81.7% zeromodels/pvt-large-224

Tips

  • Set KERAS_BACKEND before importing Keras / zeromodels.
  • PvtImageClassify returns class logits; PvtModel returns features (as_backbone=True for the four-stage pyramid).
  • Both the model and its data format (channels_last / channels_first) are supported and bit-exact.
  • See the docs and Loading Weights.
  • Upstream checkpoints load directly: PvtImageClassify.from_weights("hf:Zetatech/pvt-small-224").

Special Thanks

A huge thank you to the PVT authors (whai362/PVT) and the Hugging Face community for creating and releasing these models.

License: see the YAML license above (matches the upstream checkpoint).