Welcome to DOFBOT-Pi repository
8. Model Conversion
Model Conversion
Note: If using the docker container from the factory image, you don't need to rebuild the environment. The environment is already set up, you just need to enter the docker according to the previous tutorial and run the corresponding function commands to use it.
1. Raspberry Pi 5 YOLO11 (Benchmark)
YOLO11 benchmark data source from Ultralytics team, testing various model formats (data for reference only)
Official benchmark testing was only performed on YOLO11n and YOLO11s models, because other models are too large to run on Raspberry Pis and cannot provide good performance.

2. Model Conversion
The jetson nano mainboard docker cannot perform conversion because PyTorch/ultralytics dependencies are too new and CPU/GPU instruction sets are incompatible. You can first export TensorRT/ONNX on Raspberry Pi or PC, then run on Jetson Nano:
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 YOLO11's export mode, it will automatically install some dependencies, just wait for the automatic completion!
2.1 CLI: pt → onnx, pt → ncnn
Convert PyTorch format models to onnx and ncnn
xxxxxxxxxxcd ~/ultralytics/ultralytics/
Run the following commands in terminal:
xyolo export model=yolo11n.pt format=onnx# yolo export model=yolo11n-seg.pt format=onnx# yolo export model=yolo11n-pose.pt format=onnx# yolo export model=yolo11n-cls.pt format=onnx# yolo export model=yolo11n-obb.pt format=onnxyolo export model=yolo11n.pt format=ncnn# yolo export model=yolo11n-seg.pt format=ncnn# yolo export model=yolo11n-pose.pt format=ncnn# yolo export model=yolo11n-cls.pt format=ncnn# yolo export model=yolo11n-obb.pt format=ncnn

2.2 Python: pt → onnx → ncnn
Convert PyTorch format models to TensorRT: The conversion process will automatically generate ONNX models
xxxxxxxxxxcd ~/ultralytics/ultralytics/yahboom_demo
xxxxxxxxxxpython3 model_pt_onnx_ncnn.py

Example code:
xxxxxxxxxxfrom ultralytics import YOLO# Load a YOLO11n PyTorch modelmodel = YOLO("/root/ultralytics/ultralytics/yolo11n.pt")# model = YOLO("/root/ultralytics/ultralytics/yolo11n-seg.pt")# model = YOLO("/root/ultralytics/ultralytics/yolo11n-pose.pt")# model = YOLO("/root/ultralytics/ultralytics/yolo11n-cls.pt")# model = YOLO("/root/ultralytics/ultralytics/yolo11n-obb.pt")# Export the model to ONNX formatmodel.export(format="onnx") # This will create 'yolo11n.onnx' in the same directory# Export the model to NCNN formatmodel.export(format="ncnn") # creates 'yolo11n_ncnn_model'3. Model Prediction
CLI Usage
CLI currently only supports calling USB cameras!
xxxxxxxxxxcd ~/ultralytics/ultralytics/
xxxxxxxxxxyolo predict model=yolo11n.onnx source=0 save=False show

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