TinyFormer
TinyFormer is a trainable transformer detector with a DINOv3 backbone.
- タスク
- detection
- インストール
pip install libreyolo- サポートティア
- コア、v1.6.0以降。学習可能なコア検出器:機能は同じリリースサイクルでフラッグシップに続いて実装されます。
- ライセンス
- コード:MIT、重み:Apache-2.0; DINOv3 terms。商用利用
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
| タスク | ONNX | TorchScript | ExecuTorch | TensorRT | OpenVINO | Paddle | MNN | RKNN | ncnn | TFLite | CoreML | Core AI |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Detection | Detection to ONNX:対応 | Detection to TorchScript:対応 | Detection to ExecuTorch:対応 | Detection to TensorRT:対応 | Detection to OpenVINO:対応 | Detection to Paddle:非対応 | Detection to MNN:非対応 | Detection to RKNN:非対応 | Detection to ncnn:非対応 | Detection to TFLite:非対応 | Detection to CoreML:非対応 | Detection to Core AI:非対応 |
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
| テンソル | images float32 [batch, 3, height, width] |
|---|---|
| 色 | RGB |
| スケーリング | ピクセル値 / 255 |
| 正規化 | 平均 [0.485,0.456,0.406], 標準偏差 [0.229,0.224,0.225] |
| リサイズ | 幅 x 高さに引き伸ばす(パディングなし、アスペクト比は保持しない), Pillow bilinear |
Pillow のバイリニアリサイズを再現する方法
LibreYOLO は Pillow の BILINEAR フィルタ(Image.resize)でリサイズします。これは OpenCV の INTER_LINEAR や INTER_AREA ではありません。縮小時、Pillow は縮小率の分だけフィルタを広げます。OpenCV のリサイズでは検出結果が変わり、ボックスが数ピクセルずれます。Pillow なしで再現するには、片方の軸をリサイズして 8 ビットに丸め、もう片方の軸をリサイズして再び丸めます。軸ごとに s = in_size / out_size、f = max(s, 1) とします。出力ピクセル i の中心は c = (i + 0.5) * s で、元画像のピクセル j を int(c - f + 0.5) から int(c + f + 0.5) - 1 まで(画像内に制限して)読み取り、それぞれの重みは max(0, 1 - |j + 0.5 - c| / f) で、重みの合計で割ります。Pillow は固定小数点で計算し、画像の形状から軸の順序を選ぶため、浮動小数点の重みでは一部のピクセルで 1 レベル異なることがあります。これは私たちの検証の結果を変えません。
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、デフォルトのエクスポート
| 出力 | 形状 | 意味 |
|---|---|---|
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. |
後処理
- 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.
自分の実装を確認するには、同じファイルを LibreYOLO で実行します。LibreYOLO("model.onnx").predict("image.jpg") が基準となる結果を返します。 LibreYOLO 1.7.0 で検証済み。
Checkpoints
| ファイル | 重みのライセンス |
|---|---|
| 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 |
上記のすべてのファイルは現在LibreYOLO orgにあり、初回使用時にダウンロードされます。
Licensing
ダウンロードする特定の重みについて、Hugging Faceリポジトリのライセンスを確認してください。LibreYOLO orgの各チェックポイントにはライセンスが付与されており、同じファミリー内でも常に同一とは限りません。そのリポジトリが正式な情報源です。以下の概要は、このページを最後に検証した時点で適用されていた内容を示します。
これは関連するライセンスの説明であり、法的助言ではありません。商用上重要な場合は、自分でライセンスを読み、専門家の助言を受けてください。
- 原著作物
- TinyFormer, TinyFormer authors
- アップストリームのライセンス
- Apache-2.0; DINOv3 terms
- アップストリームのソース
- github.com/mmpmmpmmpjosh/TinyFormer
- LibreYOLOのコード
- MIT
- 重み
- Apache-2.0; DINOv3 terms、huggingface.co/LibreYOLOで再公開
- 解釈
- 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}
}著者によるraw.githubusercontent.com/mmpmmpmmpjosh/TinyFormer/main/README.mdの引用ブロックからコピーしています。