> This is the documentation for LibreYOLO 1.6.0. Current version: https://www.libreyolo.com/docs/models/teed

# TEED
TEED (Tiny and Efficient Edge Detector) is a small convolutional network that predicts a dense edge-probability map from one RGB image. LibreYOLO wraps its architecture for edge detection only; no checkpoint ships with the library.
Tasks: Edges. Install: pip install libreyolo.
Verified against LibreYOLO v1.5.0.

## Install

TEED needs no optional extra. Everything it imports is in the base install.

```bash
pip install libreyolo
```

## Predict

LibreYOLO ships no TEED checkpoint. The officially released weights are
trained on BIPED, whose published dataset terms restrict use to
non-commercial purposes, so LibreYOLO does not mirror them. Convert a
checkpoint you are licensed to use with `weights/convert_teed_weights.py`,
which checks the tensor keys against the runtime architecture before writing
a file LibreYOLO can load directly:

```bash
python weights/convert_teed_weights.py upstream.pth weights/LibreTEEDt-edge.pt --verify
```

**Python**

```python
from libreyolo import LibreYOLO, SAMPLE_IMAGE

model = LibreYOLO("weights/LibreTEEDt-edge.pt")
result = model(SAMPLE_IMAGE, save=True)

edges = result.edges
print(edges.array.shape)        # (H, W) float32 in [0, 1]
print(edges.binary(0.5).sum())  # thresholded edge-pixel count
```

**CLI**

```bash
libreyolo predict model=weights/LibreTEEDt-edge.pt source=https://raw.githubusercontent.com/LibreYOLO/libreyolo/release/libreyolo/assets/parkour.jpg save=True
```

`result.edges` holds the result: an `(H, W)` float32 array in `[0, 1]`,
with `.binary(threshold)` returning a boolean edge mask. There are no boxes,
so `conf`, `iou` and `max_det` have no effect. See
[prediction](/docs/v1.6.0/predict) for sources, streaming and result handling.

## Variants

TEED ships one size in LibreYOLO. LibreYOLO's benchmark harness has not
measured this family, so there are no published numbers to compare it
against.

## Validate

`val()` reports BSDS-style ODS and OIS F-measures against a paired edge
dataset: images beside same-stem edge maps, with an optional validity mask so
padded pixels never count. `imgsz` must be divisible by the network's
downsample stride, and LibreYOLO raises a clear error if it is not.

**Python**

```python
from libreyolo import LibreYOLO

model = LibreYOLO("weights/LibreTEEDt-edge.pt")
metrics = model.val(data="my-dataset.yaml", imgsz=352)

print(metrics["metrics/ODS"])   # optimal-dataset-scale F-measure
print(metrics["metrics/OIS"])   # optimal-image-scale F-measure
```

**CLI**

```bash
libreyolo val model=weights/LibreTEEDt-edge.pt data=my-dataset.yaml imgsz=352
```

## Export

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

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

Edge export uses a fixed-resolution, batch-1 runtime contract: `dynamic` and a
`batch` other than 1 are rejected, and the exported graph outputs a single
fused probability map. An exported artifact loads back through `LibreYOLO()`
on its file suffix, so a `.onnx` file behaves like a checkpoint and returns
the same `Results`.

**Python**

```python
from libreyolo import LibreYOLO

model = LibreYOLO("weights/LibreTEEDt-edge.pt")
model.export(format="onnx", imgsz=352)
model.export(format="tensorrt", imgsz=352, half=True)
```

**CLI**

```bash
libreyolo export model=weights/LibreTEEDt-edge.pt format=onnx imgsz=352
libreyolo export model=weights/LibreTEEDt-edge.pt format=tensorrt imgsz=352 half=True
```

**Use the exported file**

```python
from libreyolo import LibreYOLO, SAMPLE_IMAGE

model = LibreYOLO("weights/LibreTEEDt-edge.onnx")
result = model(SAMPLE_IMAGE)

print(result.edges.array.shape)
```

## 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: TEED, Xavier Soria
- Upstream license: MIT
- Upstream source: https://github.com/xavysp/TEED
- LibreYOLO code: MIT
- Weights: MIT, distributed by their authors. LibreYOLO does not host or mirror them.
- Interpretation: MIT is a permissive license, so the TEED architecture LibreYOLO ports can be used in commercial and closed-source products, with the license text and copyright notice kept alongside any copy you redistribute. LibreYOLO ships no checkpoint for this family: the officially released weights are trained on BIPED, whose published dataset terms restrict use to non-commercial purposes, and mirroring them would carry that restriction into a nominally MIT-licensed download. Convert a checkpoint you hold a license for with `weights/convert_teed_weights.py`; the MIT code license does not change the terms attached to whatever checkpoint you convert.

LibreYOLO publishes no TEED checkpoint. Nothing is mirrored under the
LibreYOLO organization; convert a checkpoint you hold a license for with
`weights/convert_teed_weights.py` instead.

## Citation

```bibtex
@InProceedings{Soria_2023teed,
    author    = {Soria, Xavier and Li, Yachuan and Rouhani, Mohammad and Sappa, Angel D.},
    title     = {Tiny and Efficient Model for the Edge Detection Generalization},
    booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV) Workshops},
    month     = {October},
    year      = {2023},
    pages     = {1364-1373}
}
```

Copied from https://github.com/xavysp/TEED#citation


## TEED architecture

- Tiny: [SVG](/diagrams/models/teed/t-edge.svg), [interactive diagram](/diagrams/models/teed/t-edge.html)
