Skip to content

Export your own model

Export with one picture as the input, in floating point numbers, as one file. A fixed input size is read from the model; for a free one OADM uses 640 x 640.

With Ultralytics (pip install ultralytics):

Terminal window
yolo export model=yolo11n.pt format=onnx opset=20

Your own trained model works the same way (model=best.pt). The class names travel inside the file. With opset=20 a graphics card on Windows runs the whole model; with a newer opset part of it runs on the CPU and the card is slower than the CPU.

With PyTorch 2.5 or later:

import torch
model = torch.hub.load('facebookresearch/detr', 'detr_resnet50', pretrained=True).eval()
picture = torch.zeros(1, 3, 800, 800)
torch.onnx.export(model, picture, 'detr-r50.onnx', input_names=['images'],
output_names=['pred_logits', 'pred_boxes'], opset_version=17, dynamo=False)

OADM names the classes with COCO, 91 ids. The ready DETR R50 file saves you the export.

Your own trained RF-DETR: the rf-detr-onnx project exports it with uv run export.py --checkpoint your-model.pth.

Any model with one picture in and one score per class out, for example a classifier of PyTorch exported with torch.onnx.export like DETR above, with one output. Load a labels file when you import it. OADM gives a classifier a 224 x 224 input when the file leaves the size open, and scales the picture as ImageNet models are trained, except for Ultralytics’ files, which say so in the file.

A model runs only with the standard operations of ONNX Runtime. OADM refuses a model that needs code of its own or data in other files. For you this means:

  • A model exported with the standard tools of PyTorch or Ultralytics works.
  • A model that needs a custom operator, for example from TensorRT or an own plugin, is refused. Export it again without.
  • A model exported into several files is refused. Export it as one file.

The Settings step of Import model shows Model detected and what the model check found, for example Detection · 576x576 · 91 classes, and the Model family. The family sets the format, the fit and the scaling at once. A green check marks each setting the check found; a setting you change shows a warning and what the check found below it. The info icon next to each setting shows a picture of what it does.

The Settings step of Import model: Model detected, Model family, Format, Fit and Scaling with their checks
Model family For
YOLOv8, YOLO11, YOLO12 Ultralytics detection exports, also YOLOv5
YOLOv10, YOLO26 end to end Exports that sort out overlapping boxes themselves
YOLOX Megvii’s YOLOX releases
RF-DETR Roboflow’s RF-DETR
DETR Facebook’s DETR, also Hugging Face exports
RT-DETR, D-FINE Hugging Face exports
DETR with labels Exports with boxes, scores and labels apart
ImageNet classifier ResNet, MobileNet, EfficientNet and others
YOLO classifier Ultralytics classification exports

Change the family or a setting only if your model was made differently.

When boxes land in the wrong place or the classes make no sense, open the model’s ⋯ menu > Settings. The same settings as in the wizard:

Setting Choices When to change it
Format YOLO, YOLO with suppression, YOLOX, DETR, RF-DETR, DETR with labels, RT-DETR, Classification The model was read as another family. OADM refuses a format the outputs do not fit
Fit Letterbox, Stretch, Keep shape and pad Boxes are shifted or squeezed. YOLO and YOLOX use Letterbox, RF-DETR, RT-DETR and classifiers Stretch, DETR Keep shape and pad
Scaling 0 to 1, ImageNet, 0 to 255, BGR Scores stay low or classes are nonsense. Ultralytics models use 0 to 1, DETR, RF-DETR and most classifiers ImageNet, YOLOX 0 to 255, BGR
Input width, Input height 32 to 2048, in steps of 32 Only for a model without a fixed size. Larger finds smaller objects and takes longer

A wrong fit gives no error, only worse boxes. Check the result on the live video.