DeiT
DeiT (Data-efficient image Transformer) is a plain Vision Transformer classifier trained on ImageNet-1k alone, with no extra pretraining data. LibreYOLO carries the tiny, small and base patch-16 sizes as a frozen, inference-only exhibit.
- Tasks
- classify
- Sizes
- t, s, b at 224 px
- Install
pip install libreyolo- Support tier
- Museum, since v. Frozen exhibit. Bug fixes only.
- Licenses
- Code Apache-2.0, weights Apache-2.0. Commercial use
Install
DeiT needs no extra beyond the base package.
pip install libreyoloPredict
This family is inference-only: train() raises NotImplementedError, so this
page has no Train section. Predict, validate and export are all supported.
Weights download from Hugging Face on first use and are cached locally. The
-cls suffix in the filename is required and selects the classification task.
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreDeiTb-cls.pt")result = model(SAMPLE_IMAGE) print(result.probs.top1, result.probs.top1conf)print(result.probs.top5)libreyolo predict model=LibreDeiTb-cls.pt source=https://raw.githubusercontent.com/LibreYOLO/libreyolo/release/libreyolo/assets/parkour.jpgThe returned Results object carries a probs tensor instead of boxes;
top1 and top5 index the 1,000 ImageNet-1k classes and top1conf is the
softmax score for the top prediction. Each size has a fixed input resolution
from its positional embedding: preprocessing resizes and center-crops to it,
and passing a different imgsz raises rather than silently resampling. See
prediction for sources, streaming and result handling.
Validate
val() returns a dictionary with top-1 and top-5 accuracy, measured against a
dataset laid out in the conventional train/<class>/ and val/<class>/
folder structure.
from libreyolo import LibreYOLO model = LibreYOLO("LibreDeiTb-cls.pt")metrics = model.val(data="my-dataset.yaml") print(metrics["metrics/accuracy_top1"])print(metrics["metrics/accuracy_top5"])libreyolo val model=LibreDeiTb-cls.pt data=my-dataset.yamlExport
| Task | ONNX | TorchScript | ExecuTorch | TensorRT | OpenVINO | Paddle | MNN | RKNN | ncnn | TFLite | CoreML | Core AI |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| classify | classify to ONNX: supported. | classify to TorchScript: supported. | classify to ExecuTorch: supported. | classify to TensorRT: supported. | classify to OpenVINO: supported. | classify to Paddle: not supported | classify to MNN: not supported | classify to RKNN: not supported | classify to ncnn: supported. | classify to TFLite: not supported | classify to CoreML: not supported | classify to Core AI: not supported |
An exported artifact loads back through LibreYOLO() on its file suffix, so a
.onnx or .engine file behaves like a checkpoint and returns the same
Results. Running the graph in a bare runtime, with no LibreYOLO installed, is
also supported, but then preprocessing and postprocessing are yours to write.
from libreyolo import LibreYOLO model = LibreYOLO("LibreDeiTb-cls.pt")model.export(format="onnx")model.export(format="tensorrt", half=True)libreyolo export model=LibreDeiTb-cls.pt format=onnxlibreyolo export model=LibreDeiTb-cls.pt format=tensorrt half=Truefrom libreyolo import LibreYOLO, SAMPLE_IMAGE # The factory routes on the file suffix, so an exported artifact loads# like any checkpoint and returns the same Results object.model = LibreYOLO("LibreDeiTb-cls.onnx")result = model(SAMPLE_IMAGE) print(result.probs.top1)Checkpoints
Every published weight file for this family.
| File | Input (px) | Weights license |
|---|---|---|
| classify | ||
| LibreDeiTt-cls.pt | 224 | apache-2.0 |
| LibreDeiTs-cls.pt | 224 | apache-2.0 |
| LibreDeiTb-cls.pt | 224 | apache-2.0 |
Every file above exists in the LibreYOLO org today and downloads on first use.
Licensing
Check the license on the Hugging Face repository of the specific weights you download. Every checkpoint in the LibreYOLO org carries one, and they are not always the same across a family. That repository is the authoritative source; the summary below describes what applied when this page was last verified.
This is a description of the licenses involved, not legal advice. If the answer matters commercially, read the licenses yourself and take your own counsel.
- Original work
- DeiT, Meta Research
- Upstream license
- Apache-2.0
- Upstream source
- github.com/facebookresearch/deit
- LibreYOLO code
- MIT
- Weights
- Apache-2.0, republished at huggingface.co/LibreYOLO
- Interpretation
- Apache-2.0 is a permissive license, so these weights can be used in commercial and closed-source products. It asks you to keep its license text and attribution notices with any copy of the weights you redistribute, and it grants a patent license. It places no obligation on your own application code, and weights you train yourself on your own data are yours. LibreYOLO ships the plain tiny, small and base patch-16 classifiers at fixed 224px only; the distillation-token, CaiT, DeiT III and 384px variants from the same repository are out of scope.
Citation
@InProceedings{pmlr-v139-touvron21a,
title = {Training data-efficient image transformers & distillation through attention},
author = {Touvron, Hugo and Cord, Matthieu and Douze, Matthijs and Massa, Francisco and Sablayrolles, Alexandre and Jegou, Herve},
booktitle = {International Conference on Machine Learning},
pages = {10347--10357},
year = {2021},
volume = {139},
month = {July}
}Copied from the authors' citation block at github.com/facebookresearch/deit#-model-zoo.