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는 고정소수점으로 계산하고 이미지 모양에 따라 축 순서를 고르므로, 부동소수점 가중치는 일부 픽셀에서 한 단계 다를 수 있습니다. 이는 우리 검증 결과를 바꾸지 않습니다.
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 조직에 있으며 처음 사용할 때 내려받습니다.
Licensing
내려받는 특정 가중치의 Hugging Face 저장소에서 라이선스를 확인하십시오. LibreYOLO 조직의 모든 체크포인트에는 라이선스가 있으며 한 계열 안에서도 항상 같지는 않습니다. 해당 저장소가 신뢰할 수 있는 기준입니다. 아래 요약은 이 페이지를 마지막으로 검증했을 때 적용된 내용을 설명합니다.
관련 라이선스에 관한 설명이며 법률 자문이 아닙니다. 상업적으로 중요한 사안이라면 라이선스를 직접 읽고 별도의 법률 자문을 받으십시오.
- 원작
- TinyFormer, TinyFormer authors
- 업스트림 라이선스
- Apache-2.0; DINOv3 terms
- 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에 있는 저자의 인용 블록에서 복사했습니다.