Downloads · 30 days
33
100% of all-time downloads
zeromodels/levit-128
levit-128 is a image classification model from zeromodels. Use it when you need a label for an image. It is set up for zeromodels. The card lists the license as apache-2.0.
[](https://github.com/IMvision12/ZeroModels) [](https://imvision12.github.io/ZeroModels/classificationbackbones/) [](https://huggingface.co/collections/zeromodels/levit-6a937f8760837c24b7a51d25)
Downloads · 30 days
33
100% of all-time downloads
All-time downloads
33
Public
Repo size
37.7 MB
Likes
0
Public
Click a slice to open those files.
.h537.7 MB · 100%
From the Hugging Face model README
Paper: LeViT: a Vision Transformer in ConvNet's Clothing for Faster Inference (arXiv:2104.01136) · HF Papers
LeViT is a hybrid convolution/transformer image classifier built for fast inference: a four-layer conv stem downsamples the image 16x, then three attention stages (each adding a learnable 2D relative-position bias) run over the tokens, with a BatchNorm fused into every linear layer and Hardswish activations. The released checkpoints are distilled - a second classification head is averaged with the first at inference. Base LeViT (hidden sizes 128/256/384, depths 4/4/4).
For more details on the model, please go to Meta's original model card.
Pure-Keras 3 conversion of facebook/levit-128 for zeromodels. One implementation runs unmodified on TensorFlow / Torch / JAX.
import os
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
from PIL import Image
from zeromodels.models.levit import LevitImageClassify, LevitModel, LevitImageProcessor
model = LevitImageClassify.from_weights("zeromodels/levit-128")
processor = LevitImageProcessor.from_weights("zeromodels/levit-128")
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 = LevitModel.from_weights("zeromodels/levit-128")
features = backbone(pixels, training=False)
Load any LeViT variant the same way with from_weights("zeromodels/<variant>"):
| Variant | Hub |
|---|---|
levit-128S | zeromodels/levit-128S |
levit-128 | zeromodels/levit-128 |
levit-192 | zeromodels/levit-192 |
levit-256 | zeromodels/levit-256 |
levit-384 | zeromodels/levit-384 |
KERAS_BACKEND before importing Keras / zeromodels.[0, 255] pixels.resize((224, 224)) is close and also works.LevitImageClassify averages the two distillation heads internally; LevitModel.from_weights(...) gives the backbone (the final token sequence, no head).hf: prefix, e.g. LevitImageClassify.from_weights("hf:facebook/levit-128").A huge thank you to the Meta AI LeViT authors for creating and releasing these models.
License: Apache 2.0.