TinyFormer
TinyFormer is a trainable transformer detector with a DINOv3 backbone.
- Tâches
- detection
- Installer
pip install libreyolo- Niveau de support
- Cœur, depuis v1.6.0. Détecteurs entraînables du cœur : les fonctionnalités suivent les fers de lance dans la même vague de publication.
- Licences
- Code MIT, poids Apache-2.0; DINOv3 terms. Usage commercial
Install
pip install "libreyolo"Predict
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreTinyFormers.pt", device="cpu")result = model(SAMPLE_IMAGE)print(result)Choose a published checkpoint below. The naming distinguishes the VisDrone variants and Objects365-to-COCO variants. Prediction requires a square imgsz; rectangular inputs raise an error.
Train
Training accepts a detection dataset YAML. Omitted epochs, batch, imgsz, lr0 and amp use the family recipe.
Dataset setup describes the required training data.
from libreyolo import LibreYOLO model = LibreYOLO("LibreTinyFormers.pt", device="cpu")# coco8.yaml is a built-in 8-image detection dataset that downloads on first use.# Replace it with the path to your own detection dataset YAML.model.train(data="coco8.yaml", epochs=1, device="cpu", workers=0)Validate
from libreyolo import LibreYOLO model = LibreYOLO("LibreTinyFormers.pt", device="cpu")# coco8.yaml downloads on first use; pass your own detection dataset YAML instead.metrics = model.val(data="coco8.yaml", workers=0)print(metrics)Use the dataset format for this task. Validation explains the dataset requirements and returned metrics.
Export
| Tâche | ONNX | TorchScript | ExecuTorch | TensorRT | OpenVINO | Paddle | MNN | RKNN | ncnn | TFLite | CoreML | Core AI |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Detection | Detection to ONNX : pris en charge | Detection to TorchScript : pris en charge | Detection to ExecuTorch : pris en charge | Detection to TensorRT : pris en charge | Detection to OpenVINO : pris en charge | Detection to Paddle : non pris en charge | Detection to MNN : non pris en charge | Detection to RKNN : non pris en charge | Detection to ncnn : non pris en charge | Detection to TFLite : non pris en charge | Detection to CoreML : non pris en charge | Detection to Core AI : non pris en charge |
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreTinyFormers.pt", device="cpu")model.export(format="onnx")Export setup lists format dependencies and loading exported artifacts.
ONNX inputs and outputs
| Tenseur | images float32 [batch, 3, height, width] |
|---|---|
| Couleur | RGB |
| Mise à l'échelle | pixel / 255 |
| Normalisation | moyenne [0.485,0.456,0.406], écart type [0.229,0.224,0.225] |
| Redimensionnement | étirer à largeur x hauteur (sans remplissage, le rapport d'aspect n'est pas conservé), Pillow bilinear |
Comment reproduire le redimensionnement bilinéaire de Pillow
LibreYOLO redimensionne avec le filtre BILINEAR de Pillow (Image.resize). Ce n'est ni OpenCV INTER_LINEAR ni INTER_AREA : en réduction, Pillow élargit le filtre du facteur de réduction, et les redimensionnements d'OpenCV modifient les détections et déplacent les boîtes de plusieurs pixels. Pour le reproduire sans Pillow, redimensionnez un axe, arrondissez sur 8 bits, puis redimensionnez l'autre axe et arrondissez de nouveau. Par axe, posons s = in_size / out_size et f = max(s, 1). Le pixel de sortie i a pour centre c = (i + 0.5) * s et lit les pixels source j de int(c - f + 0.5) à int(c + f + 0.5) - 1, limités à l'image, chacun avec le poids max(0, 1 - |j + 0.5 - c| / f), divisé par la somme des poids. Pillow calcule en virgule fixe et choisit l'ordre des axes selon la forme de l'image, donc des poids en virgule flottante peuvent s'en écarter d'un niveau sur quelques pixels. Cela ne change pas les résultats dans nos vérifications.
Square input only. Export rejects a non-square imgsz, and height and width are 640 by default for every size. Another square imgsz must be a multiple of 32.
Batch size 1 only. The graph declares a dynamic batch axis, but batches of 2 or more fail in 1.7.0.
After the resize, divide by 255, then subtract the ImageNet mean and divide by the ImageNet std, per channel in RGB order.
Detection, export par défaut
| Sortie | Forme | Signification |
|---|---|---|
pred_logits | [batch, queries, nc] | One logit per query and class. Sigmoid is not applied. queries is 300 for every size. |
pred_boxes | [batch, queries, 4] | cx, cy, w, h of each query, normalized 0 to 1 of the input. The input is the whole image stretched, so these are also fractions of the original image. |
Post-traitement
- Apply sigmoid to pred_logits.
- Flatten the [queries, nc] scores and take the top 300 (max_det, 300 by default). For flat index k, the query is k // nc and the class is k % nc. One query can yield several classes.
- Keep the pairs whose score is above the confidence threshold (0.25 by default).
- Convert the query's box to x1 = cx - w / 2, y1 = cy - h / 2, x2 = cx + w / 2, y2 = cy + h / 2. Multiply x by the original image width and y by the original image height.
- There is no NMS and the iou threshold is not used. TinyFormer predicts a set of boxes, and export with nms=True raises NotImplementedError.
- LibreYOLO does not clip these boxes, so an edge can sit slightly outside the image.
Pour vérifier votre propre implémentation, passez le même fichier dans LibreYOLO : LibreYOLO("model.onnx").predict("image.jpg") renvoie les résultats de référence. Vérifié avec LibreYOLO 1.7.0.
Checkpoints
| Fichier | Licence des poids |
|---|---|
| Detection | |
| LibreTinyFormers.pt | other |
| LibreTinyFormerm.pt | other |
| LibreTinyFormerl.pt | other |
| LibreTinyFormerx.pt | other |
| LibreTinyFormerxl.pt | other |
| LibreTinyFormers-visdrone.pt | other |
| LibreTinyFormerm-visdrone.pt | other |
| LibreTinyFormerl-visdrone.pt | other |
| LibreTinyFormerx-visdrone.pt | other |
| LibreTinyFormerx-obj2coco.pt | other |
| LibreTinyFormerxl-obj2coco.pt | other |
Tous les fichiers ci-dessus sont actuellement disponibles dans l<link>organisation LibreYOLO</link> et sont téléchargés à la première utilisation.
Licensing
Vérifiez la licence dans le dépôt Hugging Face des poids précis que vous téléchargez. Chaque checkpoint de l<link>organisation LibreYOLO</link> en possède une, et elles ne sont pas toujours identiques au sein dune même famille. Ce dépôt fait autorité ; le résumé ci-dessous décrit les conditions applicables lors de la dernière vérification de cette page.
Ceci décrit les licences concernées et ne constitue pas un conseil juridique. Si la réponse a une importance commerciale, lisez vous-même les licences et consultez votre propre avocat.
- Travail d'origine
- TinyFormer, TinyFormer authors
- Licence du projet d'origine
- Apache-2.0; DINOv3 terms
- Source du projet d'origine
- github.com/mmpmmpmmpjosh/TinyFormer
- Code de LibreYOLO
- MIT
- Poids
- Apache-2.0; DINOv3 terms, republiés sur huggingface.co/LibreYOLO
- Interprétation
- The detector uses Apache-2.0 source and a DINOv3 backbone with its own terms. Check the publisher declarations for the chosen checkpoint.
Citation
@article{hsieh2026tinyformer,
title={TinyFormer: Preserving Tiny Objects in YOLO-DETR Hybrid Real-time Detectors},
author={Hsieh, Jun-Wei and Kao, Meng-Yu and Kurniawan, Ghufron Wahyu and Peng, Kuan-Chuan},
journal={arXiv preprint arXiv:2605.25046},
year={2026}
}Copié depuis le bloc de citation des auteurs sur raw.githubusercontent.com/mmpmmpmmpjosh/TinyFormer/main/README.md.