Skip to navigation

Export LibreYOLO

Runs on: gpu Dockerfile
First run can take longer while the worker pulls the configured Docker image.

Overview

Converts a LibreYOLO detection checkpoint to PyTorch, ONNX, or TensorRT, whichever formats you tick, and attaches each result to the model version the weights came from.

The model then carries its weights and every format it has been exported to, and the model page lists them for download. A format already exported from the same checkpoint with the same settings is reused instead of converted again.

Use it after Train LibreYOLO when a checkpoint needs a deployment format.

Train LibreYOLO Export LibreYOLO Exported model files

Prerequisites

RequirementWhat you need
LibreYOLO modelA LibreYOLO detection model version with weights of its own, e.g. one trained by Train LibreYOLO. A model copied from the catalog stores no weights of its own to attach exports to.
NVIDIA GPUA GPU worker with a working NVIDIA runtime. The node requests one for every run, and TensorRT has no CPU fallback.

How it works

1

Checks each ticked format against the exports already on the model version and skips the ones built from the same checkpoint with the same settings.

2

Downloads the version’s weights once, for however many formats are left to build, and checks them before anything reads them: safetensors are built into the network LibreYOLO defines for the version’s architecture, and a LibreYOLO .pt is read by LibreYOLO itself, which only happens with safe weights off.

3

Hands it to LibreYOLO per format. The PyTorch target stages the weights file itself, model.safetensors for a version trained here, which LibreYOLO("model.safetensors") loads. The ONNX graph is traced at a fixed input shape with batch size 1 with the settings below, and the TensorRT engine is built from that graph.

4

Attaches every produced file to the source model version and returns the same model reference it was given.

FAQ

When the model version already carries an export of that format built from the same checkpoint at the same precision and NMS settings. Every ticked format is checked separately, so a run can build one format and reuse another. Rerunning with the same settings therefore builds nothing new, except an ONNX or TensorRT export made before the node recorded its graph layout (see below), which is rebuilt once.

No. An export is another file on the version it came from, and the Model output is the same reference as the input, so downstream nodes keep running the original weights.

One run downloads the checkpoint once and attaches every format to the same version. A TensorRT engine is built from an ONNX graph, so ticking ONNX as well (in full precision) costs one trace rather than two.

By default the graph ends at the raw head output, in FP32: one row per anchor with the box coordinates and the score of every class. It holds no NMS, so whoever runs it must filter by score and suppress overlaps. With Embed NMS, the ONNX graph ends in suppression instead: the first output holds up to Max detections rows of x1, y1, x2, y2, score, class for the image, in pixels of the model input and padded with zero rows, with the score and IoU thresholds baked into the file; the raw head output follows as a second output. The NMS graph is for one image at a time. A TensorRT engine is always built from the graph without NMS, whatever Embed NMS says: TensorRT 10.9 and 10.13 both refuse the NMS graph of a YOLOv9 model (its TopK ranks all 8400 anchors, above the 3840 TensorRT allows), so the node files the engine as a plain one and logs a warning. LibreYOLO9E2E models return their final detections from the head and need no NMS, so the node exports them as they are, whatever Embed NMS says, and files the export as a plain one. The PyTorch file is the checkpoint and is not affected. Every ONNX and TensorRT file is filed with how to read it: box_format: xyxy, letterbox_pad (topleft for LibreYOLO’s checkpoints), nms, end_to_end (true for LibreYOLO9E2E) and multi_label. The Benchmark runtime node reads these, since the shapes alone look like an Ultralytics head.

ONNX FP16 traces the graph with the model converted to half precision, and TensorRT FP16 builds the engine in half precision. Exports at different precision or NMS settings are kept side by side on the version, and each is reused only for the same settings.

The weights the picked version points at, which for a training run are its best weights, model.safetensors. Their bytes decide how they load, not their name: with safe weights on, a pickle (.pt, .pth) is refused before it is read, and an ONNX model is already an export, so the run stops.

TensorRT builds its engine on a CUDA GPU and has no CPU fallback. The node runs on GPU machine classes only and checks the GPU works before it downloads or converts anything, so a run on a broken GPU stops before any format is built. Every format in the run, ONNX included, is exported on that GPU. An engine build can take several minutes.

Dynamic batch sizes, INT8, and other LibreYOLO export formats. At least one format must be ticked, or the run stops.

The version may have no weights of its own, as with a model copied from the catalog. Train from the catalog model first, then export the version that run produced.

Inputs

Model
modelRequired

Detection model whose weights are exported, e.g. a version trained in this workspace. A model copied from the catalog stores no weights of its own to attach exports to, so train from it first. Key: MODEL.

Export to PyTorch
booleanDefaults to falseRequired

Attach the weights file itself as a PyTorch export - model.safetensors for a version trained here, which LibreYOLO("model.safetensors") loads. Key: EXPORT_PYTORCH.

Export to ONNX
booleanDefaults to falseRequired

Trace the checkpoint to an ONNX graph. By default the graph ends at the raw head output, in FP32, see Embed NMS and ONNX FP16. Key: EXPORT_ONNX.

Export to TensorRT
booleanDefaults to falseRequired

Build a TensorRT engine. It is cut from an intermediate ONNX graph, so ticking ONNX as well costs one trace rather than two. Key: EXPORT_TENSORRT.

Embed NMS
booleanDefaults to falseRequired

Put non-maximum suppression inside the ONNX graph. Off (the default), the graph ends at the raw head output: one row of box coordinates and class scores per anchor, which the caller must filter and suppress. On, the graph’s first output holds up to Max detections rows of x1, y1, x2, y2, score, class per image, in pixels of the model input, already suppressed (padded with zero rows), and the raw head output follows as a second one. Has no effect on the PyTorch file, and none on LibreYOLO9E2E models, whose end-to-end head already returns filtered detections without NMS. A TensorRT engine is always built without NMS: TensorRT cannot build the NMS graph of a YOLOv9 model. Key: NMS.

NMS score threshold
numberDefaults to 0.25Required

Detections below this score are dropped inside the graph. Baked into the file, only used with Embed NMS. Lower it (e.g. 0.001) when the graph feeds an mAP evaluation. Minimum: 0.001. Maximum: 1. Step: 0.001. Key: NMS_CONF.

NMS IoU threshold
numberDefaults to 0.7Required

Two boxes of one class overlapping more than this count as the same object. Baked into the file, only used with Embed NMS. Minimum: 0.01. Maximum: 1. Step: 0.01. Key: NMS_IOU.

Max detections
integerDefaults to 300Required

Most detections the NMS graph returns per image. Baked into the file, only used with Embed NMS. Minimum: 1. Key: MAX_DET.

ONNX FP16
booleanDefaults to falseRequired

Trace the ONNX graph in half precision (the model is converted before tracing, so inputs and outputs are float16 too). Needs the GPU the run already has. Run it with an FP16-capable provider such as CUDA. Key: ONNX_FP16.

TensorRT FP16
booleanDefaults to falseRequired

Build the engine with half-precision layers. Faster and lighter on GPU memory, at a small cost in accuracy, the engine’s input and output tensors stay float32. Key: TRT_FP16.

Outputs

Exported formats
string

Format keys this run produced, comma separated. Read by the download widget. Hidden from the flow editor. Key: EXPORT_FORMATS.

Model
model

The model that was exported, as <model id>@<version id> - the same reference this node was given. An export is another file on that version, not a version of its own, so this output wires on to anything the input accepts. Shown as an artifact. Key: MODEL.

Runtime

The image carries TensorRT, NVIDIA software under NVIDIA’s license.

  • Configured image: ovalbee/node-libreyolo:0.0.17, shared with the train and predict nodes.
  • Upstream base: the OvalBee PyTorch CUDA 12.8 base image, with libreyolo==1.6.0, ONNX and TensorRT installed on top.
  • Exact CUDA, PyTorch, NVIDIA driver, and GPU compatibility depends on the image digest deployed by the worker.

JSON config

Machine-readable node interface for automation and advanced usage.

{
"name": "Export LibreYOLO",
"description": "Convert a LibreYOLO checkpoint to PyTorch, ONNX and TensorRT, optionally with NMS inside the ONNX graph and in half precision, and attach every format to the model it came from.",
"category": "Models",
"namespace": "ovalbee",
"templateKey": "models/libreyolo/export_libreyolo",
"version": "v1",
"inputs": [
{
"key": "MODEL",
"label": "Model",
"type": "model",
"description": "Detection model whose weights are exported, e.g. a version trained in this workspace. A model copied from the catalog stores no weights of its own to attach exports to, so train from it first.\n",
"required": true,
"default": null,
"visibleWhen": null,
"options": {
"framework": "libreyolo",
"task_type": "object_detection"
}
},
{
"key": "EXPORT_PYTORCH",
"label": "Export to PyTorch",
"type": "boolean",
"description": "Attach the weights file itself as a PyTorch export - `model.safetensors` for a version trained here, which `LibreYOLO(\"model.safetensors\")` loads.",
"required": true,
"default": false,
"visibleWhen": null
},
{
"key": "EXPORT_ONNX",
"label": "Export to ONNX",
"type": "boolean",
"description": "Trace the checkpoint to an ONNX graph. By default the graph ends at the raw head output, in FP32; see Embed NMS and ONNX FP16.",
"required": true,
"default": false,
"visibleWhen": null
},
{
"key": "EXPORT_TENSORRT",
"label": "Export to TensorRT",
"type": "boolean",
"description": "Build a TensorRT engine. It is cut from an intermediate ONNX graph, so ticking ONNX as well costs one trace rather than two.",
"required": true,
"default": false,
"visibleWhen": null
},
{
"key": "NMS",
"label": "Embed NMS",
"type": "boolean",
"description": "Put non-maximum suppression inside the ONNX graph. Off (the default), the graph ends at the raw head output: one row of box coordinates and class scores per anchor, which the caller must filter and suppress. On, the graph's first output holds up to Max detections rows of `x1, y1, x2, y2, score, class` per image, in pixels of the model input, already suppressed (padded with zero rows), and the raw head output follows as a second one. Has no effect on the PyTorch file, and none on LibreYOLO9E2E models, whose end-to-end head already returns filtered detections without NMS. A TensorRT engine is always built without NMS: TensorRT cannot build the NMS graph of a YOLOv9 model.\n",
"required": true,
"default": false,
"visibleWhen": null
},
{
"key": "NMS_CONF",
"label": "NMS score threshold",
"type": "number",
"description": "Detections below this score are dropped inside the graph. Baked into the file; only used with Embed NMS. Lower it (e.g. 0.001) when the graph feeds an mAP evaluation.",
"required": true,
"default": 0.25,
"visibleWhen": null,
"options": {
"type": "float",
"min": 0.001,
"max": 1,
"step": 0.001
}
},
{
"key": "NMS_IOU",
"label": "NMS IoU threshold",
"type": "number",
"description": "Two boxes of one class overlapping more than this count as the same object. Baked into the file; only used with Embed NMS.",
"required": true,
"default": 0.7,
"visibleWhen": null,
"options": {
"type": "float",
"min": 0.01,
"max": 1,
"step": 0.01
}
},
{
"key": "MAX_DET",
"label": "Max detections",
"type": "number",
"description": "Most detections the NMS graph returns per image. Baked into the file; only used with Embed NMS.",
"required": true,
"default": 300,
"visibleWhen": null,
"options": {
"type": "integer",
"min": 1
}
},
{
"key": "ONNX_FP16",
"label": "ONNX FP16",
"type": "boolean",
"description": "Trace the ONNX graph in half precision (the model is converted before tracing, so inputs and outputs are float16 too). Needs the GPU the run already has. Run it with an FP16-capable provider such as CUDA.",
"required": true,
"default": false,
"visibleWhen": null
},
{
"key": "TRT_FP16",
"label": "TensorRT FP16",
"type": "boolean",
"description": "Build the engine with half-precision layers. Faster and lighter on GPU memory, at a small cost in accuracy; the engine's input and output tensors stay float32.",
"required": true,
"default": false,
"visibleWhen": null
}
],
"outputs": [
{
"key": "EXPORT_FORMATS",
"label": "Exported formats",
"type": "string",
"description": "Format keys this run produced, comma separated. Read by the download widget.",
"artifact": false,
"badge": false,
"badgeOpens": null,
"hidden": true
},
{
"key": "MODEL",
"label": "Model",
"type": "model",
"description": "The model that was exported, as `<model id>@<version id>` - the same reference this node was given. An export is another file on that version, not a version of its own, so this output wires on to anything the input accepts.\n",
"artifact": true,
"badge": false,
"badgeOpens": null,
"hidden": false
}
],
"runtime": {
"type": "docker",
"devices": [
"gpu"
],
"dockerImage": "ovalbee/node-libreyolo:0.0.17"
},
"widgets": {
"widget": {
"id": "model-download",
"settings": {
"assetId": {
"type": "variable",
"value": "self.outputs.MODEL"
},
"format": {
"type": "variable",
"value": "self.outputs.EXPORT_FORMATS"
}
}
}
}
}

References