Welcome to DOFBOT-Ultra repository
8. Model Conversion
Model Conversion
Please ensure that the web control program backend process is not running in the background. To close it, refer to the [Get Started Quickly - 2. Access the Terminal] section in [Disable the Auto-Start Web Control Backend Process]. After closing, please restart DofbotUltra!!!
Model Conversion1. Raspberry Pi 5 YOLO26 (Benchmark)2. Model Conversion2.1. CLI: pt → onnx, pt → ncnn2.2. Python: pt → onnx → ncnn4. Model PredictionCLI UsageReferences
1. Raspberry Pi 5 YOLO26 (Benchmark)
YOLO26 benchmark data is sourced from the Ultralytics team, testing models in various formats (data for reference only).
The official benchmarks only cover YOLO26n and YOLO26s models, as other model sizes are too large to run on Raspberry Pis and do not provide good performance.

2. Model Conversion
According to the test parameters provided by the Ultralytics team for different model formats, we can find that using TensorRT for inference provides the best performance!
The first time you use YOLO26's export mode, it will automatically install some dependencies. Please wait for it to complete!
2.1. CLI: pt → onnx, pt → ncnn
Convert PyTorch format models to onnx and ncnn.
xxxxxxxxxxcd /home/pi/ultralytics/ultralytics
xyolo export model=yolo26n.pt format=onnx# yolo export model=yolo26n-seg.pt format=onnx# yolo export model=yolo26n-pose.pt format=onnx# yolo export model=yolo26n-cls.pt format=onnx# yolo export model=yolo26n-obb.pt format=onnxyolo export model=yolo26n.pt format=ncnn# yolo export model=yolo26n-seg.pt format=ncnn# yolo export model=yolo26n-pose.pt format=ncnn# yolo export model=yolo26n-cls.pt format=ncnn# yolo export model=yolo26n-obb.pt format=ncnn


2.2. Python: pt → onnx → ncnn
Convert PyTorch format models: The conversion process will automatically generate an ONNX model.
xxxxxxxxxxcd /home/pi/ultralytics/ultralytics/yahboom_demo_26
xxxxxxxxxxpython3 model_pt_onnx_ncnn.py
xxxxxxxxxxfrom ultralytics import YOLO
# Load a YOLO26n PyTorch modelmodel = YOLO("/home/pi/ultralytics/ultralytics/yolo26n.pt")# model = YOLO("/home/pi/ultralytics/ultralytics/yolo26n-seg.pt")# model = YOLO("/home/pi/ultralytics/ultralytics/yolo26n-pose.pt")# model = YOLO("/home/pi/ultralytics/ultralytics/yolo26n-cls.pt")# model = YOLO("/home/pi/ultralytics/ultralytics/yolo26n-obb.pt")
# Export the model to ONNX formatmodel.export(format="onnx") # This will create 'yolo26n.onnx' in the same directory
# Export the model to NCNN formatmodel.export(format="ncnn") # creates 'yolo26n_ncnn_model'Note: The converted model files are located in the same directory as the original model file.

4. Model Prediction
CLI Usage
Currently, CLI only supports USB cameras. For CSI cameras, users can directly modify the Python code above to use onnx and ncnn models.
xxxxxxxxxxcd /home/pi/ultralytics/ultralytics
xxxxxxxxxxyolo predict model=yolo26n.onnx source=0 save=False show

xxxxxxxxxxyolo predict model=yolo26n_ncnn_model source=0 save=False show
