Bắt đầu

Export Intel OpenVINO

OpenVINO là bộ công cụ mã nguồn mở của Intel để tối ưu hóa và chạy suy luận AI. Xuất model Ultralytics YOLO26 bằng format="openvino" sẽ tạo thư mục yolo26n_openvino_model/ chứa model OpenVINO IR (các file .xml và .bin) dành cho CPU Intel, GPU Intel tích hợp và rời, cùng NPU Intel, với độ chính xác FP32, FP16 hoặc INT8.

Tổng quan nhanh#

Thuộc tínhChi tiết
Đối số formatopenvino
Đầu rayolo26n_openvino_model/, một thư mục chứa yolo26n.xml, yolo26n.bin và metadata.yaml; yolo26n_int8_openvino_model/ cho một bản xuất quantize=8
Chạy trênCPU Intel, GPU Intel tích hợp và rời, cùng NPU Intel. Thiết bị CPU cũng chạy trên các bộ xử lý x86-64 và ARM64 khác, chẳng hạn như AMD và silicon của Apple
RuntimeOpenVINO Runtime 2024.0.0 trở lên (package Python openvino)
PrecisionFP32, FP16, INT8. YOLO26n có dung lượng 10.1 MB ở FP32, 5.3 MB ở FP16 và 3.3 MB ở INT8
Máy exportLinux, macOS hoặc Windows. Quá trình xuất chạy trên CPU và không cần GPU
Export trên cloud

Ultralytics Platform có thể xuất model đã huấn luyện sang OpenVINO cho bạn, vì vậy bạn không cần môi trường xuất cục bộ.

Bắt đầu nhanh#

Cài package Ultralytics cùng các dependency để xuất OpenVINO:

pip install "ultralytics[export-openvino]"

Lệnh này cài đặt openvino và, trên Python 3.9 trở lên, nncf để lượng tử hóa INT8. Với pip install ultralytics thông thường, lần xuất đầu tiên sẽ cài đặt các package còn thiếu. Quá trình xuất có các yêu cầu phiên bản sau:

PackagePhiên bản yêu cầu
torch2.1 trở lên
openvino2024.0.0 trở lên; 2025.2.0 trở lên trên macOS 15.4 trở lên
nncf2.14.0 trở lên, chỉ dành cho quantize=8; thấp hơn 3.0.0 khi PyTorch thấp hơn 2.3

Để xem các phương thức cài đặt khác, hãy tham khảo hướng dẫn cài đặt. Sau đó xuất model và tải thư mục đã xuất để chạy suy luận hoặc xác thực độ chính xác. Khóa học OpenVINO trên CPU hướng dẫn các bước tương tự.

Export
from ultralytics import YOLO

# Nạp model YOLO26
model = YOLO("yolo26n.pt")

# Export model sang định dạng OpenVINO
model.export(format="openvino")  # creates 'yolo26n_openvino_model/'

# # Xuất model OpenVINO được lượng tử hóa INT8 bằng dữ liệu hiệu chuẩn
model.export(format="openvino", quantize=8, data="coco8.yaml")  # creates 'yolo26n_int8_openvino_model/'
Dự đoán
from ultralytics import YOLO

# Tải model OpenVINO đã export
model = YOLO("yolo26n_openvino_model/")

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

# # Chạy suy luận trên GPU Intel; dùng "npu" cho NPU Intel hoặc "cpu" cho CPU
results = model("https://ultralytics.com/images/bus.jpg", device="xpu")
Xác thực
from ultralytics import YOLO

# Tải model OpenVINO đã export
model = YOLO("yolo26n_openvino_model/")

# # Đánh giá độ chính xác trên bộ dữ liệu COCO8
metrics = model.val(data="coco8.yaml")

Các tác vụ được hỗ trợ#

Xuất OpenVINO hỗ trợ cả bảy tác vụ Ultralytics với các model YOLOv8, YOLO11 và YOLO26: phát hiện, phân đoạn, phân đoạn ngữ nghĩa, ước tính độ sâu, phân loại, ước tính tư thế và OBB. Phân đoạn ngữ nghĩa và ước tính độ sâu chỉ có trên YOLO26, dòng model duy nhất có các head này.

Các tham số xuất model#

Đối sốKiểuMặc địnhMô tả
formatstr'openvino'Định dạng đích của model đã xuất, xác định khả năng tương thích với nhiều môi trường triển khai.
imgszint hoặc tuple640Kích thước ảnh đầu vào của model: số nguyên đối với ảnh vuông hoặc tuple (height, width). Nếu không truyền giá trị, quá trình export sẽ dùng kích thước mà checkpoint đã được huấn luyện. Các checkpoint YOLO26 chính thức dùng 640 cho detect, segment, pose và model semantic được pretrained trên ADE20K, 1024 cho OBB và model semantic được pretrained trên Cityscapes, 768 cho depth và 224 cho classify.
quantizeint hoặc strNoneĐộ chính xác lượng tử hóa: 16 (FP16: trọng số được lưu ở độ chính xác một nửa, đầu vào và đầu ra vẫn là FP32) hoặc 8 (lượng tử hóa sau huấn luyện INT8 bằng NNCF với ảnh hiệu chuẩn từ data, được ghi vào thư mục _int8_openvino_model/); 32/không đặt là FP32. Không thể xuất checkpoint được huấn luyện bằng quantize=8 sang OpenVINO; xem Giới hạn và khắc phục sự cố. Thay thế các cờ half/int8 đã lỗi thời.
datastrNoneFile YAML của dataset dùng để hiệu chuẩn INT8; với phân loại, thay vào đó cần thư mục dataset hoặc tên dataset tích hợp sẵn. Hiệu chuẩn dùng split val trừ khi đặt split. Nếu không cung cấp quantize=8, Ultralytics dùng dataset mặc định nhỏ cho tác vụ của model, chẳng hạn coco8.yaml cho phát hiện.
fractionfloat, int hoặc list1.0Tập con hiệu chuẩn dưới dạng tỷ lệ, số lượng ảnh hoặc tỷ lệ/số lượng [train, val, test]. Danh sách gồm hai mục giữ test ở dạng đầy đủ, còn 0 sẽ bỏ qua mục này.
dynamicboolFalseĐặt batch, chiều cao và chiều rộng của đầu vào ở dạng động để một model có thể nhận các kích thước batch và ảnh khác nhau. Trên NPU Intel, model động vẫn chạy ở imgsz khi xuất; xem Triển khai.
nmsbool, không bắt buộcNoneChọn đầu ra thô (None, mặc định), NMS nhúng (True) hoặc head không dùng NMS (False). Xem định dạng đầu ra.
batchint1Kích thước batch của model đã xuất. Với bản xuất tĩnh, kích thước batch này được cố định trong shape đầu vào. Đây cũng là kích thước batch dùng cho hiệu chuẩn INT8.
devicestrNoneQuá trình xuất luôn chạy trên CPU. Với quantize=8, device=npu chọn activation INT8 đối xứng cho các model YOLO phát hiện, phân đoạn, tư thế và OBB, giúp chạy nhanh hơn tới 2 lần trên NPU Intel.

Để biết các đối số dùng chung cho mọi định dạng, hãy xem tài liệu chế độ Export.

Lượng tử hóa INT8#

quantize=8 áp dụng lượng tử hóa sau huấn luyện bằng NNCF: quá trình xuất đưa ảnh hiệu chuẩn qua model và lưu trọng số cùng activation dưới dạng số nguyên 8-bit khi có thể.

  • Dữ liệu hiệu chuẩn: quá trình xuất hiệu chuẩn trên mọi batch đầy đủ thuộc split val của data, hoặc split được đặt bằng split. Dùng fraction để giới hạn số ảnh. Quá trình xuất sẽ cảnh báo nếu có dưới 300 ảnh.
  • Head phát hiện: với các model có head phát hiện YOLO (phát hiện, phân đoạn, tư thế và OBB) và RT-DETR, các phép toán giải mã đầu ra của head (đổi shape, nối, giải mã box và DFL) cùng mọi phép toán sigmoid vẫn dùng số thực dấu phẩy động, trong khi các phép tích chập của head được lượng tử hóa. Model phân loại, phân đoạn ngữ nghĩa và độ sâu không có phép toán nào bị loại trừ.
  • Đầu vào và đầu ra: model INT8 giữ nguyên đầu vào float32 và các đầu ra của model FP32, vì vậy mã suy luận được viết cho model FP32 có thể chạy mà không cần chỉnh sửa.
  • NPU Intel: thêm device=npu vào bản xuất INT8 dự định chạy trên NPU Intel. Tùy chọn này chuyển các model YOLO phát hiện, phân đoạn, tư thế và OBB từ lượng tử hóa activation bất đối xứng sang đối xứng.
Ví dụ
from ultralytics import YOLO

model = YOLO("yolo26n.pt")

# Hiệu chuẩn trên 10% số ảnh validation COCO (500 ảnh); thay coco.yaml bằng dataset của riêng bạn
model.export(format="openvino", quantize=8, data="coco.yaml", fraction=0.1)

# # Tải model INT8 đã xuất và chạy suy luận
model = YOLO("yolo26n_int8_openvino_model/")
results = model("https://ultralytics.com/images/bus.jpg")

Trong các phép đo benchmark, model INT8 chạy nhanh hơn FP32 từ 1.02 đến 1.33 lần trên CPU máy chủ và giảm 0.5 đến 0.9 mAP trên COCO val2017. Trên CPU Intel Core Ultra, INT8 chạy nhanh hơn FP32 từ 1.2 đến 3.8 lần. Hãy xác thực model INT8 trên dữ liệu của bạn trước khi triển khai.

Định dạng đầu ra#

Quá trình xuất ghi một thư mục chứa ba file:

FileNội dung
yolo26n.xmlĐồ thị mạng ở định dạng OpenVINO IR
yolo26n.binTrọng số
metadata.yamlTên lớp, tác vụ, kích thước ảnh, kích thước batch, stride và các tham số xuất mà Ultralytics đọc khi tải model

Model nhận một đầu vào có shape (batch, 3, height, width), RGB và được scale về khoảng 0-1. Đầu vào và đầu ra là float32 trong các model FP32, FP16 và INT8, ngoại trừ đầu ra phân đoạn ngữ nghĩa là bản đồ lớp uint8 (int32 với model có hơn 256 lớp). Tensor không mang tên images và output0 như trong bản xuất ONNX, vì vậy hãy truy cập đầu vào và đầu ra theo chỉ mục trong mã của bạn.

Các shape đầu ra giống với bản xuất ONNX và phụ thuộc vào tác vụ cùng tham số nms: model phát hiện YOLO26n được xuất tại imgsz=640 trả về (1, 84, 8400) với nms=None mặc định và (1, 300, 6) với nms=False hoặc nms=True. Xem định dạng đầu ra ONNX để biết shape và nội dung của từng tác vụ. Với nms=True, ngưỡng confidence conf (mặc định là 0.25), ngưỡng IoU iou, agnostic_nms và max_det được cố định trong đồ thị khi xuất. Giá trị conf thấp hơn trong lúc dự đoán hoặc xác thực không thể khôi phục các detection đã bị đồ thị loại bỏ, vì vậy hãy xuất lại để thay đổi các giá trị này.

Triển khai#

YOLO("yolo26n_openvino_model/") chạy model bằng OpenVINO Runtime và ánh xạ tham số device sang thiết bị OpenVINO:

deviceThiết bị OpenVINO
để trốngAUTO, cho phép OpenVINO chọn giữa CPU và GPU Intel (danh sách ưu tiên mặc định không bao gồm NPU), hoặc CPU khi CPU là thiết bị duy nhất OpenVINO tìm thấy
cpuCPU
xpu hoặc xpu:0GPU hoặc GPU.0, GPU Intel tích hợp hoặc rời. xpu:1 chọn GPU.1 trên máy có hai GPU Intel
npuNPU, bộ xử lý thần kinh của các bộ xử lý Intel Core Ultra

Các giá trị khác, chẳng hạn 0 hoặc mps, được xử lý như khi không đặt device. Các tên cũ intel:cpu, intel:gpu và intel:npu vẫn hoạt động và ghi nhật ký cảnh báo ngừng sử dụng. Bảng thiết bị suy luận so sánh các tên này giữa các định dạng. Dòng nhật ký Using OpenVINO LATENCY mode for batch=1 inference on CPU... cho biết tên thiết bị mà OpenVINO báo cáo khi tải model. Với AUTO, thiết bị này có thể là CPU trong khi GPU Intel vẫn đang biên dịch model, vì vậy hãy đặt device để bảo đảm chọn đúng thiết bị. Với model .pt, device="xpu" chọn backend GPU Intel của PyTorch thay thế; đây cũng là thiết bị dùng để huấn luyện trên GPU Intel, còn device="npu" chọn NPU Huawei Ascend, không phải NPU Intel.

Hành vi khi suy luận phụ thuộc vào cách xuất model:

  • Xuất tĩnh (mặc định): model luôn chạy ở imgsz và batch khi xuất; Ultralytics đọc các giá trị này từ metadata.yaml. Giá trị imgsz được truyền vào predict sẽ bị bỏ qua. Batch lớn hơn được chia thành các phần theo kích thước batch lúc xuất, còn batch nhỏ hơn được đệm, vì vậy có thể xử lý số lượng ảnh bất kỳ.
  • Xuất động (dynamic=True): predict chấp nhận các kích thước batch khác nhau và mọi giá trị imgsz là bội số của stride model. NPU Intel và model INT8 trên CPU Intel AMX là các trường hợp ngoại lệ; xem Giới hạn và khắc phục sự cố.
  • Chế độ độ trễ: Ultralytics biên dịch model với gợi ý hiệu năng OpenVINO LATENCY và chạy suy luận đồng bộ. Để phục vụ nhiều yêu cầu song song với gợi ý THROUGHPUT, hãy dùng OpenVINO Runtime API như hướng dẫn trong tài liệu về độ trễ và thông lượng.
  • NPU Intel: Ultralytics biên dịch model cho batch size 1 trên NPU và chia batch lớn hơn thành các ảnh đơn. Trên NPU, bản xuất động bị cố định ở imgsz lúc xuất.

Chạy bằng OpenVINO Runtime API#

Để chạy model bên ngoài package Ultralytics, hãy tải file .xml bằng package openvino. Model yêu cầu ảnh đã tiền xử lý và trả về đầu ra thô được mô tả trong Định dạng đầu ra, vì vậy mã của bạn cần tự xử lý letterbox và, với bản xuất mặc định, NMS:

# # Export first: yolo export model=yolo26n.pt format=openvino nms=False
import numpy as np
import openvino as ov
import yaml

core = ov.Core()
model = core.read_model("yolo26n_openvino_model/yolo26n.xml")
compiled = core.compile_model(model, "AUTO")  # # or "CPU", "GPU", "NPU"

image = np.zeros((1, 3, 640, 640), dtype=np.float32)  # # your preprocessed image: RGB, NCHW, 0-1
detections = compiled(image)[0][0]  # # first output, first image: shape (300, 6)
detections = detections[detections[:, 4] > 0.25]  # giữ các hàng vượt ngưỡng độ tin cậy

with open("yolo26n_openvino_model/metadata.yaml") as f:
    names = yaml.safe_load(f)["names"]  # {0: 'person', 1: 'bicycle', ...}

Hướng dẫn triển khai#

Giới hạn và khắc phục sự cố#

  • Phiên bản PyTorch: quá trình xuất thất bại với OpenVINO export requires torch>=2.1 trên các phiên bản PyTorch cũ.
  • macOS 15.4 trở lên: OpenVINO 2025.1.0 trở xuống không chạy được trên các phiên bản macOS này, vì vậy quá trình xuất yêu cầu openvino>=2025.2.0 trên các phiên bản đó và cập nhật package cũ hơn.
  • Checkpoint được huấn luyện bằng quantize=8: checkpoint được tinh chỉnh bằng huấn luyện nhận biết lượng tử hóa sẽ không xuất được với format='openvino' cannot export a QAT model: its Q/DQ ranges are only read by the 'onnx' and 'engine' backends. Thay vào đó, hãy xuất checkpoint ban đầu dùng để tinh chỉnh bằng quantize=8, hoặc xuất checkpoint đã tinh chỉnh sang ONNX hoặc TensorRT.
  • Xuất INT8 không có data: quá trình xuất ghi nhật ký INT8 export requires a missing 'data' arg for calibration. Using default 'data=coco8.yaml'. và hiệu chuẩn trên dataset mặc định nhỏ cho tác vụ đó. Hãy truyền data cùng các ảnh đại diện cho dữ liệu triển khai của bạn.
  • Kích thước hiệu chuẩn INT8: quá trình xuất ghi nhật ký >300 images recommended for INT8 calibration, found 4 images. khi split hiệu chuẩn có dưới 300 ảnh. coco8.yaml chỉ có 4 ảnh xác thực, đủ để kiểm tra quá trình xuất nhưng không đủ để hiệu chuẩn model dùng trong triển khai.
  • Thư mục đầu ra: mỗi lần xuất cùng một checkpoint, ngoại trừ INT8, đều ghi vào cùng thư mục yolo26n_openvino_model/, bất kể quantize, imgsz, dynamic, nms hay batch, vì vậy lần xuất sau sẽ thay thế lần trước. Mọi bản xuất INT8, có hoặc không có device=npu, đều dùng chung yolo26n_int8_openvino_model/.
  • Thiết bị không khả dụng: khi thiết bị được yêu cầu không có sẵn, Ultralytics ghi nhật ký OpenVINO device 'GPU' not available. Using 'AUTO' instead. (hoặc Using 'CPU' instead. trên máy mà OpenVINO chỉ tìm thấy CPU) rồi tiếp tục chạy trên thiết bị đó. Hãy kiểm tra xem bộ xử lý của bạn có được OpenVINO hỗ trợ hay không và cài driver GPU hoặc NPU của Intel.
  • NPU Intel: Ultralytics chạy NPU với batch size 1 và shape đầu vào cố định; xem Triển khai. Truyền device=npu để sử dụng NPU: nếu không đặt device, NPU sẽ không được chọn.
  • Shape động với NMS: bản xuất có dynamic=True và nms=True sẽ ghi nhật ký 'dynamic=True' export requires a maximum batch size, e.g. 'batch=16'. khi batch được giữ ở giá trị 1. Ultralytics chạy batch lớn hơn theo từng phần có kích thước batch lúc xuất.
  • Model INT8 động trên CPU Intel AMX: trên Linux với CPU hỗ trợ AMX (Intel Sapphire Rapids trở lên), Ultralytics chạy model INT8 động trên thiết bị CPU hoặc AUTO ở imgsz lúc xuất, giống như với model tĩnh: giá trị imgsz được truyền vào predict hoặc val sẽ bị bỏ qua, còn val dùng batch lúc xuất. predict vẫn chấp nhận các kích thước batch khác và biên dịch lại model cho mỗi kích thước batch mới, vì vậy lần suy luận đầu tiên với kích thước batch mới sẽ chậm hơn.
  • Windows: trên Windows, Ultralytics đặt gợi ý độ chính xác suy luận CPU thành FP32, ngăn OpenVINO sử dụng các kernel dấu phẩy động có độ chính xác thấp hơn (model INT8 vẫn chạy ở INT8), đồng thời giới hạn oneDNN ở các tập lệnh thấp hơn AMX. Hãy đặt biến môi trường ONEDNN_MAX_CPU_ISA trước khi tải model để dùng giới hạn khác.
  • Linux trên ARM64: Ultralytics chạy thiết bị CPU ở chế độ thực thi ưu tiên độ chính xác của OpenVINO với độ chính xác suy luận FP32.
  • NMS tích hợp: nms=True gây ra 'nms=True' is not valid for classification models. với tác vụ phân loại và bị bỏ qua kèm cảnh báo với model phân đoạn ngữ nghĩa và ước tính độ sâu ('nms=True' is not valid for semantic models. Forcing 'nms=None'.), cũng như model RT-DETR ('nms=True' is not available for end2end models or non-YOLO heads. Forcing 'nms=None'.).
  • Head không dùng NMS: nms=False yêu cầu model có head không dùng NMS, chẳng hạn YOLO26 hoặc YOLOv10. Với các model khác, ví dụ YOLO11, quá trình export sẽ cảnh báo This model has no one-to-one head; using one-to-many outputs. và ghi đầu ra thô (1, 84, 8400).

Đối với các lỗi khác, hãy xem hướng dẫn về các sự cố thường gặp.

Benchmark YOLO26 với OpenVINO#

Các bảng dưới đây so sánh PyTorch với model OpenVINO FP32, FP16 và INT8 cho mọi model phát hiện YOLO26. Bộ kết quả đầu tiên được đo trên CPU máy chủ với độ chính xác trên COCO val2017; bộ thứ hai được đo trên ba bộ xử lý Intel Core Ultra bằng CPU và GPU, cùng NPU của hai bộ xử lý trong số đó. Trang model YOLO26 liệt kê độ chính xác, tốc độ ONNX trên CPU và tốc độ TensorRT trên T4 của từng model.

FP32, FP16 và INT8 trên CPU máy chủ#

Mọi giá trị trong phần này được đo trên CPU của một máy chủ có hai bộ xử lý AMD EPYC 9655 96 lõi, không phải CPU Intel. PyTorch chạy với 8 luồng và OpenVINO với 96 luồng, là các giá trị mặc định mà Ultralytics và OpenVINO chọn trên máy chủ đó; do vậy số luồng cũng như runtime đều khác nhau giữa các cột PyTorch và OpenVINO. PyTorch cũng xác thực bằng suy luận hình chữ nhật, tức mỗi ảnh được đệm thành hình chữ nhật theo tỷ lệ khung hình (512x672 cho ảnh 480x640), trong khi model OpenVINO tĩnh luôn chạy ở kích thước 640x640.

Số mili giây trên mỗi ảnh; càng thấp càng tốt. Định dạng nhanh nhất cho mỗi model được in đậm.

ModelimgszPyTorchOpenVINO FP32OpenVINO FP16OpenVINO INT8
YOLO26n64013.313.413.333.35
YOLO26s64024.285.185.184.51
YOLO26m64049.948.398.346.60
YOLO26l64063.7510.9211.058.94
YOLO26x640115.1117.1217.1612.83

YOLO26n trên cùng 8 CPU (PyTorch và OpenVINO đều được ghim vào các CPU 0-7 của máy chủ đó bằng taskset):

Chỉ sốPyTorchOpenVINO FP32OpenVINO FP16OpenVINO INT8
Độ trễ (ms/ảnh)9.287.137.146.71
mAPval 50-9540.840.940.940.3
  • OpenVINO FP32 chạy nhanh hơn PyTorch từ 3.9 đến 6.7 lần với số luồng mặc định nêu trên, trong khi độ chính xác chênh không quá 0.1 mAP. Khi cả hai đều được ghim vào cùng 8 CPU, trong điều kiện PyTorch chạy nhanh hơn so với cấu hình mặc định, OpenVINO FP32 chạy YOLO26n nhanh hơn PyTorch 1.3 lần, còn INT8 nhanh hơn FP32 1.06 lần.
  • FP16 giảm một nửa dung lượng model, độ chênh so với FP32 không quá 0.1 mAP và độ trễ tương đương FP32 (chênh không quá 3%).
  • INT8 chạy nhanh hơn FP32 từ 1.02 đến 1.33 lần, giảm dung lượng model từ 3.1 đến 3.9 lần và giảm 0.5 đến 0.9 mAP.

Đo bằng ultralytics 8.4.212, OpenVINO 2026.4.1, NNCF 3.4.0 và PyTorch 2.15.0 trên batch=1 vào ngày 14 tháng 11 năm 2026. Độ trễ là giai đoạn suy luận được val báo cáo, không bao gồm tiền xử lý hoặc hậu xử lý. Các giá trị PyTorch, FP32 và FP16 là trung bình của ba lần chạy; mức chênh lệch giữa các lần chạy lên tới 26% với PyTorch và 6% với OpenVINO. Model INT8 được hiệu chuẩn trên 591 ảnh COCO train2017 (split=train fraction=0.005) và dựng ba lần; các giá trị INT8 là trung bình của ba lần dựng. Bảng 8 CPU dùng một bản dựng INT8 chạy ba lần.

CPU, GPU và NPU Intel Core Ultra#

Các bảng này được đo trên ba bộ xử lý Intel Core Ultra với openvino 2026.2.1 ở chế độ benchmark: model.benchmark(data="coco128.yaml", format="openvino", device=...), với device được đặt thành cpu, xpu hoặc npu. Độ chính xác là mAP50-95 trên dataset COCO128 gồm 128 ảnh, nên không thể so sánh với các giá trị COCO val2017 ở trên. PyTorch chạy trên CPU của cùng bộ xử lý. Model YOLO26 chỉ chạy trên NPU của các bộ xử lý Intel Core Ultra dòng 2xxV, dòng 3xx trở lên.

Intel Core Ultra X7 358H#

Intel Core Ultra X7 358H (Panther Lake) kết hợp các lõi CPU, GPU Intel Arc tích hợp và NPU Intel AI Boost.

Số mili giây mỗi ảnh; càng thấp càng tốt. Cột nhanh nhất của mỗi model được in đậm.

ModelCPU PyTorchCPU FP32CPU FP16CPU INT8GPU FP32GPU FP16GPU INT8NPU FP32NPU FP16NPU INT8
YOLO26n29.2814.3514.239.994.094.034.247.687.718.60
YOLO26s59.3235.0333.5516.685.085.144.479.899.9410.69
YOLO26m143.2190.5388.8233.337.107.065.6113.0213.1314.84
YOLO26l181.16112.83111.3143.278.458.496.2514.5314.5515.64
YOLO26x379.75241.21236.8778.9213.0312.988.7423.4823.4121.56

Các bộ xử lý Intel Core Ultra đời trước#

Intel Core Ultra 7 258V (Lunar Lake)

Số mili giây mỗi ảnh; càng thấp càng tốt. Cột nhanh nhất của mỗi model được in đậm.

ModelCPU PyTorchCPU FP32CPU FP16CPU INT8GPU FP32GPU FP16GPU INT8NPU FP32NPU FP16NPU INT8
YOLO26n27.3316.8416.738.623.333.343.4623.7123.7023.96
YOLO26s60.2054.7154.4520.194.664.653.9926.6226.6225.89
YOLO26m152.87178.59179.2553.079.038.985.7032.9433.0130.95
YOLO26l201.57238.15233.7067.7311.3211.367.4536.0235.7732.64
YOLO26x431.04567.22561.39151.1119.0819.6313.6949.6449.6941.75
Intel Core Ultra 7 155H (Meteor Lake)

Số mili giây mỗi ảnh; càng thấp càng tốt. Cột nhanh nhất của mỗi model được in đậm.

ModelCPU PyTorchCPU FP32CPU FP16CPU INT8GPU FP32GPU FP16GPU INT8
YOLO26n33.1913.4313.2011.409.139.075.79
YOLO26s70.9236.1636.0715.5416.3716.659.27
YOLO26m192.45102.52101.8835.7234.4735.7115.46
YOLO26l239.19129.24128.5045.3843.2443.4019.72
YOLO26x511.89293.40296.4885.2479.4979.4534.66

Trên cả ba bộ xử lý:

  • CPU: INT8 chạy nhanh hơn FP32 từ 1,2 đến 3,8 lần và nhanh hơn PyTorch từ 2,9 đến 6,0 lần. FP32 chạy nhanh hơn PyTorch từ 1,6 đến 2,5 lần trên X7 358H và 155H, nhưng chậm hơn PyTorch với YOLO26m, YOLO26l và YOLO26x trên 258V.
  • GPU: GPU tích hợp chạy các model FP32 nhanh hơn PyTorch trên CPU từ 3,6 đến 29,1 lần. INT8 nhanh hơn FP32 với mọi model, ngoại trừ YOLO26n trên X7 358H và 258V, với mức nhanh hơn lên đến 2,3 lần.
  • NPU (X7 358H và 258V): Các model FP32 chạy nhanh hơn PyTorch trên CPU từ 1,2 đến 16,2 lần, còn INT8 đạt tốc độ bằng 0,88 đến 1,19 lần FP32. Các model INT8 này được export trước khi device=npu chọn activation đối xứng, vì vậy các bảng không hiển thị bản export INT8 được tối ưu cho NPU.
  • Độ trễ FP16 chênh lệch không quá 5% so với FP32 trên mọi thiết bị, còn INT8 làm giảm mAP50-95 từ 0,1 đến 2,7 điểm.

Giới thiệu về OpenVINO#

OpenVINO, viết tắt của Open Visual Inference and Tối ưu hóa mạng nơ-ron, chuyển đổi model từ các framework như PyTorch sang định dạng IR riêng và chạy chúng thông qua một API trên CPU, GPU và NPU của Intel. Xem tài liệu OpenVINO để biết tài liệu tham khảo đầy đủ.

OpenVINO Intel AI inference toolkit



Xem: Cách export Ultralytics YOLO26 sang định dạng Intel OpenVINO để inference nhanh hơn 🚀

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

  • Có, trên CPU. Thiết bị OpenVINO CPU chạy trên bộ xử lý x86-64 và ARM64: benchmark CPU máy chủ trên trang này được đo trên bộ xử lý AMD EPYC, và cùng bản export cũng chạy trên Apple silicon. Các thiết bị GPU và NPU cần phần cứng Intel, vì vậy device=xpu và device=npu sẽ chuyển sang phương án dự phòng kèm cảnh báo trên các máy khác. Với các mục tiêu khác, hãy xem hướng dẫn các tùy chọn triển khai model.

  • Điều này tùy thuộc vào thiết bị. FP16 (quantize=16) không cần dữ liệu hiệu chuẩn, giảm một nửa kích thước model và duy trì độ chính xác cũng như độ trễ của FP32 trong các benchmark, vì vậy hãy dùng FP16 khi kích thước model là yếu tố quan trọng. INT8 (quantize=8) cho độ trễ CPU thấp nhất với hầu hết model: trên CPU máy chủ, INT8 giảm độ trễ YOLO26s từ 5.18 ms xuống 4.51 ms mỗi ảnh, với 47.6 mAPval 50-95 so với 48.5 ở FP32; trên CPU Intel Core Ultra, INT8 chạy nhanh hơn FP32 từ 1,2 đến 3,8 lần. Trên GPU Intel tích hợp, mức tăng tốc của INT8 thấp hơn, lên đến 2,3 lần; trên NPU, các model INT8 trong những lần chạy này, được export mà không có device=npu, có tốc độ gần bằng FP32. INT8 cần dữ liệu hiệu chuẩn có tính đại diện, vì vậy hãy xác thực model INT8 trên dữ liệu của riêng bạn trước khi chọn.

  • Export bằng dynamic=True và truyền batch cùng imgsz cần dùng tại thời điểm dự đoán. Kích thước ảnh phải là bội số của stride model, bằng 32 đối với các checkpoint YOLO26 chính thức, ngoại trừ các model phân loại; xem Triển khai để biết các ngoại lệ.

    Export động
    from ultralytics import YOLO
    
    model = YOLO("yolo26n.pt")
    model.export(format="openvino", dynamic=True)
    
    model = YOLO("yolo26n_openvino_model/")
    results = model(["https://ultralytics.com/images/bus.jpg"] * 4, imgsz=320)  # một batch gồm 4 ảnh ở kích thước 320 pixel
  • Dùng OpenVINO khi phần cứng triển khai là Intel: device=xpu và device=npu chọn GPU và NPU Intel, còn các model OpenVINO INT8 chạy nhanh hơn FP32 từ 1,2 đến 3,8 lần trên CPU Intel Core Ultra trong các benchmark. Dùng ONNX khi cần chạy cùng một tệp trên GPU NVIDIA hoặc AMD, hoặc trong runtime khác OpenVINO; trên Windows, Windows ML có thể chọn phần cứng Intel cho model ONNX.

Bình luận23

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

  1. EduardoNewGitHub

    I encountered some difficulties while trying to run the official video demo. Here is my code:

    from ultralytics import YOLO

    def main(): # Load a YOLOv8n PyTorch model model = YOLO("yolov8n.pt")

    # Export the model
    model.export(format="openvino")  # creates 'yolov8n_openvino_model/'
    
    # Load the exported OpenVINO model with explicit task definition
    ov_model = YOLO("yolov8n_openvino_model\\", task='detect')  # Explicitly define task as 'detect'
    
    # Run inference
    results_original = model("D:\\python_YOLO_test\\bus.jpg")
    
    # Run ov inference
    results_ov = ov_model("D:\\python_YOLO_test\\bus.jpg")

    if name == "main": main() Additional notes: My environment is openvino==2024.0.0, and I executed pip install --upgrade torch ultralytics.

    The issue I encountered is as follows:

    Results saved to D:\python_YOLO_test Ultralytics YOLOv8.2.57 🚀 Python-3.11.9 torch-2.1.1+cu118 CPU (11th Gen Intel Core(TM) i7-11800H 2.30GHz) YOLOv8n summary (fused): 168 layers, 3,151,904 parameters, 0 gradients, 8.7 GFLOPs

    PyTorch: starting from 'yolov8n.pt' with input shape (1, 3, 640, 640) BCHW and output shape(s) (1, 84, 8400) (6.2 MB)

    OpenVINO: starting export with openvino 2024.0.0-14509-34caeefd078-releases/2024/0... OpenVINO: export success ✅ 2.8s, saved as 'yolov8n_openvino_model' (12.3 MB)

    Export complete (5.2s) Results saved to D:\python_YOLO_test Predict: yolo predict task=detect model=yolov8n_openvino_model imgsz=640
    Validate: yolo val task=detect model=yolov8n_openvino_model imgsz=640 data=coco.yaml
    Visualize: https://netron.app

    image 1/1 D:\python_YOLO_test\bus.jpg: 640x480 4 persons, 1 bus, 1 stop sign, 324.0ms Speed: 24.0ms preprocess, 324.0ms inference, 21.0ms postprocess per image at shape (1, 3, 640, 480) Loading yolov8n_openvino_model for OpenVINO inference... Using OpenVINO LATENCY mode for batch=1 inference...

    Process finished with exit code -1073741819 (0xC0000005)

    Process finished with exit code -1073740791 (0xC0000409) The model was successfully exported but did not perform inference, instead, it terminated directly. How should I resolve this issue?

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

      @EduardoNew the exit code 0xC0000005 often indicates a memory access violation. Let's address this step-by-step:

      1. Path Format: Try using forward slashes in your OpenVINO model path: "yolov8n_openvino_model/" instead of backslashes.

      2. OpenVINO Version: Ultralytics requires openvino>=2024.0.0. Try upgrading to a recent release:

      pip install -U openvino
      1. Hardware Compatibility: Ensure you have the latest Intel drivers installed from Intel's official site.

      If issues persist, please create a Minimum Reproducible Example and open a GitHub Issue following our bug report guidelines. We'll be happy to investigate further!

  2. Ranjith3436GitHub

    You mentioned that the core CPU inference model takes 23.53 ms. I would like to know if the processing time decreases when we increase the number of CPU cores ? currently i am using 12 thread CPU.

    1. Glenn JocherUltralytics

      @Ranjith3436 increasing the number of CPU cores can potentially reduce processing time, as it allows for parallel processing, but the actual speedup will depend on the model's ability to leverage multi-threading effectively.

    2. Glenn JocherUltralytics

      To assess a model's ability to utilize multiple CPU cores, you can check its support for multi-threading or parallel processing in the documentation or by running benchmarks on your hardware configuration.

  3. kimchi2020GitHub

    hey i am working on object detection in videos and came across openvino that helps in increasing speed. how can i use openvino and yolov8 together to find objects in a video

    1. Glenn JocherUltralytics

      @kimchi2020 hi there! It's great to hear that you're exploring OpenVINO to enhance the speed of your object detection tasks in videos. OpenVINO can indeed provide significant performance improvements, especially on Intel hardware.

      To get started with using YOLOv8 and OpenVINO together, follow these steps:

      Exporting YOLOv8 to OpenVINO Format
      1. Export the Model: You can export your YOLOv8 model to the OpenVINO format using the following Python code:

        from ultralytics import YOLO
        
        # Load a YOLOv8n PyTorch model
        model = YOLO("yolov8n.pt")
        
        # Export the model to OpenVINO format
        model.export(format="openvino")  # creates 'yolov8n_openvino_model/'

        Alternatively, you can use the CLI:

        yolo export model=yolov8n.pt format=openvino  # creates 'yolov8n_openvino_model/'
      2. Run Inference with the Exported Model: After exporting, you can run inference using the exported OpenVINO model. Here’s how you can do it in Python:

        from ultralytics import YOLO
        
        # Load the exported OpenVINO model
        ov_model = YOLO("yolov8n_openvino_model/")
        
        # Run inference
        results = ov_model("https://ultralytics.com/images/bus.jpg")

        Or using the CLI:

        yolo predict model=yolov8n_openvino_model source='https://ultralytics.com/images/bus.jpg'
      Running Inference on Videos

      To process videos, you can modify the inference code to read frames from a video file and run the model on each frame. Here’s an example in Python:

      import cv2
      from ultralytics import YOLO
      
      # Load the exported OpenVINO model
      model = YOLO("yolov8n_openvino_model/")
      
      # Open the video file
      video_path = "path/to/your/video.mp4"
      cap = cv2.VideoCapture(video_path)
      
      # Loop through the video frames
      while cap.isOpened():
          ret, frame = cap.read()
          if not ret:
              break
      
          # Run inference on the frame
          results = model(frame)
      
          # Visualize the results on the frame
          annotated_frame = results[0].plot()
      
          # Display the annotated frame
          cv2.imshow("YOLOv8 OpenVINO Inference", annotated_frame)
      
          # Break the loop if 'q' is pressed
          if cv2.waitKey(1) & 0xFF == ord('q'):
              break
      
      # Release the video capture object and close the display window
      cap.release()
      cv2.destroyAllWindows()
      Additional Resources

      For more detailed information and advanced usage, you can refer to the OpenVINO documentation. This guide covers everything from exporting models to running inference and optimizing performance.

      Feel free to reach out if you have any more questions. Happy coding! 🚀

    2. kimchi2020GitHub

      Traceback (most recent call last): File "/home/kimchi/Desktop/yolov8/onnx.py", line 18, in results = model(frame) ^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/ultralytics/engine/model.py", line 174, in call return self.predict(source, stream, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/ultralytics/engine/model.py", line 442, in predict return self.predictor.predict_cli(source=source) if is_cli else self.predictor(source=source, stream=stream) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/ultralytics/engine/predictor.py", line 168, in call return list(self.stream_inference(source, model, *args, **kwargs)) # merge list of Result into one ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 35, in generator_context response = gen.send(None) ^^^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/ultralytics/engine/predictor.py", line 234, in stream_inference self.model.warmup(imgsz=(1 if self.model.pt or self.model.triton else self.dataset.bs, 3, *self.imgsz)) File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/ultralytics/nn/autobackend.py", line 626, in warmup import torchvision # noqa (import here so torchvision import time not recorded in postprocess time) ^^^^^^^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/torchvision/init.py", line 6, in from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/torchvision/models/init.py", line 2, in from .convnext import * File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/torchvision/models/convnext.py", line 8, in from ..ops.misc import Conv2dNormActivation, Permute File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/torchvision/ops/init.py", line 1, in from ._register_onnx_ops import _register_custom_op File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/torchvision/ops/_register_onnx_ops.py", line 5, in from torch.onnx import symbolic_opset11 as opset11 File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/torch/onnx/init.py", line 59, in from ._internal.onnxruntime import ( File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/torch/onnx/_internal/onnxruntime.py", line 36, in import onnx File "/home/kimchi/Desktop/yolov8/onnx.py", line 18, in results = model(frame) ^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/ultralytics/engine/model.py", line 174, in call return self.predict(source, stream, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/ultralytics/engine/model.py", line 442, in predict return self.predictor.predict_cli(source=source) if is_cli else self.predictor(source=source, stream=stream) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/ultralytics/engine/predictor.py", line 168, in call return list(self.stream_inference(source, model, *args, **kwargs)) # merge list of Result into one ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 35, in generator_context response = gen.send(None) ^^^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/ultralytics/engine/predictor.py", line 261, in stream_inference self.results = self.postprocess(preds, im, im0s) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/ultralytics/models/yolo/detect/predict.py", line 25, in postprocess preds = ops.non_max_suppression( ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kimchi/Desktop/yolov8/myvenv/lib/python3.12/site-packages/ultralytics/utils/ops.py", line 291, in non_max_suppression i = torchvision.ops.nms(boxes, scores, iou_thres) # NMS ^^^^^^^^^^^^^^^ AttributeError: partially initialized module 'torchvision' has no attribute 'ops' (most likely due to a circular import). Did you mean: 'os'?

      I am getting this error, how to get rid of it and what does it mean

    3. Glenn JocherUltralytics

      Hi @kimchi2020,

      Thank you for reaching out! The error you're encountering seems to be related to a circular import issue with the torchvision library. This can happen if there's a naming conflict or an import loop in your code.

      Steps to Resolve the Issue:
      1. Check for Naming Conflicts: Ensure that your script name (onnx.py) is not conflicting with any library names. Rename your script to something unique, like run_inference.py.

      2. Verify Installation: Make sure you have the latest versions of torch, torchvision, and ultralytics installed. You can update them using:

        pip install --upgrade torch torchvision ultralytics
      3. Reproduce the Issue: If the issue persists, please provide a minimum reproducible example. This helps us diagnose the problem more effectively. You can refer to our guide on creating a reproducible example here: Minimum Reproducible Example.

      Example Code for Inference with OpenVINO:

      Here's a quick example of how to export your YOLOv8 model to OpenVINO and run inference on a video:

      import cv2
      from ultralytics import YOLO
      
      # Load a YOLOv8n PyTorch model
      model = YOLO("yolov8n.pt")
      
      # Export the model to OpenVINO format
      model.export(format="openvino")  # creates 'yolov8n_openvino_model/'
      
      # Load the exported OpenVINO model
      ov_model = YOLO("yolov8n_openvino_model/")
      
      # Open the video file
      video_path = "path/to/your/video.mp4"
      cap = cv2.VideoCapture(video_path)
      
      # Loop through the video frames
      while cap.isOpened():
          ret, frame = cap.read()
          if not ret:
              break
      
          # Run inference on the frame
          results = ov_model(frame)
      
          # Visualize the results on the frame
          annotated_frame = results[0].plot()
      
          # Display the annotated frame
          cv2.imshow("YOLOv8 OpenVINO Inference", annotated_frame)
      
          # Break the loop if 'q' is pressed
          if cv2.waitKey(1) & 0xFF == ord('q'):
              break
      
      # Release the video capture object and close the display window
      cap.release()
      cv2.destroyAllWindows()

      For more detailed information on exporting and using OpenVINO, please refer to our OpenVINO Integration Guide.

      Feel free to reach out if you have any more questions or need further assistance. Happy coding! 🚀

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

      To use Intel GPUs for inference, export your YOLOv8 model to OpenVINO format with model.export(format="openvino"), then run inference with the exported model and select the GPU with device="intel:gpu", for example ov_model("bus.jpg", device="intel:gpu"). For more details, please refer to the OpenVINO integration guide.

    5. YA12SHYAMGitHub

      ok, just to confirm i can't use ultralytics python api for inference with intel gpu like i usually do within the ultralytics ecosystem for example ?

      from ultralytics import YOLO
      model =  YOLO(path/to/model)

      here the path/to/model works with onnx, engine, opnevino;s xml , but it use cpu in case of openvino , i want to use my intel GPU

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

      @YA12SHYAM to use Intel GPUs with YOLOv8, export your model to OpenVINO format and select the GPU at inference with device="intel:gpu", e.g. model("bus.jpg", device="intel:gpu"). For detailed steps, refer to the OpenVINO integration guide.

  4. kanishkaswGitHub

    Hi Im getting the following error when attempting to convert the model to openVino. Tried with both 2024.1.0 and 2024.0.0. Im on ubuntu 20.04 with python 3.8 $ yolo export model=runs/classify/train/weights/best.pt format=openvino Ultralytics YOLOv8.2.31 🚀 Python-3.8.10 torch-2.3.1+cu121 CPU (Intel Core(TM) i9-7900X 3.30GHz) YOLOv8n-cls summary (fused): 73 layers, 1438723 parameters, 0 gradients, 3.3 GFLOPs

    PyTorch: starting from 'runs/classify/train/weights/best.pt' with input shape (1, 3, 320, 320) BCHW and output shape(s) (1, 3) (2.8 MB) OpenVINO: export failure ❌ 0.0s: module 'openvino' has no attribute 'version' Traceback (most recent call last): File "/home/Kanishka/v5.0/YOLOV8_classification/.venv/bin/yolo", line 8, in sys.exit(entrypoint()) File "/home/Kanishka/v5.0/YOLOV8_classification/.venv/lib/python3.8/site-packages/ultralytics/cfg/init.py", line 591, in entrypoint getattr(model, mode)(**overrides) # default args from model File "/home/Kanishka/v5.0/YOLOV8_classification/.venv/lib/python3.8/site-packages/ultralytics/engine/model.py", line 602, in export return Exporter(overrides=args, _callbacks=self.callbacks)(model=self.model) File "/home/Kanishka/v5.0/YOLOV8_classification/.venv/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(*args, **kwargs) File "/home/Kanishka/v5.0/YOLOV8_classification/.venv/lib/python3.8/site-packages/ultralytics/engine/exporter.py", line 308, in call f[3], _ = self.export_openvino() File "/home/Kanishka/v5.0/YOLOV8_classification/.venv/lib/python3.8/site-packages/ultralytics/engine/exporter.py", line 142, in outer_func raise e File "/home/Kanishka/v5.0/YOLOV8_classification/.venv/lib/python3.8/site-packages/ultralytics/engine/exporter.py", line 137, in outer_func f, model = inner_func(*args, **kwargs) File "/home/Kanishka/v5.0/YOLOV8_classification/.venv/lib/python3.8/site-packages/ultralytics/engine/exporter.py", line 454, in export_openvino LOGGER.info(f"\n{prefix} starting export with openvino {ov.version}...") AttributeError: module 'openvino' has no attribute 'version'

    1. Paula DerrengerUltralytics(đã chỉnh sửa)

      @kanishkasw hi there,

      Thank you for reaching out and providing detailed information about the issue you're encountering. It looks like you're experiencing an error when attempting to export your model to OpenVINO format. Let's work through this together.

      First, let's ensure that you are using the latest versions of torch and ultralytics. Please run the following commands to update your packages:

      pip install --upgrade torch ultralytics

      Next, it seems the error is related to the OpenVINO package. The error message module 'openvino' has no attribute '__version__' suggests there might be an issue with the OpenVINO installation. Please make sure you have a recent version of OpenVINO installed (Ultralytics requires openvino>=2024.0.0). You can install it using the following command:

      pip install -U openvino

      Once you've updated the packages, try exporting the model again:

      yolo export model=runs/classify/train/weights/best.pt format=openvino

      If the issue persists, could you please provide a minimum reproducible example? This will help us investigate the problem more effectively. You can find guidance on creating a minimum reproducible example here: Minimum Reproducible Example.

      Additionally, here's a Python example to ensure everything is set up correctly:

      from ultralytics import YOLO
      
      # Load a YOLOv8n PyTorch model
      model = YOLO("runs/classify/train/weights/best.pt")
      
      # Export the model to OpenVINO format
      model.export(format="openvino")  # creates 'best_openvino_model/'
      
      # Load the exported OpenVINO model
      ov_model = YOLO("best_openvino_model/")
      
      # Run inference
      results = ov_model("https://ultralytics.com/images/bus.jpg")

      For more detailed instructions on using OpenVINO, please refer to our OpenVINO Integration Guide.

      Feel free to reach out if you have any further questions or run into any other issues. We're here to help! 😊

  5. renato-rodrigGitHub

    hello everything is fine? I have a question about the results exposed in the article above. Is the time shown in the graphs in relation to the inference time that the model takes to return the detections or is it the time for image reading, image pre-processing and model inference? I ask this because on my computer (intel core i7 12 generation CPU) the yolov8n model ran with an inference time of 40ms and the gain from using OpenVINO was not that great.

    1. Paula DerrengerUltralytics

      @renato-rodrig hello! 👋 Regarding your question about the times shown in the graphs, they typically refer to the total inference time, which includes the actual model inference as well as the time taken for pre-processing the input data (like image reading and resizing).

      The difference you observed with OpenVINO on your Intel Core i7 may vary due to several factors such as the specific configuration of your system, the type of tasks being run, and the optimizations that the YOLOv8n model can leverage on that platform. Generally, OpenVINO tends to show more significant performance gains on integrated Intel GPUs and some specific CPU configurations.

      If you haven't seen a major performance improvement, you might want to look into further tuning your OpenVINO deployment or explore using other optimization techniques provided by OpenVINO. Additionally, ensure all drivers and software components are up to date for optimal performance.

      Here’s a quick example of ensuring you're using the model in the most optimized manner:

      from ultralytics import YOLO
      
      # Load YOLOv8n PyTorch model
      model = YOLO('yolov8n.pt')
      
      # Export the model to OpenVINO
      model.export(format='openvino')  # Creates 'yolov8n_openvino_model/'
      
      # Load the exported OpenVINO model
      ov_model = YOLO('yolov8n_openvino_model/')
      
      # Run inference to see if performance improves
      results = ov_model('https://ultralytics.com/images/bus.jpg')

      Feel free to experiment with different configurations and settings! 😊

      1
  6. YouROS12GitHub

    I wanna do inferences with my exported pre-trained yolov8 model using Raspberry PI with a Neural Network Computing 2 (NCS2) plugged in.. but its doesn't support opset 11 or above.. only opset10.. I specified onnx opset to 10 and convert it to Openvino but it didn't work.

    Anyway please to export openvino model directly in opset10 ? Does even yolov8 support this specified opset format ?

    Thank you.

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

      @YouROS12 the current OpenVINO export no longer goes through ONNX: Ultralytics converts the PyTorch model directly to OpenVINO IR with openvino.convert_model, so the ONNX opset argument does not apply and the old mo Model Optimizer step isn't needed. Export with:

      from ultralytics import YOLO
      
      # Load a pretrained YOLOv8 model
      model = YOLO('yolov8n.pt')
      
      # Export the model to OpenVINO
      model.export(format='openvino')  # creates 'yolov8n_openvino_model/'

      The export requires openvino>=2024.0.0. If your target requires an older OpenVINO that cannot load these models, you can still try model.export(format='onnx', opset=10) and convert the ONNX file with that toolkit's own tools, but some YOLOv8 operations may not be supported in older opsets, which could lead to errors during export or inference.

    2. YouROS12GitHub

      Where can I find documentation about YOLOv8's operations with opset 10 ? Updating OpenVINO toolkit is not an option because NCS2 works only at opset 10 and lower.

    3. Paula DerrengerUltralytics

      @YouROS12 the documentation for ONNX opset versions and the operations they support can be found on the ONNX GitHub repository or the official ONNX documentation. However, there isn't specific documentation for YOLOv8's operations with opset 10, as this would be a combination of YOLOv8's implementation details and ONNX's opset specifications.

      To check which operations are supported in opset 10, you can refer to the ONNX Operators documentation for that specific version. This documentation lists all the operators available in opset 10 and their details.

      For YOLOv8, you would need to look at the model's architecture and identify which operations are used. Then, cross-reference these operations with the ONNX opset 10 documentation to see if they are supported. If certain operations are not supported in opset 10, you might need to modify the model or the export script to use alternative operations that are compatible with opset 10.

      Since updating OpenVINO is not an option for you, if you find that YOLOv8 uses operations not supported in opset 10, you might need to consider using a different model architecture that is compatible with opset 10, or reach out to the community or Ultralytics for further assistance on how to proceed with your specific use case and hardware constraints.