XCiT-Tiny-12/P8 β€” INT8 ONNX, 81.2% ImageNet in 8.6 MB

This is XCiT-Tiny-12/P8 (timm/xcit_tiny_12_p8_224.fb_dist_in1k, Apache-2.0), quantized to INT8 with Kenosis, Core Epoch's post-training quantizer, using 128 calibration images and no retraining. It scores 81.16% top-1 on ImageNet-1K in an 8.6 MB single file, and the same file runs on both ONNX Runtime and OpenVINO, with no GPU required.

Measured accuracy

ImageNet-1K validation, 49,872 images. Calibration and evaluation images are disjoint, and every row was evaluated on identical inputs.

model top-1 Ξ” vs FP32 file size
FP32 baseline 81.22% β€” 27.0 MB
this artifact 81.16% βˆ’0.06 8.59 MB
ONNX Runtime static quantization at default calibration, same model, same calibration data 64.95% βˆ’16.3 7.83 MB

Run it

pip install onnxruntime numpy pillow huggingface_hub
from huggingface_hub import hf_hub_download
import numpy as np
import onnxruntime as ort
from PIL import Image

path = hf_hub_download("CoreEpoch/xcit-tiny12-p8-int8-imagenet", "xcit_tiny12_p8_224_int8.onnx")
sess = ort.InferenceSession(path, providers=["CPUExecutionProvider"])
img = Image.open("your_image.jpg").convert("RGB")
scale = 224 / min(img.size)  # shorter side to 224, then center crop β€” the 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] in standard sorted-synset class order. run_classify.py and eval_imagenet.py in this repo reproduce the demo and the full measurement against a local ImageNet validation copy.

Integrity

xcit_tiny12_p8_224_int8.onnx (8,589,956 bytes). SHA-256: 544B82D1CAF5D6548C0507C7C3CE0BF32B88B05E96ED318932A01519A65BF17E.

Credits

Base architecture:

@article{elnouby2021xcit,
  title={XCiT: Cross-Covariance Image Transformers},
  author={El-Nouby, Alaaeldin and Touvron, Hugo and Caron, Mathilde and Bojanowski, Piotr and Douze, Matthijs and Joulin, Armand and Laptev, Ivan and Neverova, Natalia and Synnaeve, Gabriel and Verbeek, Jakob and J{\'e}gou, Herv{\'e}},
  journal={Advances in Neural Information Processing Systems (NeurIPS)},
  year={2021}
}

About

Quantized with Kenosis, Core Epoch's post-training quantizer (patent pending). To apply this to your own models: coreepoch.dev Β· core@coreepoch.dev

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for CoreEpoch/xcit-tiny12-p8-int8-imagenet

Quantized
(1)
this model

Dataset used to train CoreEpoch/xcit-tiny12-p8-int8-imagenet