Bắt đầu

Hướng dẫn bắt đầu nhanh: Raspberry Pi với Ultralytics YOLO26

Raspberry Pi là máy tính nhỏ gọn, giá phải chăng, chạy Ultralytics YOLO26 để phát hiện đối tượng theo thời gian thực ở biên — không cần GPU. Hướng dẫn này chỉ cách triển khai YOLO26 trên Raspberry Pi 4 và 5: flash hệ điều hành, cài đặt Ultralytics, export sang NCNN để đạt tốc độ suy luận nhanh nhất trên ARM và chạy dự đoán trên luồng camera trực tiếp. Hướng dẫn cũng bao gồm benchmark hiệu năng trên tám định dạng export để bạn chọn sự cân bằng tốt nhất giữa tốc độ và độ chính xác cho phần cứng của mình.

Chuyển đến phần thiết lập Ultralytics, xuất sang NCNN và chạy suy luận, benchmark hoặc suy luận bằng camera.



Xem: Các bản cập nhật và cải tiến dành cho Raspberry Pi 5.
Lưu ý

Hướng dẫn này đã được kiểm thử trên Raspberry Pi 4 và Raspberry Pi 5 chạy phiên bản mới nhất của Raspberry Pi OS Bookworm (Debian 12). Hướng dẫn dự kiến cũng hoạt động trên các thiết bị Raspberry Pi đời cũ như Raspberry Pi 3, miễn là đã cài cùng Raspberry Pi OS Bookworm.

Raspberry Pi là gì?#

Raspberry Pi là máy tính bo mạch đơn nhỏ gọn, giá phải chăng. Thiết bị này trở nên phổ biến trong nhiều dự án và ứng dụng, từ tự động hóa nhà ở theo sở thích đến các ứng dụng công nghiệp. Bo mạch Raspberry Pi có thể chạy nhiều hệ điều hành và cung cấp các chân GPIO (Đầu vào/Đầu ra đa dụng), cho phép dễ dàng tích hợp với cảm biến, bộ truyền động và các thành phần phần cứng khác. Raspberry Pi có nhiều model với thông số kỹ thuật khác nhau, nhưng đều tuân theo triết lý thiết kế cơ bản: giá thấp, nhỏ gọn và linh hoạt.

So sánh các dòng Raspberry Pi#

Raspberry Pi 3Raspberry Pi 4Raspberry Pi 5
CPUBroadcom BCM2837, SoC 64 bit Cortex-A53Broadcom BCM2711, SoC 64 bit Cortex-A72Broadcom BCM2712, SoC 64 bit Cortex-A76
Tần số tối đa của CPU1.4GHz1.8GHz2.4GHz
GPUVideoCore IVVideoCore VIVideoCore VII
Tần số tối đa của GPU400MHz500MHz800MHz
Bộ nhớ1GB LPDDR2 SDRAM1GB, 2GB, 4GB, 8GB LPDDR4-3200 SDRAM2GB, 4GB, 8GB, 16GB LPDDR4X-4267 SDRAM
PCIeKhông áp dụngKhông áp dụngGiao diện PCIe 2.0 1x
Mức tiêu thụ điện tối đa2.5A@5V3A@5V5A@5V (bật PD)

Raspberry Pi OS là gì?#

Raspberry Pi OS (trước đây có tên là Raspbian) là một hệ điều hành kiểu Unix dựa trên bản phân phối Debian GNU/Linux dành cho dòng máy tính bo mạch đơn nhỏ gọn Raspberry Pi do Raspberry Pi Foundation phân phối. Raspberry Pi OS được tối ưu hóa cao cho Raspberry Pi dùng CPU ARM và sử dụng môi trường desktop nhẹ, mặc định chạy trên Wayland ở Raspberry Pi 4 và 5. Raspberry Pi OS đang được phát triển tích cực, tập trung cải thiện độ ổn định và hiệu năng của nhiều gói Debian nhất có thể trên Raspberry Pi.

Flash Raspberry Pi OS vào Raspberry Pi#

Việc đầu tiên cần làm sau khi có Raspberry Pi là flash thẻ micro-SD bằng Raspberry Pi OS, lắp thẻ vào thiết bị rồi khởi động hệ điều hành. Làm theo Tài liệu bắt đầu sử dụng của Raspberry Pi để chuẩn bị thiết bị cho lần sử dụng đầu tiên.

Thiết lập Ultralytics#

Bạn có thể thiết lập package Ultralytics trên Raspberry Pi theo hai cách cho dự án Thị giác máy tính tiếp theo:

Bắt đầu với Docker#

Cách nhanh nhất để bắt đầu sử dụng Ultralytics YOLO26 trên Raspberry Pi là chạy image Docker được dựng sẵn cho Raspberry Pi.

Chạy lệnh bên dưới để tải Docker container và chạy trên Raspberry Pi. Image này dựa trên image Python 3.13-slim chính thức, chạy Python 3.13 trên bản Debian mới nhất.

t=ultralytics/ultralytics:latest-arm64
sudo docker pull $t && sudo docker run -it --ipc=host $t

Image Docker đã bao gồm Ultralytics, vì vậy bạn có thể bắt đầu ngay với thao tác export model sang NCNN.

Bắt đầu không dùng Docker#

Cài đặt package Ultralytics#

Tại đây, chúng ta sẽ cài package Ultralytics trên Raspberry Pi. Các dependency để export sang những định dạng như NCNN sẽ được tự động cài đặt vào lần đầu tiên bạn export model PyTorch, vì vậy ở đây chỉ cần cài package cơ bản.

  1. Cập nhật danh sách package, cài đặt pip và nâng cấp lên phiên bản mới nhất

    sudo apt update
    sudo apt install python3-pip -y
    pip install -U pip
  2. Cài đặt package pip ultralytics

    pip install ultralytics
  3. Khởi động lại thiết bị

    sudo reboot

Sử dụng NCNN trên Raspberry Pi#

Trong tất cả định dạng export được Ultralytics hỗ trợ, NCNN mang lại hiệu năng suy luận tốt nhất trên thiết bị Raspberry Pi vì được tối ưu cao cho các nền tảng di động và nhúng như ARM. Chuyển model PyTorch YOLO26n sang NCNN, sau đó chạy suy luận bằng model đã export:

Ví dụ
from ultralytics import YOLO

# Tải model YOLO26n PyTorch
model = YOLO("yolo26n.pt")

# Export model sang định dạng NCNN
model.export(format="ncnn")  # creates 'yolo26n_ncnn_model'

# Tải model NCNN đã export
ncnn_model = YOLO("yolo26n_ncnn_model")

# Chạy suy luận
results = ncnn_model("https://ultralytics.com/images/bus.jpg")
Mẹo

Để biết thêm chi tiết về các tùy chọn export được hỗ trợ, hãy xem hướng dẫn về các tùy chọn triển khai model.

Cải thiện hiệu năng của YOLO26 so với YOLO11#

YOLO26 được thiết kế đặc biệt để chạy trên các thiết bị có tài nguyên phần cứng hạn chế như Raspberry Pi 5. So với YOLO11n, YOLO26n tăng ~15% FPS (6.79 → 7.79), đồng thời đạt mAP cao hơn (40.1 so với 39.5) ở kích thước đầu vào 640 với model export ONNX trên Raspberry Pi 5. Bảng và biểu đồ bên dưới minh họa kết quả so sánh này.

YOLO26 benchmarks on RPi 5
Được benchmark bằng Ultralytics 8.4.14
Hiệu năng
ModelmAP50-95(B)Thời gian suy luận (ms/ảnh)
YOLO26n40.1128.42
YOLO26s47.8352.84
YOLO26m52.5993.78
YOLO26l54.41259.46
YOLO26x56.92636.26

Được benchmark bằng Ultralytics 8.4.14.

Benchmark YOLO26 trên Raspberry Pi 5#

Nhóm Ultralytics đã chạy benchmark YOLO26 trên tám định dạng model khác nhau để đo tốc độ và độ chính xác: PyTorch, TorchScript, ONNX, OpenVINO, LiteRT, MNN, NCNN, ExecuTorch. Các benchmark được chạy trên Raspberry Pi 5 với độ chính xác FP32 và kích thước ảnh đầu vào mặc định là 640.

Biểu đồ so sánh#

Chỉ bao gồm YOLO26n và YOLO26s vì các model lớn hơn chạy quá chậm trên Raspberry Pi, không phù hợp để sử dụng thực tế.

YOLO26 benchmarks on RPi 5
Được benchmark bằng Ultralytics 8.4.108

Bảng so sánh chi tiết#

Bảng dưới đây trình bày kết quả benchmark của hai model khác nhau (YOLO26n, YOLO26s) trên tám định dạng khác nhau (PyTorch, TorchScript, ONNX, OpenVINO, LiteRT, MNN, NCNN, ExecuTorch), chạy trên Raspberry Pi 5, bao gồm trạng thái, kích thước, metric mAP50-95(B) và thời gian suy luận cho từng tổ hợp.

Hiệu năng
Định dạngTrạng tháiDung lượng trên ổ đĩa (MB)mAP50-95(B)Thời gian suy luận (ms/ảnh)
PyTorch✅5.30.4760299.09
TorchScript✅9.80.4734353.20
ONNX✅9.50.4734125.99
OpenVINO✅9.60.4734104.55
LiteRT✅9.80.4730123.30
MNN✅9.40.474991.87
NCNN✅9.40.478467.03
ExecuTorch✅9.40.4772144.83

Được benchmark bằng Ultralytics 8.4.108

Lưu ý

Thời gian suy luận không bao gồm tiền xử lý/hậu xử lý.

Tái tạo kết quả của chúng tôi#

Để tái tạo các benchmark Ultralytics ở trên trên tất cả định dạng export, hãy chạy đoạn code này:

Ví dụ
from ultralytics import YOLO

# Tải model YOLO26n PyTorch
model = YOLO("yolo26n.pt")

# Benchmark tốc độ và độ chính xác của YOLO26n trên tập dữ liệu COCO128 cho tất cả định dạng xuất
results = model.benchmark(data="coco128.yaml", imgsz=640)

Lưu ý rằng kết quả benchmark có thể thay đổi tùy theo cấu hình phần cứng và phần mềm cụ thể của hệ thống, cũng như khối lượng công việc hiện tại của hệ thống tại thời điểm chạy benchmark. Để có kết quả đáng tin cậy nhất, hãy sử dụng tập dữ liệu có nhiều ảnh, ví dụ: data='coco.yaml' (5000 ảnh val).

Quá trình export LiteRT chạy trên thiết bị khác

Quá trình export format=litert (thông qua litert-torch) chỉ được hỗ trợ trên Linux x86_64 và macOS, không hỗ trợ trực tiếp trên Raspberry Pi. Export model .tflite trên máy Linux x86_64 hoặc Mac, sao chép sang Raspberry Pi rồi dùng Pi để chạy suy luận.

Sử dụng camera Raspberry Pi#

Các dự án thị giác máy tính trên Raspberry Pi thường cần luồng video thời gian thực để suy luận. Đầu nối MIPI CSI tích hợp trên Raspberry Pi cho phép kết nối các module camera Raspberry Pi chính hãng. Trong hướng dẫn này, chúng tôi sử dụng Raspberry Pi Camera Module 3 để thu luồng video và thực hiện suy luận bằng các model YOLO26.

Mẹo
Lưu ý

Raspberry Pi 5 sử dụng đầu nối CSI nhỏ hơn Raspberry Pi 4 (22 chân so với 15 chân), vì vậy bạn sẽ cần cáp chuyển đổi 15 chân sang 22 chân để kết nối camera Raspberry Pi.

Kiểm tra camera#

Sau khi kết nối camera với Raspberry Pi, hãy chạy lệnh rpicam-hello sau. Bạn sẽ thấy luồng video trực tiếp từ camera trong khoảng 5 giây.

rpicam-hello

Suy luận bằng camera#

Có hai phương pháp sử dụng camera Raspberry Pi để chạy suy luận trên các model YOLO26.

Chạy suy luận bằng camera Raspberry Pi

Dùng picamera2, được cài đặt sẵn cùng Raspberry Pi OS, để truy cập camera và chạy suy luận trên các model YOLO26.

Ví dụ
import cv2
from picamera2 import Picamera2

from ultralytics import YOLO

# Khởi tạo 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()

# Tải model YOLO26
model = YOLO("yolo26n.pt")

while True:
    # Chụp từng frame
    frame = picam2.capture_array()

    # Chạy suy luận YOLO26 trên frame
    results = model(frame)

    # # Trực quan hóa kết quả trên frame
    annotated_frame = results[0].plot()

    # Hiển thị frame kết quả
    cv2.imshow("Camera", annotated_frame)

    # # Thoát vòng lặp nếu nhấn 'q'
    if cv2.waitKey(1) == ord("q"):
        break

# Giải phóng tài nguyên và đóng cửa sổ
cv2.destroyAllWindows()

Các phương pháp hay nhất khi sử dụng Raspberry Pi#

Hãy áp dụng các phương pháp tối ưu sau để đạt hiệu năng tối đa từ YOLO26 trên Raspberry Pi.

  1. Sử dụng SSD

    Để vận hành liên tục 24/7, hãy dùng SSD cho hệ thống vì thẻ SD có thể bị hao mòn hoặc hỏng do ghi liên tục. Với đầu nối PCIe tích hợp trên Raspberry Pi 5, bạn có thể kết nối SSD bằng adapter như NVMe Base cho Raspberry Pi 5.

  2. Flash không có GUI

    Khi flash Raspberry Pi OS, bạn có thể chọn không cài môi trường Desktop (Raspberry Pi OS Lite) để tiết kiệm một phần RAM trên thiết bị, dành thêm dung lượng cho xử lý thị giác máy tính.

  3. Ép xung Raspberry Pi

    Nếu muốn tăng nhẹ hiệu năng khi chạy các model Ultralytics YOLO26 trên Raspberry Pi 5, bạn có thể ép xung CPU từ mức cơ bản 2.4GHz lên 3.0GHz và GPU từ 800MHz lên 1GHz. Nếu hệ thống hoạt động không ổn định hoặc gặp sự cố, hãy giảm mức ép xung theo từng bước 100MHz. Đảm bảo hệ thống được làm mát phù hợp, vì ép xung làm tăng nhiệt lượng và có thể gây giảm xung do nhiệt.

    a. Nâng cấp phần mềm

    sudo apt update && sudo apt dist-upgrade

    b. Mở để chỉnh sửa file cấu hình

    sudo nano /boot/firmware/config.txt

    c. Thêm các dòng sau vào cuối file

    arm_freq=3000
    gpu_freq=1000
    force_turbo=1

    d. Lưu và thoát bằng cách nhấn CTRL + X, sau đó nhấn Y rồi ENTER

    e. Khởi động lại Raspberry Pi

Các bước tiếp theo#

Bạn đã thiết lập thành công YOLO26 trên Raspberry Pi. Để tìm hiểu thêm, hãy khám phá chế độ Predict để biết thêm tùy chọn suy luận, chế độ Export để xem các định dạng triển khai bổ sung, hoặc hướng dẫn NVIDIA Jetson nếu bạn cần thêm năng lực tính toán ở biên. Truy cập Tài liệu Ultralytics YOLO26 để xem toàn bộ tài liệu.

Lời cảm ơn và trích dẫn#

Hướng dẫn này ban đầu được Daan Eeltink biên soạn cho Kashmir World Foundation, một tổ chức chuyên ứng dụng YOLO vào công tác bảo tồn các loài có nguy cơ tuyệt chủng. Chúng tôi ghi nhận những đóng góp tiên phong và trọng tâm giáo dục của tổ chức trong lĩnh vực công nghệ phát hiện đối tượng.

Để biết thêm thông tin về hoạt động của Kashmir World Foundation, bạn có thể truy cập website của tổ chức.

Câu hỏi thường gặp#

  • Để thiết lập Ultralytics YOLO26 trên Raspberry Pi mà không dùng Docker, hãy làm theo các bước sau:

    1. Cập nhật danh sách package và cài đặt pip:
      sudo apt update
      sudo apt install python3-pip -y
      pip install -U pip
    2. Cài đặt package Ultralytics:
      pip install ultralytics
    3. Khởi động lại thiết bị để áp dụng các thay đổi:
      sudo reboot

    Để biết hướng dẫn chi tiết, hãy tham khảo phần Bắt đầu không dùng Docker.

  • NCNN được tối ưu cao cho nền tảng di động và nhúng, là lựa chọn phù hợp để chạy YOLO26 trên thiết bị Raspberry Pi. Các kernel được tối ưu cho ARM mang lại tốc độ suy luận trên Pi cao hơn những định dạng xuất khác trong các benchmark ở trên.

  • Bạn có thể chuyển đổi model YOLO26 PyTorch sang định dạng NCNN bằng lệnh Python hoặc CLI:

    Ví dụ
    from ultralytics import YOLO
    
    # Tải model YOLO26n PyTorch
    model = YOLO("yolo26n.pt")
    
    # Export model sang định dạng NCNN
    model.export(format="ncnn")  # creates 'yolo26n_ncnn_model'
    
    # Tải model NCNN đã export
    ncnn_model = YOLO("yolo26n_ncnn_model")
    
    # Chạy suy luận
    results = ncnn_model("https://ultralytics.com/images/bus.jpg")

    Để biết thêm chi tiết, hãy xem phần Sử dụng NCNN trên Raspberry Pi.

  • Các khác biệt chính bao gồm:

    • CPU: Raspberry Pi 4 sử dụng SoC Broadcom BCM2711, Cortex-A72 64-bit, trong khi Raspberry Pi 5 sử dụng SoC Broadcom BCM2712, Cortex-A76 64-bit.
    • Tần số CPU tối đa: Raspberry Pi 4 có tần số tối đa 1.8GHz, trong khi Raspberry Pi 5 đạt 2.4GHz.
    • Bộ nhớ: Raspberry Pi 4 cung cấp tối đa 8GB SDRAM LPDDR4-3200, trong khi Raspberry Pi 5 có SDRAM LPDDR4X-4267, với các phiên bản 2GB, 4GB, 8GB và 16GB.

    Những cải tiến này giúp các model YOLO26 đạt kết quả benchmark hiệu năng tốt hơn trên Raspberry Pi 5 so với Raspberry Pi 4. Tham khảo bảng So sánh các dòng Raspberry Pi để biết thêm chi tiết.

  • Có hai phương pháp thiết lập Raspberry Pi Camera để suy luận với YOLO26:

    1. Sử dụng 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()
    2. Sử dụng luồng TCP:

      rpicam-vid -n -t 0 --inline --listen -o tcp://127.0.0.1:8888
      from ultralytics import YOLO
      
      model = YOLO("yolo26n.pt")
      results = model("tcp://127.0.0.1:8888")

    Để xem hướng dẫn thiết lập chi tiết, hãy truy cập mục Suy luận bằng camera.

Bình luận134

Đặt câu hỏi, chia sẻ kết quả hoặc giúp đỡ người khác.

    1. Glenn JocherUltralytics(đã chỉnh sửa)

      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:

      1. 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.

      2. 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
      3. 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")
      4. Using the Raspberry Pi Camera: For real-time video feeds, you can use the picamera2 library 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:8888
          from 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! 🚀

  1. wnelisGitHub

    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?

    1. 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/cpu

      If it still crashes, please share the text output of yolo checks and python -m pip show torch torchvision from that same environment so we can identify package/path conflicts.

  2. hm-zerooneGitHub(đã chỉnh sửa)

    "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.

    localhost_9005_ (1)

    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

    1. Glenn JocherUltralytics

      Thanks 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.

    2. hm-zerooneGitHub(đã chỉnh sửa)

      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.

      image

      
      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
    3. Glenn JocherUltralytics(đã chỉnh sửa)

      For plain Raspberry Pi CPU deployment with LiteRT (.tflite), I’d usually default to INT8 for the best speed and memory savings, and use float16 only 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 shows NCNN as the strongest baseline once you add that backend.

      1
  3. safdarhamid64-cpuGitHub

    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

    1. Glenn JocherUltralytics

      That Illegal instruction on Raspberry Pi usually means an incompatible binary wheel (most often torch/numpy pulled for the wrong arch/OS), and also note the correct import is from ultralytics import YOLO (capitalized), not yolo; please paste the text output of yolo checks plus the full traceback here in this discussion, and confirm uname -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')"

  4. inuropixGitHub

    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?

    1. Glenn JocherUltralytics

      That traceback usually means BoT-SORT didn’t get valid (2D) ReID embeddings; also note that .track() should run with a Detect/Seg/Pose model, while yolo26n-cls is only meant to be the ReID feature extractor configured inside botsort.yaml (via with_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 backend

      If you just need stable tracking on Raspberry Pi, try tracker="bytetrack.yaml" (no ReID); if you still hit this, please paste your botsort.yaml and the output of yolo checks so we can reproduce from the same environment. (docs.ultralytics.com)

  5. hananabuzainabGitHub

    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 ??

    1. Glenn JocherUltralytics

      Can you paste the full pip install ultralytics error text (as text, not a screenshot) and the output of python3 -V here 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
  6. avasanjeshGitHub

    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?

  7. Edward-YSGitHub

    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.

  8. zyt2011GitHub

    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: @.***>

    1. Glenn JocherUltralytics(đã chỉnh sửa)

      @Beautifulboy111 150ms inference latency with NCNN on Raspberry Pi 5 is higher than expected. Here are some steps to reduce it:

      1. Use a smaller YOLO26 model - our benchmarks show YOLO26n is significantly faster than YOLO26s with NCNN on Pi 5 (67ms vs 173ms)

      2. Reduce input resolution - try 320x320 instead of 640x640, which can cut inference time by up to 70%

      3. Optimize memory allocation by running without GUI (Raspberry Pi OS Lite)

      4. Ensure you're using proper cooling for sustained performance when overclocked

      5. 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.

  9. Beautifulboy111GitHub

    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?