# TinyFormer
TinyFormer is a trainable transformer detector with a DINOv3 backbone.
Tasks: Detection. Install: pip install libreyolo.
Verified against LibreYOLO v1.6.0.

## Install

```bash
pip install "libreyolo"
```

## Predict

**Python**

```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](/docs/train/datasets) describes the required training data.

**Python**

```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**

```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](/docs/train/validation) explains the dataset requirements and returned metrics.

## Export

| Task | ONNX | TorchScript | ExecuTorch | TensorRT | OpenVINO | Paddle | MNN | RKNN | ncnn | TFLite | CoreML | Core AI |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Detection | yes | yes | yes | yes | yes |  |  |  |  |  |  |  |

A "yes" means the export is supported. An empty cell means the exporter refuses that combination.

**Python**

```python
from libreyolo import LibreYOLO, SAMPLE_IMAGE

model = LibreYOLO("LibreTinyFormers.pt", device="cpu")
model.export(format="onnx")
```

[Export setup](/docs/export) lists format dependencies and loading exported artifacts.

## Checkpoints

| File | Input (px) | Task | Weights license |
| --- | --- | --- | --- |
| `LibreTinyFormers.pt` |  | Detection | other |
| `LibreTinyFormerm.pt` |  | Detection | other |
| `LibreTinyFormerl.pt` |  | Detection | other |
| `LibreTinyFormerx.pt` |  | Detection | other |
| `LibreTinyFormerxl.pt` |  | Detection | other |
| `LibreTinyFormers-visdrone.pt` |  | Detection | other |
| `LibreTinyFormerm-visdrone.pt` |  | Detection | other |
| `LibreTinyFormerl-visdrone.pt` |  | Detection | other |
| `LibreTinyFormerx-visdrone.pt` |  | Detection | other |
| `LibreTinyFormerx-obj2coco.pt` |  | Detection | other |
| `LibreTinyFormerxl-obj2coco.pt` |  | Detection | other |

## Licensing

Check the license on the Hugging Face repository of the specific weights you download. That repository is authoritative and licenses are not always uniform across a family. This is a description of the licenses involved, not legal advice.

- Original work: TinyFormer, TinyFormer authors
- Upstream license: Apache-2.0; DINOv3 terms
- Upstream source: https://github.com/mmpmmpmmpjosh/TinyFormer
- LibreYOLO code: MIT
- Weights: Apache-2.0; DINOv3 terms, republished at https://huggingface.co/LibreYOLO
- Interpretation: The detector uses Apache-2.0 source and a DINOv3 backbone with its own terms. Check the publisher declarations for the chosen checkpoint.

## Citation

```bibtex
@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}

}
```

Copied from https://raw.githubusercontent.com/mmpmmpmmpjosh/TinyFormer/main/README.md
