Instructions to use zeromodels/pvt-tiny-224 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use zeromodels/pvt-tiny-224 with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://zeromodels/pvt-tiny-224") - Notebooks
- Google Colab
- Kaggle
See our collection for all PVT and PVTv2 versions.
Run PVT with Keras 3: JAX, PyTorch, or TensorFlow
zeromodels/pvt-tiny-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: ~13.2M
- ImageNet-1k top-1: 75.1%
For more details on the model, see the upstream model card.
Pure-Keras 3 conversion of Zetatech/pvt-tiny-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
import numpy as np
from zeromodels.models.pvt import PvtImageClassify, PvtModel
model = PvtImageClassify.from_weights("zeromodels/pvt-tiny-224")
backbone = PvtModel.from_weights("zeromodels/pvt-tiny-224", as_backbone=True)
image = Image.open("your_image.jpg").convert("RGB").resize((224, 224))
x = np.asarray(image, dtype="float32")[None] # (1, H, W, 3), raw [0, 255]
print(model(x).shape) # (1, num_classes)
feats = backbone(x)
print(len(feats), [tuple(f.shape) for f in feats]) # 4-stage feature pyramid
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_BACKENDbefore importing Keras / zeromodels. PvtImageClassifyreturns class logits;PvtModelreturns features (as_backbone=Truefor 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-tiny-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).
Model tree for zeromodels/pvt-tiny-224
Base model
Zetatech/pvt-tiny-224