TinyViT-5M: INT8 ONNX, 80.5% ImageNet in 9.2 MB

TinyViT-5M (timm/tiny_vit_5m_224.dist_in22k_ft_in1k, MIT) quantized to INT8 with Kenosis: 128-image calibration, no retraining. 80.53% top-1 from a single 9.2 MB file, measured on CPU with ONNX Runtime and OpenVINO. No accelerator required.

Accuracy

ImageNet-1K validation, 49,872 images (disjoint from the 128 calibration images), top-1.

model ONNX Runtime OpenVINO size
FP32 baseline 80.873% 80.873% 22.1 MB
Kenosis INT8 80.532% 80.534% 9.23 MB

Measured on a CPU with AVX-VNNI; on CPUs without VNNI this model's INT8 top-1 sits about 0.9 below FP32 rather than 0.34.

Speed

Against the FP32 model, measured on a CPU with AVX-VNNI: about the same speed on ONNX Runtime with one thread.

Run

from huggingface_hub import hf_hub_download
import numpy as np, onnxruntime as ort
from PIL import Image
config = hf_hub_download("CoreEpoch/tinyvit-5m-int8-imagenet", "config.json")
path = hf_hub_download("CoreEpoch/tinyvit-5m-int8-imagenet", "tinyvit_5m_224_int8_kenosis.onnx")
sess = ort.InferenceSession(path, providers=["CPUExecutionProvider"])
img = Image.open("your_image.jpg").convert("RGB")
scale = 236 / min(img.size)  # shorter side to 236, center crop to 224: measured transform
img = img.resize((round(img.width*scale), round(img.height*scale)), Image.BICUBIC)
l, t = (img.width-224)//2, (img.height-224)//2
img = img.crop((l, t, l+224, t+224))
x = (np.asarray(img, np.float32)/255.0 - [0.485,0.456,0.406]) / [0.229,0.224,0.225]
logits = sess.run(None, {"input": x.transpose(2,0,1)[None].astype(np.float32)})[0]
print(int(np.argmax(logits)))

Input 1x3x224x224, RGB, /255, ImageNet mean/std. Output logits [1,1000], sorted-synset order.

Integrity & license

tinyvit_5m_224_int8_kenosis.onnx (9,228,567 B), SHA-256 EDA9007C0449F118F02B1E8C4BA6B43BEC51A7D7AB677566D42929EB3DA02874. MIT (base TinyViT, Wu et al. 2022, retained). The license covers these model files only; it grants no rights in Kenosis, Core Epoch's quantizer, which remains proprietary.

For licensing inquiries or custom model quantization: coreepoch.dev/kenosis · licensing@coreepoch.dev

Downloads last month
50
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for CoreEpoch/tinyvit-5m-int8-imagenet

Quantized
(1)
this model

Dataset used to train CoreEpoch/tinyvit-5m-int8-imagenet