快速入门指南:在 Raspberry Pi 上使用 Ultralytics YOLO26
Raspberry Pi 是一款小巧实惠的计算机,无需 GPU 即可运行 Ultralytics YOLO26,在边缘端实时执行目标检测。本指南将带你了解如何在 Raspberry Pi 4 和 5 上部署 YOLO26:刷写操作系统、安装 Ultralytics、导出为 NCNN 以在 ARM 上实现最快的推理,以及对实时摄像头画面运行预测。本指南还提供八种导出格式的性能基准测试,帮助你根据硬件选择速度与精度之间的最佳平衡。
跳转至设置 Ultralytics、导出为 NCNN 并运行推理、基准测试或摄像头推理。
观看: Raspberry Pi 5 更新与改进
本指南已在运行最新 Raspberry Pi OS Bookworm (Debian 12) 的 Raspberry Pi 4 和 Raspberry Pi 5 上测试。只要安装相同的 Raspberry Pi OS Bookworm,本指南预计也适用于 Raspberry Pi 3 等较旧的 Raspberry Pi 设备。
什么是 Raspberry Pi?#
Raspberry Pi 是一款小巧实惠的单板计算机。它在各种项目和应用中广受欢迎,从爱好者的家庭自动化到工业用途均有涉及。Raspberry Pi 板卡可以运行各种操作系统,并提供 GPIO(通用输入/输出)引脚,方便与传感器、执行器和其他硬件组件集成。Raspberry Pi 有多种规格各异的型号,但它们都秉持相同的基本设计理念:低成本、小巧且用途广泛。
Raspberry Pi 系列对比#
| Raspberry Pi 3 | Raspberry Pi 4 | Raspberry Pi 5 | |
|---|---|---|---|
| CPU | Broadcom BCM2837、Cortex-A53 64Bit SoC | Broadcom BCM2711、Cortex-A72 64Bit SoC | Broadcom BCM2712、Cortex-A76 64Bit SoC |
| CPU 最高频率 | 1.4GHz | 1.8GHz | 2.4GHz |
| GPU | VideoCore IV | VideoCore VI | VideoCore VII |
| GPU 最高频率 | 400MHz | 500MHz | 800MHz |
| 内存 | 1GB LPDDR2 SDRAM | 1GB、2GB、4GB、8GB LPDDR4-3200 SDRAM | 2GB、4GB、8GB、16GB LPDDR4X-4267 SDRAM |
| PCIe | 不适用 | 不适用 | 1xPCIe 2.0 接口 |
| 最大功耗 | 2.5A@5V | 3A@5V | 5A@5V(启用 PD) |
什么是 Raspberry Pi OS?#
Raspberry Pi OS(以前称为 Raspbian)是一个类 Unix 操作系统,基于 Debian GNU/Linux 发行版,面向 Raspberry Pi Foundation 发布的 Raspberry Pi 系列紧凑型单板计算机。Raspberry Pi OS 针对配备 ARM CPU 的 Raspberry Pi 进行了高度优化,并采用轻量级桌面环境;在 Raspberry Pi 4 和 5 上默认使用 Wayland 运行。Raspberry Pi OS 目前仍在积极开发,重点是在 Raspberry Pi 上尽可能提升 Debian 软件包的稳定性和性能。
将 Raspberry Pi OS 刷写到 Raspberry Pi#
拿到 Raspberry Pi 后,首先要做的是将 Raspberry Pi OS 刷写到 micro-SD 卡中,将卡插入设备,然后启动操作系统。请按照 Raspberry Pi 入门文档中的详细说明,为首次使用做好设备准备。
设置 Ultralytics#
你可以通过两种方式在 Raspberry Pi 上设置 Ultralytics 包,以用于接下来的计算机视觉项目:
从 Docker 开始#
在 Raspberry Pi 上快速开始使用 Ultralytics YOLO26 的方法,是运行适用于 Raspberry Pi 的预构建 Docker 镜像。
运行以下命令以拉取 Docker 容器并在 Raspberry Pi 上运行。此容器基于官方 Python 3.13-slim 镜像,该镜像在最新的 Debian 版本上运行 Python 3.13。
t=ultralytics/ultralytics:latest-arm64
sudo docker pull $t && sudo docker run -it --ipc=host $tDocker 镜像已包含 Ultralytics,因此你可以直接将模型导出为 NCNN。
不使用 Docker 开始#
安装 Ultralytics 包#
这里将在 Raspberry Pi 上安装 Ultralytics 包。导出为 NCNN 等格式所需的依赖项,会在你首次导出 PyTorch 模型时自动安装,因此这里只需安装基础包。
-
更新软件包列表、安装 pip 并升级到最新版本
sudo apt update sudo apt install python3-pip -y pip install -U pip -
安装
ultralyticspip 包pip install ultralytics -
重启设备
sudo reboot
在 Raspberry Pi 上使用 NCNN#
在 Ultralytics 支持的所有模型导出格式中,NCNN在 Raspberry Pi 设备上的推理性能最佳,因为它针对 ARM 等移动和嵌入式平台进行了高度优化。将你的 YOLO26n PyTorch 模型转换为 NCNN,然后使用导出的模型运行推理:
from ultralytics import YOLO
# 加载 YOLO26n PyTorch 模型
model = YOLO("yolo26n.pt")
# 将模型导出为 NCNN 格式
model.export(format="ncnn") # creates 'yolo26n_ncnn_model'
# 加载导出的 NCNN 模型
ncnn_model = YOLO("yolo26n_ncnn_model")
# 运行推理
results = ncnn_model("https://ultralytics.com/images/bus.jpg")如需了解支持的导出选项详情,请参阅模型部署选项指南。
YOLO26 相较于 YOLO11 的性能提升#
YOLO26 专为 Raspberry Pi 5 等硬件资源受限的设备设计。在 Raspberry Pi 5 上,使用 ONNX 导出的模型且输入尺寸为 640 时,与 YOLO11n 相比,YOLO26n 的 FPS 提升约 ~15%(6.79 → 7.79),同时精度也更高(40.1 对 39.5)。下表和图表展示了这一对比。
| 模型 | mAP50-95(B) | 推理时间 (ms/im) |
|---|---|---|
| YOLO26n | 40.1 | 128.42 |
| YOLO26s | 47.8 | 352.84 |
| YOLO26m | 52.5 | 993.78 |
| YOLO26l | 54.4 | 1259.46 |
| YOLO26x | 56.9 | 2636.26 |
使用 Ultralytics 8.4.14 进行基准测试。
Raspberry Pi 5 YOLO26 基准测试#
Ultralytics 团队对 YOLO26 进行了基准测试,测量其在八种不同模型格式下的速度和精度:PyTorch、TorchScript、ONNX、OpenVINO、LiteRT、MNN、NCNN、ExecuTorch。测试在 Raspberry Pi 5 上以 FP32 精度进行,默认输入图像尺寸为 640。
对比图表#
这里只包含 YOLO26n 和 YOLO26s,因为更大的模型在 Raspberry Pi 上运行过慢,不适合实际使用。
详细对比表#
下表展示了两种不同模型(YOLO26n、YOLO26s)在 Raspberry Pi 5 上运行时,采用八种不同格式(PyTorch、TorchScript、ONNX、OpenVINO、LiteRT、MNN、NCNN、ExecuTorch)的基准测试结果,包括每种组合的状态、大小、mAP50-95(B) 指标和推理时间。
| 格式 | 状态 | 磁盘占用大小 (MB) | mAP50-95(B) | 推理时间 (ms/im) |
|---|---|---|---|---|
| PyTorch | ✅ | 5.3 | 0.4760 | 299.09 |
| TorchScript | ✅ | 9.8 | 0.4734 | 353.20 |
| ONNX | ✅ | 9.5 | 0.4734 | 125.99 |
| OpenVINO | ✅ | 9.6 | 0.4734 | 104.55 |
| LiteRT | ✅ | 9.8 | 0.4730 | 123.30 |
| MNN | ✅ | 9.4 | 0.4749 | 91.87 |
| NCNN | ✅ | 9.4 | 0.4784 | 67.03 |
| ExecuTorch | ✅ | 9.4 | 0.4772 | 144.83 |
使用 Ultralytics 8.4.108 进行基准测试
推理时间不包括预处理和后处理。
复现我们的结果#
如需在所有导出格式下复现上述 Ultralytics 基准测试,请运行以下代码:
from ultralytics import YOLO
# 加载 YOLO26n PyTorch 模型
model = YOLO("yolo26n.pt")
# 在 COCO128 数据集上对 YOLO26n 的所有导出格式进行速度和精度基准测试
results = model.benchmark(data="coco128.yaml", imgsz=640)请注意,基准测试结果可能因系统的具体硬件和软件配置,以及运行基准测试时系统的当前负载而有所不同。为获得最可靠的结果,请使用包含大量图像的数据集,例如 data='coco.yaml'(5000 张验证图像)。
format=litert 导出(通过 litert-torch)仅支持 Linux x86_64 和 macOS,不支持直接在 Raspberry Pi 上进行。请在 Linux x86_64 计算机或 Mac 上导出 .tflite 模型,将其复制到 Raspberry Pi,然后在 Pi 上进行推理。
使用 Raspberry Pi 摄像头#
Raspberry Pi 上的计算机视觉项目通常需要实时视频流来进行推理。Raspberry Pi 上的 MIPI CSI 接口可用于连接官方 Raspberry Pi 摄像头模块。本指南使用 Raspberry Pi Camera Module 3获取视频流,并使用 YOLO26 模型执行推理。
Raspberry Pi 5 使用的 CSI 接口比 Raspberry Pi 4 更小(22 针对比 15 针),因此你需要一根 15 针转 22 针适配线来连接 Raspberry Pi 摄像头。
测试摄像头#
将摄像头连接到 Raspberry Pi 后,执行以下 rpicam-hello 命令。你应该会看到摄像头的实时视频流,持续约 5 秒。
rpicam-hello使用摄像头进行推理#
使用 Raspberry Pi 摄像头对 YOLO26 模型运行推理有两种方法。
使用 Raspberry Pi OS 预装的 picamera2 访问摄像头,并对 YOLO26 模型运行推理。
import cv2
from picamera2 import Picamera2
from ultralytics import YOLO
# 初始化 Picamera2
picam2 = Picamera2()
picam2.preview_configuration.main.size = (1280, 720)
picam2.preview_configuration.main.format = "RGB888"
picam2.preview_configuration.align()
picam2.configure("preview")
picam2.start()
# 加载 YOLO26 模型
model = YOLO("yolo26n.pt")
while True:
# 逐帧捕获
frame = picam2.capture_array()
# 对帧运行 YOLO26 推理
results = model(frame)
# 可视化该帧上的结果
annotated_frame = results[0].plot()
# 显示处理后的帧
cv2.imshow("Camera", annotated_frame)
# 如果按下 'q',则退出循环
if cv2.waitKey(1) == ord("q"):
break
# 释放资源并关闭窗口
cv2.destroyAllWindows()使用 Raspberry Pi 的最佳实践#
遵循以下最佳实践,充分发挥 YOLO26 在 Raspberry Pi 上的性能。
-
使用 SSD
如果需要 24/7 持续运行,请使用 SSD 作为系统盘,因为 SD 卡在持续写入时可能会磨损或损坏。Raspberry Pi 5 配有板载 PCIe 接口,你可以使用 NVMe Base for Raspberry Pi 5 等适配器连接 SSD。
-
不安装图形界面进行刷写
刷写 Raspberry Pi OS 时,你可以选择不安装桌面环境(Raspberry Pi OS Lite),这样可以节省一些设备内存,为计算机视觉处理留出更多空间。
-
对 Raspberry Pi 进行超频
如果你想在 Raspberry Pi 5 上运行 Ultralytics YOLO26 模型时稍微提升性能,可以将 CPU 从基础频率 2.4GHz 超频至 3.0GHz,并将 GPU 从 800MHz 超频至 1GHz。如果系统变得不稳定或崩溃,请以每次 100MHz 的幅度降低超频值。确保配备适当的散热,因为超频会增加热量,可能导致热降频。
a. 升级软件
sudo apt update && sudo apt dist-upgradeb. 打开配置文件进行编辑
sudo nano /boot/firmware/config.txtc. 在文件末尾添加以下几行
arm_freq=3000 gpu_freq=1000 force_turbo=1d. 按 CTRL + X,然后按 Y,再按 ENTER 保存并退出
e. 重启 Raspberry Pi
后续步骤#
你已成功在 Raspberry Pi 上设置 YOLO26。接下来,你可以探索预测模式以了解更多推理选项,探索导出模式以了解其他部署格式;如果你需要更强的边缘计算能力,也可以查看 NVIDIA Jetson 指南。完整文档请访问 Ultralytics YOLO26 文档。
致谢与引用#
本指南最初由 Daan Eeltink 为 Kashmir World Foundation 编写。该组织致力于使用 YOLO 保护濒危物种。我们感谢他们在目标检测技术领域的开创性工作和对教育的重视。
如需了解 Kashmir World Foundation 的更多活动信息,请访问其网站。
常见问题#
按照以下步骤,在不使用 Docker 的情况下于 Raspberry Pi 上设置 Ultralytics YOLO26:
- 更新软件包列表并安装
pip:sudo apt update sudo apt install python3-pip -y pip install -U pip - 安装 Ultralytics 包:
pip install ultralytics - 重启设备以应用更改:
sudo reboot
详细说明请参阅不使用 Docker 开始部分。
- 更新软件包列表并安装
NCNN 针对移动和嵌入式平台进行了高度优化,因此非常适合在 Raspberry Pi 设备上运行 YOLO26。与上方的基准测试中的其他导出格式相比,其针对 ARM 优化的内核可在 Pi 上实现更快的推理。
你可以使用 Python 或 CLI 命令将 PyTorch YOLO26 模型转换为 NCNN 格式:
示例from ultralytics import YOLO # 加载 YOLO26n PyTorch 模型 model = YOLO("yolo26n.pt") # 将模型导出为 NCNN 格式 model.export(format="ncnn") # creates 'yolo26n_ncnn_model' # 加载导出的 NCNN 模型 ncnn_model = YOLO("yolo26n_ncnn_model") # 运行推理 results = ncnn_model("https://ultralytics.com/images/bus.jpg")详情请参阅在 Raspberry Pi 上使用 NCNN部分。
主要差异包括:
- CPU:Raspberry Pi 4 使用 Broadcom BCM2711、Cortex-A72 64 位 SoC;Raspberry Pi 5 使用 Broadcom BCM2712、Cortex-A76 64 位 SoC。
- CPU 最高频率:Raspberry Pi 4 的最高频率为 1.8GHz,而 Raspberry Pi 5 可达 2.4GHz。
- 内存:Raspberry Pi 4 提供最高 8GB 的 LPDDR4-3200 SDRAM,而 Raspberry Pi 5 配备 LPDDR4X-4267 SDRAM,提供 2GB、4GB、8GB 和 16GB 版本。
这些改进使 YOLO26 模型在 Raspberry Pi 5 上的性能基准优于 Raspberry Pi 4。更多详情请参阅 Raspberry Pi 系列对比表格。
设置 Raspberry Pi Camera 以运行 YOLO26 推理有两种方法:
-
使用
picamera2:import cv2 from picamera2 import Picamera2 from ultralytics import YOLO picam2 = Picamera2() picam2.preview_configuration.main.size = (1280, 720) picam2.preview_configuration.main.format = "RGB888" picam2.preview_configuration.align() picam2.configure("preview") picam2.start() model = YOLO("yolo26n.pt") while True: frame = picam2.capture_array() results = model(frame) annotated_frame = results[0].plot() cv2.imshow("Camera", annotated_frame) if cv2.waitKey(1) == ord("q"): break cv2.destroyAllWindows() -
使用 TCP 流:
rpicam-vid -n -t 0 --inline --listen -o tcp://127.0.0.1:8888from ultralytics import YOLO model = YOLO("yolo26n.pt") results = model("tcp://127.0.0.1:8888")
有关详细设置说明,请参阅摄像头推理部分。
-
评论134
提出问题、分享结果,或帮助其他人。
smhty
Works great on Raspberry Pi 5. A tutorial for the AI kit that comes with Raspberry Pi 5 would be great as well: https://www.raspberrypi.com/products/ai-kit/
1
Glenn JocherUltralytics(已编辑)Hi there!
Thank you for your feedback and for sharing your positive experience on the Raspberry Pi 5! 😊
Creating a tutorial for the AI kit that comes with the Raspberry Pi 5 is a fantastic idea. In the meantime, you can refer to our comprehensive Quick Start Guide for Raspberry Pi with Ultralytics YOLO26, which provides detailed instructions on setting up and running YOLO on Raspberry Pi devices, including performance benchmarks.
For those interested in using the AI kit, the setup process should be quite similar. Here’s a quick overview to get you started:
-
Flash Raspberry Pi OS: Ensure you have the latest Raspberry Pi OS Bookworm (Debian 12) installed. Follow the Getting Started Documentation by Raspberry Pi to prepare your device.
-
Set Up Ultralytics:
- With Docker:
t=ultralytics/ultralytics:latest-arm64 && sudo docker pull $t && sudo docker run -it --ipc=host $t - Without Docker:
sudo apt update sudo apt install python3-pip -y pip install -U pip pip install ultralytics[export] sudo reboot
- With Docker:
-
Use NCNN for Best Performance: Convert your YOLO26 model to NCNN format for optimal performance on Raspberry Pi:
from ultralytics import YOLO # Load a YOLO26n PyTorch model model = YOLO("yolo26n.pt") # Export the model to NCNN format model.export(format="ncnn") # creates 'yolo26n_ncnn_model' # Load the exported NCNN model ncnn_model = YOLO("yolo26n_ncnn_model") # Run inference results = ncnn_model("https://ultralytics.com/images/bus.jpg") -
Using the Raspberry Pi Camera: For real-time video feeds, you can use the
picamera2library or set up a TCP stream:-
Using
picamera2:import cv2 from picamera2 import Picamera2 from ultralytics import YOLO picam2 = Picamera2() picam2.preview_configuration.main.size = (1280, 720) picam2.preview_configuration.main.format = "RGB888" picam2.preview_configuration.align() picam2.configure("preview") picam2.start() model = YOLO("yolo26n.pt") while True: frame = picam2.capture_array() results = model(frame) annotated_frame = results[0].plot() cv2.imshow("Camera", annotated_frame) if cv2.waitKey(1) == ord("q"): break cv2.destroyAllWindows() -
Using TCP Stream:
rpicam-vid -n -t 0 --inline --listen -o tcp://127.0.0.1:8888from ultralytics import YOLO model = YOLO("yolo26n.pt") results = model("tcp://127.0.0.1:8888")
-
We hope this helps you get started with the AI kit on your Raspberry Pi 5. For more detailed instructions and additional resources, please visit our Raspberry Pi Guide.
Happy coding! 🚀
-
wnelis
Today I've installed module ultralytics on a Raspberry Pi 4 with 4 [GiB] memory running Trixie. Some remarks about what I've learned: . Use the 64-bit variant of Raspberry OS; . Use an microSD card of at least 32 [GiB]; . Disable /tmp becoming a file system in memory (tmpfs):
sudo systemctl mask tmp.mount; . OpenCV is installed using apt, module ultralytics is installed in a virtual Python environment: 'python -m venv --system-site-packages `.It is found that YOLO runs into a hardware error: "Illegal instruction". This can be reproduced by using the Python script shown above to export the model in NCNN format. The output is:
Downloading https://github.com/ultralyti…: 100% ━━━━━━━━━━━━ 5.3MB 1.4MB/s 3.8s Ultralytics 8.4.191 🚀 Python-3.13.5 torch-2.14.1+cu130 CPU (aarch64) Illegal instruction
How can this issue be solved?
Paula DerrengerUltralytics@wnelis the most likely cause is a native PyTorch binary using instructions unsupported by the Pi 4’s CPU, rather than faulty hardware; similar crashes are documented in Ultralytics #19091 and upstream PyTorch, although your exact version is not confirmed affected. (github.com) Your log shows a CUDA build (
+cu130); first replace it with the matching official CPU-only packages inside your activated virtual environment, then retry the export: (pytorch.org)python -m pip install --force-reinstall torch==2.14.1 torchvision==0.29.1 --index-url https://download.pytorch.org/whl/cpuIf it still crashes, please share the text output of
yolo checksandpython -m pip show torch torchvisionfrom that same environment so we can identify package/path conflicts.
hm-zeroone(已编辑)
"We haven’t validated Orbit OS yet, but if it supports tflite or onnx runtimes you should be able to deploy an exported Ultralytics YOLO26 model there using Export mode and the deployment options guide; if you try it, please share the exact device, export format, and any text error logs here in Discussions so the Ultralytics team can take a look."
Hi @glenn-jocher,
I added a new feature to my Orbit OS app to test YOLO models directly on edge devices, in this case a Raspberry Pi. The app now allows adding new models, and by default includes YOLO v8, v11 and v26.
We also introduced a benchmark mode, where you can select an image and run all models to compare performance and results.
In the example shown in the image, YOLOv8 achieved the highest number of correct object detections by time.
This demo video shows the remote deployment, no SSH, no Docker, of the app in action on Raspberry Pi 5 vs Arduino UNO Q and a comparison (“VS”) between the RPi 5 and UNO Q running YOLO v8. https://youtu.be/aiFJmosYVAI?si=v3Jo_TbswU3n-sZU
Glenn JocherUltralyticsThanks for sharing the Orbit OS benchmark; for a fair cross-model comparison please include the exact export/runtime backend,
imgsz, confidence/IoU thresholds, and per-image latency/FPS, since on Raspberry Pi CPU deployments NCNN is usually the best baseline for YOLO26.hm-zeroone(已编辑)
Hey! Thanks for the feedback. All models were tested under the same conditions — TFlite runtime, same image, same thresholds (conf=0.50, IoU=0.45), same imgsz 640×640 with letterbox preprocessing.
Everything runs through the OrbitOS SDK which currently has TFLite and ONNX embedded. NCNN is something we'll look into adding in a future release.
Quick question — for RPi deployments, would you recommend INT8 or float16 as the default export format?
Orbit OS SDK 26.0.1 Inference example.
Orbit OS is multi-language — For now only Go SDK is available, Python, Java and C++ SDKs are coming soon.
model, _ := device.AIManager.UploadAndLoadModel( "yolo8n", "models/yolo26n_float16.tflite", aiv26.ModelBackend_TFLITE, aiv26.ExecutionMode_EXEC_HIGH_THREADS, ) resp, _ := model.Infer(ctx, tensor.Data, tensor.Shape, tensor.Dtype) fmt.Println(resp.GetOutputShape()) // [1 84 8400] fmt.Println(resp.GetLatencyUs()) // e.g. 528000
Glenn JocherUltralytics(已编辑)For plain Raspberry Pi CPU deployment with
LiteRT(.tflite), I’d usually default toINT8for the best speed and memory savings, and usefloat16only if quantization hurts accuracy too much or your runtime performs better with FP kernels; if you benchmark both, the LiteRT export guide is the right reference, while our Raspberry Pi guide showsNCNNas the strongest baseline once you add that backend.1
safdarhamid64-cpu
when i write in raspberry pi terminal : from ultralytics import yolo error msg illegal instruction pops up , i have trained model and even i have first created environment and installed pip install ultralytics but still i am not able to run model yolo11n on my Raspberry Pi 4 , Guide me plzz
Glenn JocherUltralyticsThat
Illegal instructionon Raspberry Pi usually means an incompatible binary wheel (most oftentorch/numpypulled for the wrong arch/OS), and also note the correct import isfrom ultralytics import YOLO(capitalized), notyolo; please paste the text output ofyolo checksplus the full traceback here in this discussion, and confirmuname -m+ whether you’re on Raspberry Pi OS Bookworm 64-bit as in the Raspberry Pi YOLO26 guide; as a quick way to rule out env issues you can also try our ARM64 Docker flow from that guide:```bash t=ultralytics/ultralytics:latest-arm64 sudo docker pull $t && sudo docker run -it --ipc=host $t python -c "from ultralytics import YOLO; YOLO('yolo11n.pt')"
inuropix
Hi.. I get an error when implement botsort with reid is True and the model is ncnn(exported from yolo26n-cls.pt)
Here’s the full traceback from the error:
self.tracks = self.model.track( ^^^^^^^^^^^^^^^^^ File "/home/sbr/people_counting/lib/python3.11/site-packages/ultralytics/engine/model.py", line 579, in track return self.predict(source=source, stream=stream, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/sbr/people_counting/lib/python3.11/site-packages/ultralytics/engine/model.py", line 536, in predict return self.predictor.predict_cli(source=source) if is_cli else self.predictor(source=source, stream=stream) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/sbr/people_counting/lib/python3.11/site-packages/ultralytics/engine/predictor.py", line 225, in __call__ return list(self.stream_inference(source, model, *args, **kwargs)) # merge list of Results into one ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/sbr/people_counting/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 40, in generator_context response = gen.send(None) ^^^^^^^^^^^^^^ File "/home/sbr/people_counting/lib/python3.11/site-packages/ultralytics/engine/predictor.py", line 338, in stream_inference self.run_callbacks("on_predict_postprocess_end") File "/home/sbr/people_counting/lib/python3.11/site-packages/ultralytics/engine/predictor.py", line 509, in run_callbacks callback(self) File "/home/sbr/people_counting/lib/python3.11/site-packages/ultralytics/trackers/track.py", line 93, in on_predict_postprocess_end tracks = tracker.update(det, result.orig_img, getattr(result, "feats", None)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/sbr/people_counting/lib/python3.11/site-packages/ultralytics/trackers/byte_tracker.py", line 361, in update dists = self.get_dists(unconfirmed, detections) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/sbr/people_counting/lib/python3.11/site-packages/ultralytics/trackers/bot_sort.py", line 220, in get_dists emb_dists = matching.embedding_distance(tracks, detections) / 2.0 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/sbr/people_counting/lib/python3.11/site-packages/ultralytics/trackers/utils/matching.py", line 128, in embedding_distance cost_matrix = np.maximum(0.0, cdist(track_features, det_features, metric)) # Normalized features ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/sbr/people_counting/lib/python3.11/site-packages/scipy/spatial/distance.py", line 2903, in cdist raise ValueError('XA must be a 2-dimensional array.') ValueError: XA must be a 2-dimensional array.Any idea?
Glenn JocherUltralyticsThat traceback usually means BoT-SORT didn’t get valid (2D) ReID embeddings; also note that
.track()should run with a Detect/Seg/Pose model, whileyolo26n-clsis only meant to be the ReID feature extractor configured insidebotsort.yaml(viawith_reid/model). (docs.ultralytics.com)yolo track model=yolo26n.pt source=path/to/video.mp4 tracker="botsort.yaml"# in a copy of botsort.yaml with_reid: True model: yolo26n-cls.pt # first confirm this works before swapping to an exported backendIf you just need stable tracking on Raspberry Pi, try
tracker="bytetrack.yaml"(no ReID); if you still hit this, please paste yourbotsort.yamland the output ofyolo checksso we can reproduce from the same environment. (docs.ultralytics.com)
hananabuzainab
I can't install ultralytics on rasspbery pi 5...with python 3.11 version,why??
I used: pip install ultralytics
How can i fix this problem ??
Glenn JocherUltralyticsCan you paste the full
pip install ultralyticserror text (as text, not a screenshot) and the output ofpython3 -Vhere so we can pinpoint what’s failing? On Raspberry Pi 5 this is most often a Python/pip mismatch or non-Bookworm/32-bit setup—please also confirm you’re on Raspberry Pi OS Bookworm 64-bit as in the Raspberry Pi with Ultralytics YOLO26 guide.python3 -V python3 -m pip install -U pip setuptools wheel python3 -m venv .venv source .venv/bin/activate python -m pip install -U pip python -m pip install ultralytics
avasanjesh
Hi,
I want to use python version of raspberry pi 32 bit OS. can you please tell me if i can export yolo detection model in 32 bit raspberry pi?
Edward-YS
Hello,I'm wondering if there is Benchmarking Results of Two Different Models (YOLO8n, YOLO8s) Across Ten Formats: PyTorch, TF, ONNX, OpenVINO, TF SavedModel, TF GraphDef, TF Lite, PaddlePaddle, MNN, NCNN.
zyt2011
Installing a single Hailo-5 is sufficient.
发件人: Beautifulboy111 @.> 发送时间: 2025年4月22日 14:24 收件人: ultralytics/ultralytics @.> 抄送: zyt2011 @.>; Mention @.> 主题: Re: [ultralytics/ultralytics] zh/guides/raspberry-pi/ (Discussion #19489)
Why does my Raspberry Pi 5 have a high inference latency of 150ms when using NCNN for video recognition, even after overclocking? How can I reduce the inference time?
― Reply to this email directly, view it on GitHubhttps://github.com/orgs/ultralytics/discussions/19489#discussioncomment-12906311, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BJ7DFR53TAD7QVJNO3TTXJL22XOAJAVCNFSM6AAAAABYEEJCHCVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTEOJQGYZTCMI. You are receiving this because you were mentioned.Message ID: @.***>
Glenn JocherUltralytics(已编辑)@Beautifulboy111 150ms inference latency with NCNN on Raspberry Pi 5 is higher than expected. Here are some steps to reduce it:
-
Use a smaller YOLO26 model - our benchmarks show YOLO26n is significantly faster than YOLO26s with NCNN on Pi 5 (67ms vs 173ms)
-
Reduce input resolution - try 320x320 instead of 640x640, which can cut inference time by up to 70%
-
Optimize memory allocation by running without GUI (Raspberry Pi OS Lite)
-
Ensure you're using proper cooling for sustained performance when overclocked
-
Consider processing at lower FPS if your application allows it
Regarding @zyt2011's suggestion, while accelerators like Hailo can boost performance, they're a separate investment. I'd recommend optimizing your current setup first using the techniques in our Raspberry Pi guide.
What's your specific use case? This would help us provide more targeted optimization advice.
-
Beautifulboy111
Why does my Raspberry Pi 5 have a high inference latency of 150ms when using NCNN for video recognition, even after overclocking? How can I reduce the inference time?