TinyFormer

TinyFormer is a trainable transformer detector with a DINOv3 backbone.

Tác vụ
detection
Cài đặt
pip install libreyolo
Bậc hỗ trợ
Cốt lõi, từ v1.6.0. Các bộ phát hiện cốt lõi có thể huấn luyện: tính năng theo sau các mô hình chủ lực trong cùng đợt phát hành.
Thượng nguồn
TinyFormer của TinyFormer authors, Apache-2.0; DINOv3 terms. Bài báo, mã nguồn
Giấy phép
Mã nguồn MIT, trọng số Apache-2.0; DINOv3 terms. Sử dụng thương mại

Install

bash
pip install "libreyolo"

Predict

Python
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.

Python
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

Python
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ác vụONNXTorchScriptExecuTorchTensorRTOpenVINOPaddleMNNRKNNncnnTFLiteCoreMLCore AI
DetectionDetection to ONNX: được hỗ trợDetection to TorchScript: được hỗ trợDetection to ExecuTorch: được hỗ trợDetection to TensorRT: được hỗ trợDetection to OpenVINO: được hỗ trợDetection to Paddle: không được hỗ trợDetection to MNN: không được hỗ trợDetection to RKNN: không được hỗ trợDetection to ncnn: không được hỗ trợDetection to TFLite: không được hỗ trợDetection to CoreML: không được hỗ trợDetection to Core AI: không được hỗ trợ
Python
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

Tensorimages float32 [batch, 3, height, width]
MàuRGB
Chuẩn hóa tỉ lệpixel / 255
Chuẩn hóatrung bình [0.485,0.456,0.406], độ lệch chuẩn [0.229,0.224,0.225]
Đổi kích thướckéo giãn về rộng x cao (không đệm, không giữ tỉ lệ khung hình), Pillow bilinear
Cách tái tạo phép đổi kích thước bilinear của Pillow

LibreYOLO đổi kích thước bằng bộ lọc BILINEAR của Pillow (Image.resize). Đó không phải OpenCV INTER_LINEAR hay INTER_AREA: khi thu nhỏ, Pillow nới rộng bộ lọc theo hệ số thu nhỏ, còn các phép đổi kích thước của OpenCV làm thay đổi kết quả phát hiện và dịch các hộp đi vài pixel. Để tái tạo mà không dùng Pillow, hãy đổi kích thước một trục, làm tròn về 8 bit, rồi đổi kích thước trục còn lại và làm tròn lần nữa. Với mỗi trục, đặt s = in_size / out_size và f = max(s, 1). Pixel đầu ra i có tâm c = (i + 0.5) * s và đọc các pixel nguồn j từ int(c - f + 0.5) đến int(c + f + 0.5) - 1, giới hạn trong ảnh, mỗi pixel có trọng số max(0, 1 - |j + 0.5 - c| / f), chia cho tổng các trọng số. Pillow tính bằng dấu phẩy cố định và chọn thứ tự trục theo hình dạng ảnh, nên trọng số dấu phẩy động có thể lệch một mức ở vài pixel. Điều đó không làm thay đổi kết quả trong các kiểm tra của chúng tôi.

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, xuất mặc định
Đầu raHình dạngÝ nghĩa
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.

Hậu xử lý

  1. Apply sigmoid to pred_logits.
  2. 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.
  3. Keep the pairs whose score is above the confidence threshold (0.25 by default).
  4. 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.
  5. There is no NMS and the iou threshold is not used. TinyFormer predicts a set of boxes, and export with nms=True raises NotImplementedError.
  6. LibreYOLO does not clip these boxes, so an edge can sit slightly outside the image.

Để kiểm tra bản triển khai của bạn, hãy chạy cùng tệp đó qua LibreYOLO: LibreYOLO("model.onnx").predict("image.jpg") trả về kết quả tham chiếu. Đã kiểm chứng với LibreYOLO 1.7.0.

Checkpoints

Mọi tệp ở trên hiện đều có trong tổ chức LibreYOLO và được tải xuống trong lần sử dụng đầu tiên.

Licensing

Hãy kiểm tra giấy phép trong repo Hugging Face của trọng số cụ thể mà bạn tải xuống. Mỗi checkpoint trong tổ chức LibreYOLO đều có giấy phép riêng và giấy phép có thể khác nhau trong cùng một họ. Repo đó là nguồn có thẩm quyền; phần tóm tắt dưới đây mô tả các điều khoản áp dụng khi trang này được kiểm chứng lần gần nhất.

Đây là phần mô tả các giấy phép liên quan, không phải tư vấn pháp lý. Nếu câu trả lời có ý nghĩa về mặt thương mại, hãy tự đọc các giấy phép và tham khảo cố vấn của riêng bạn.

Công trình gốc
TinyFormer, TinyFormer authors
Giấy phép thượng nguồn
Apache-2.0; DINOv3 terms
Nguồn thượng nguồn
github.com/mmpmmpmmpjosh/TinyFormer
Mã nguồn LibreYOLO
MIT
Trọng số
Apache-2.0; DINOv3 terms, được phát hành lại tại huggingface.co/LibreYOLO
Diễn giải
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}

}

Được sao chép từ khối trích dẫn của tác giả tại raw.githubusercontent.com/mmpmmpmmpjosh/TinyFormer/main/README.md.

Đã kiểm chứng với LibreYOLO v1.6.0. Các bảng hỗ trợ, checkpoint và số liệu benchmark trên trang này được tạo từ thư viện đã phát hành và trọng số đã công bố, không phải viết thủ công.