はじめる

Intel OpenVINOへのエクスポート

OpenVINOは、AI推論を最適化して実行するためのIntelのオープンソースツールキットです。format="openvino"を使用してUltralytics YOLO26モデルをエクスポートすると、FP32、FP16、またはINT8の精度で、Intel CPU、Intel内蔵GPUおよびディスクリートGPU、Intel NPU向けのOpenVINO IRモデル(.xmlファイルと.binファイル)を格納したyolo26n_openvino_model/ディレクトリが作成されます。

概要#

プロパティ詳細
format 引数openvino
出力yolo26n_openvino_model/。yolo26n.xml、yolo26n.bin、metadata.yamlを含むディレクトリ。quantize=8エクスポート用のyolo26n_int8_openvino_model/
実行環境Intel CPU、Intel内蔵GPUおよびディスクリートGPU、Intel NPU。CPUデバイスはAMDやApple siliconなど、ほかのx86-64およびARM64プロセッサでも動作します
ランタイムOpenVINO Runtime 2024.0.0以降(openvino Pythonパッケージ)
適合率FP32、FP16、INT8。YOLO26nのサイズはFP32で10.1 MB、FP16で5.3 MB、INT8で3.3 MBです
エクスポートホストLinux、macOS、またはWindows。エクスポートはCPU上で実行され、GPUは必要ありません
クラウドでエクスポート

Ultralytics Platformでは、トレーニング済みモデルをOpenVINOにエクスポートできるため、ローカルのエクスポート環境は必要ありません。

クイックスタート#

OpenVINOエクスポート用の依存関係とともにUltralyticsパッケージをインストールします。

pip install "ultralytics[export-openvino]"

これによりopenvinoがインストールされ、Python 3.9以降ではINT8量子化用のnncfもインストールされます。通常のpip install ultralyticsを使用している場合、初回のエクスポート時に不足しているパッケージがインストールされます。エクスポートには次のバージョン要件があります。

パッケージ必須バージョン
torch2.1以降
openvino2024.0.0以降。macOS 15.4以降では2025.2.0以降
nncfquantize=8のみの場合は2.14.0以降。PyTorchが2.3未満の場合は3.0.0未満

ほかのインストール方法については、インストールガイドをご覧ください。次に、モデルをエクスポートし、エクスポートしたディレクトリを読み込んで推論を実行するか、精度を検証します。CPUでのOpenVINOコースでは、同じ手順を解説しています。

エクスポート
from ultralytics import YOLO

# YOLO26モデルを読み込みます
model = YOLO("yolo26n.pt")

# モデルをOpenVINO形式にエクスポート
model.export(format="openvino")  # creates 'yolo26n_openvino_model/'

# キャリブレーションデータを使用してINT8量子化OpenVINOモデルをエクスポートする
model.export(format="openvino", quantize=8, data="coco8.yaml")  # creates 'yolo26n_int8_openvino_model/'
推論
from ultralytics import YOLO

# エクスポート済みのOpenVINOモデルを読み込む
model = YOLO("yolo26n_openvino_model/")

# 推論を実行
results = model("https://ultralytics.com/images/bus.jpg")

# Intel GPUで推論を実行します。Intel NPUには「npu」、CPUには「cpu」を使用します
results = model("https://ultralytics.com/images/bus.jpg", device="xpu")
検証
from ultralytics import YOLO

# エクスポート済みのOpenVINOモデルを読み込む
model = YOLO("yolo26n_openvino_model/")

# COCO8データセットで精度を検証します
metrics = model.val(data="coco8.yaml")

対応タスク#

OpenVINOエクスポートでは、YOLOv8、YOLO11、YOLO26モデルを使用したUltralyticsの7つすべてのタスク、すなわち検出、セグメンテーション、セマンティックセグメンテーション、深度推定、分類、姿勢推定、OBBがサポートされています。セマンティックセグメンテーションと深度推定は、これらのヘッドを備える唯一のファミリーであるYOLO26でのみ利用できます。

エクスポート引数#

引数種類デフォルト説明
formatstr'openvino'エクスポートしたモデルのターゲットフォーマットです。さまざまなデプロイ環境との互換性を定義します。
imgszintまたはtuple640モデル入力の画像サイズです。正方形の画像には整数を、タプルには (height, width) を指定します。指定しない場合、エクスポートではチェックポイントの学習時に使用されたサイズが使われます。公式YOLO26チェックポイントでは、検出、セグメンテーション、姿勢推定、およびADE20Kで事前学習したセマンティックモデルには 640、OBBおよびCityscapesで事前学習したセマンティックモデルには 1024、深度推定には 768、分類には 224 が使用されます。
quantizeintまたはstrNone量子化精度:16(FP16:重みは半精度で保存され、入力と出力はFP32のまま)または8(dataのキャリブレーション画像を使用したNNCFによるINT8の学習後量子化。結果は_int8_openvino_model/ディレクトリに書き込まれます)。32/未設定の場合はFP32です。quantize=8でトレーニングされたチェックポイントはOpenVINOにエクスポートできません。制限事項とトラブルシューティングをご覧ください。非推奨のhalf/int8フラグを置き換えるものです。
datastrNoneINT8キャリブレーションに使用するデータセットYAML。分類の場合は、代わりにデータセットディレクトリまたは組み込みデータセット名を指定します。キャリブレーションでは、splitが設定されていない限り、valの分割を使用します。quantize=8が指定されていない場合、Ultralyticsはモデルのタスクに対応した小規模なデフォルトデータセットを使用します。たとえば、検出ではcoco8.yamlを使用します。
fractionfloat、int、またはlist1.0キャリブレーション用サブセットを、比率、画像数、または[train, val, test]の比率/件数として指定します。2項目のリストではtestがすべて含まれ、0では除外されます。
dynamicboolFalse入力のバッチサイズ、高さ、幅を動的に設定し、1つのモデルで異なるバッチサイズと画像サイズに対応できるようにします。Intel NPUでは、動的モデルもエクスポート時のimgszで実行されます。デプロイをご覧ください。
nmsbool、省略可Noneraw出力(None、デフォルト)、NMSを組み込んだ出力(True)、またはNMS-freeヘッド(False)を選択します。出力形式を参照してください。
batchint1エクスポートするモデルのバッチサイズです。静的エクスポートでは、入力形状にこのバッチサイズが固定されます。INT8キャリブレーションにもこのバッチサイズが使用されます。
devicestrNoneエクスポートは常にCPU上で実行されます。quantize=8を指定すると、device=npuによってYOLOの検出、セグメンテーション、姿勢推定、OBBモデルのアクティベーションに対称INT8量子化が選択され、Intel NPU上で最大2倍高速に動作します。

すべての形式に共通する引数については、エクスポートモードのドキュメントを参照してください。

INT8量子化#

quantize=8は、NNCFを使用した学習後の量子化を適用します。エクスポートではキャリブレーション画像をモデルに通し、可能な箇所で重みとアクティベーションを8ビット整数として保存します。

  • キャリブレーションデータ:エクスポートでは、splitで指定した分割、またはdataのval分割から、完全なバッチごとにキャリブレーションを行います。画像数を制限するにはfractionを使用します。画像数が300未満の場合、エクスポート時に警告が表示されます。
  • 検出ヘッド:YOLO検出ヘッドを持つモデル(検出、セグメンテーション、姿勢推定、OBB)およびRT-DETRでは、ヘッド出力をデコードする処理(reshape、連結、ボックスのデコード、DFL)とすべてのsigmoid処理は浮動小数点のまま維持され、ヘッドの畳み込みは量子化されます。分類、セマンティックセグメンテーション、深度モデルには量子化対象外の処理はありません。
  • 入力と出力:INT8モデルの入力と出力はFP32モデルのfloat32を維持するため、FP32モデル用に記述した推論コードを変更せずに実行できます。
  • Intel NPU:Intel NPUで実行する予定のINT8エクスポートにはdevice=npuを追加します。これにより、YOLOの検出、セグメンテーション、姿勢推定、OBBモデルのアクティベーション量子化が非対称から対称に切り替わります。
例
from ultralytics import YOLO

model = YOLO("yolo26n.pt")

# COCOの検証画像の10%(500枚)でキャリブレーションします。coco.yamlを独自のデータセットに置き換えてください
model.export(format="openvino", quantize=8, data="coco.yaml", fraction=0.1)

# エクスポートしたINT8モデルを読み込み、推論を実行する
model = YOLO("yolo26n_int8_openvino_model/")
results = model("https://ultralytics.com/images/bus.jpg")

ベンチマークでは、INT8モデルはサーバーCPU上でFP32より1.02~1.33倍高速に動作し、COCO val2017でmAPが0.5~0.9低下しました。Intel Core Ultra CPU上では、INT8はFP32より1.2~3.8倍高速に動作しました。デプロイ前に、独自のデータでINT8モデルを検証してください。

出力形式#

エクスポートでは、次の3つのファイルを含むディレクトリが1つ書き込まれます。

ファイル内容
yolo26n.xmlOpenVINO IR形式のネットワークグラフ
yolo26n.bin重み
metadata.yamlクラス名、タスク、画像サイズ、バッチサイズ、ストライド、エクスポート引数。Ultralyticsはモデルの読み込み時にこれらを読み取ります

モデルは形状が(batch, 3, height, width)の入力を1つ受け取ります。入力はRGBで、値は0~1にスケーリングされています。セマンティックセグメンテーションの出力(uint8クラスマップ。256クラスを超えるモデルではint32)を除き、FP32、FP16、INT8モデルの入力と出力はfloat32です。テンソルにはONNXエクスポートのimagesおよびoutput0という名前が付与されないため、独自のコードではインデックスで入出力を指定してください。

出力形状はONNXエクスポートと同じで、タスクとnms引数によって異なります。imgsz=640でエクスポートされたYOLO26n検出モデルは、デフォルトのnms=Noneでは(1, 84, 8400)を、nms=Falseまたはnms=Trueでは(1, 300, 6)を返します。すべてのタスクの形状と内容については、ONNX出力形式をご覧ください。nms=Trueを指定すると、信頼度しきい値conf(デフォルトは0.25)、IoUしきい値iou、agnostic_nms、max_detがエクスポート時にグラフ内で固定されます。予測時または検証時にconfを下げても、グラフですでに除外された検出結果は復元できないため、これらの値を変更するには再エクスポートしてください。

デプロイする#

YOLO("yolo26n_openvino_model/")はOpenVINO Runtimeでモデルを実行し、device引数をOpenVINOデバイスに対応付けます。

deviceOpenVINOデバイス
未設定AUTO。OpenVINOにCPUとIntel GPUのどちらを使うか選択させます(デフォルトの優先順位リストではNPUは対象外です)。OpenVINOがCPUのみを検出する場合はCPUを指定します
cpuCPU
xpuまたはxpu:0Intel内蔵GPUまたはディスクリートGPUを指定するGPUまたはGPU.0。Intel GPUを2基搭載したマシンでは、xpu:1によってGPU.1が選択されます
npuNPU。Intel Core Ultraプロセッサのニューラルプロセッシングユニットです

0やmpsなどのほかの値は、deviceが未設定の場合と同様に処理されます。以前のintel:cpu、intel:gpu、intel:npuという名前も引き続き使用できますが、非推奨の警告がログに記録されます。推論デバイスの表では、各フォーマットでのこれらの名前を比較しています。ログのUsing OpenVINO LATENCY mode for batch=1 inference on CPU...は、モデル読み込み時にOpenVINOが報告するデバイス名です。AUTOを指定した場合、Intel GPUでモデルのコンパイル中でもCPUが表示されることがあるため、確実に選択するにはdeviceを設定してください。.ptモデルでは、代わりにdevice="xpu"によってPyTorchのIntel GPUバックエンドが選択されます。このバックエンドはIntel GPUでのトレーニングにも使用するデバイスです。また、device="npu"はIntel NPUではなくHuawei Ascend NPUを選択します。

推論時の動作は、モデルのエクスポート方法によって異なります。

  • 静的エクスポート(デフォルト):モデルは常にエクスポート時のimgszとbatchで実行されます。Ultralyticsはこれらをmetadata.yamlから読み取ります。predictに渡されたimgszは無視されます。大きいバッチはエクスポート時のバッチサイズのチャンクに分割され、小さいバッチはパディングされるため、任意の枚数の画像を処理できます。
  • 動的エクスポート(dynamic=True):predictは異なるバッチサイズと、モデルのストライドの倍数であるすべてのimgszを受け入れます。Intel NPUとIntel AMX CPU上のINT8モデルは例外です。制限事項とトラブルシューティングをご覧ください。
  • レイテンシモード:UltralyticsはOpenVINOのLATENCYパフォーマンスヒントを使用してモデルをコンパイルし、同期的に推論を実行します。THROUGHPUTヒントを使用して多数のリクエストを並列処理するには、レイテンシとスループットのガイドに示すようにOpenVINO Runtime APIを使用してください。
  • Intel NPU:UltralyticsはNPU向けにバッチサイズ1でモデルをコンパイルし、それより大きいバッチは単一画像に分割します。動的エクスポートもNPUではエクスポート時のimgszに固定されます。

OpenVINO Runtime APIで実行する#

Ultralyticsパッケージ以外でモデルを実行するには、openvinoパッケージを使用して.xmlファイルを読み込みます。モデルは前処理済み画像を受け取り、出力形式で説明されている生の出力を返します。そのため、デフォルトのエクスポートではレターボックス処理とNMSを独自のコードで行う必要があります。

# 最初にエクスポートします: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")  # または「CPU」、「GPU」、「NPU」

image = np.zeros((1, 3, 640, 640), dtype=np.float32)  # 前処理済み画像:RGB、NCHW、0~1
detections = compiled(image)[0][0]  # 最初の出力の最初の画像:形状 (300, 6)
detections = detections[detections[:, 4] > 0.25]  # 信頼度しきい値を超える行を保持

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

デプロイガイド#

制限事項とトラブルシューティング#

  • PyTorchのバージョン:古いPyTorchバージョンでは、エクスポート時にOpenVINO export requires torch>=2.1で失敗します。
  • macOS 15.4以降:これらのmacOSバージョンではOpenVINO 2025.1.0以前は失敗するため、エクスポートにはopenvino>=2025.2.0が必要で、古いパッケージが更新されます。
  • quantize=8でトレーニングされたチェックポイント:量子化を考慮したトレーニングでファインチューニングしたチェックポイントは、format='openvino' cannot export a QAT model: its Q/DQ ranges are only read by the 'onnx' and 'engine' backendsでエクスポートすると失敗します。代わりに、ファインチューニングの開始元となったチェックポイントをquantize=8でエクスポートするか、ファインチューニング済みチェックポイントをONNXまたはTensorRTにエクスポートしてください。
  • dataを指定しないINT8エクスポート:エクスポートではINT8 export requires a missing 'data' arg for calibration. Using default 'data=coco8.yaml'.がログに記録され、そのタスク用の小規模なデフォルトデータセットでキャリブレーションが行われます。デプロイ先のデータを代表する画像を含むdataを渡してください。
  • INT8キャリブレーションのサイズ:キャリブレーション用の分割に画像が300枚未満の場合、エクスポートでは>300 images recommended for INT8 calibration, found 4 images.がログに記録されます。coco8.yamlには検証画像が4枚しかありません。エクスポートのテストには十分ですが、デプロイ用モデルのキャリブレーションには不十分です。
  • 出力ディレクトリ:INT8以外では、同じチェックポイントのエクスポートは、quantize、imgsz、dynamic、nms、batchの値にかかわらず、毎回同じyolo26n_openvino_model/ディレクトリに書き込まれるため、後から行ったエクスポートが前のものを置き換えます。device=npuの有無にかかわらず、すべてのINT8エクスポートでyolo26n_int8_openvino_model/が共有されます。
  • デバイスを利用できない場合:指定したデバイスがない場合、UltralyticsはOpenVINO device 'GPU' not available. Using 'AUTO' instead.(OpenVINOがCPUのみを検出するマシンではUsing 'CPU' instead.)をログに記録し、そのデバイスで処理を続行します。プロセッサがOpenVINOでサポートされていることを確認し、IntelのGPUまたはNPUドライバーをインストールしてください。
  • Intel NPU:Ultralyticsは固定入力形状でNPUをバッチサイズ1で実行します。デプロイをご覧ください。NPUを使用するにはdevice=npuを渡してください。deviceが未設定の場合、NPUは選択されません。
  • NMSを使用した動的形状:dynamic=Trueとnms=Trueを指定してエクスポートし、batchを1のままにすると、'dynamic=True' export requires a maximum batch size, e.g. 'batch=16'.がログに記録されます。Ultralyticsは大きいバッチをエクスポート時のbatchのチャンクに分割して実行します。
  • Intel AMX CPU上の動的INT8モデル:AMX対応CPU(Intel Sapphire Rapids以降)を搭載したLinuxでは、Ultralyticsは動的INT8モデルを静的モデルと同様に、エクスポート時のimgszでCPUまたはAUTOデバイス上で実行します。predictまたはvalに渡されたimgszは無視され、valではエクスポート時のbatchが使用されます。predictでは引き続き異なるバッチサイズを受け入れ、新しいバッチサイズごとにモデルを再コンパイルするため、新しいバッチサイズでの初回推論は遅くなります。
  • Windows:Windowsでは、UltralyticsはCPU推論の精度ヒントをFP32に設定します。これによりOpenVINOが低精度の浮動小数点カーネルを使用しなくなります(INT8モデルは引き続きINT8で動作します)。また、oneDNNはAMX未満の命令セットに制限されます。異なる制限を使用するには、モデルの読み込み前にONEDNN_MAX_CPU_ISA環境変数を設定してください。
  • ARM64上のLinux:Ultralyticsは、FP32の推論精度でOpenVINOの精度実行モードを使用してCPUデバイスを実行します。
  • 組み込みNMS:分類ではnms=Trueによって'nms=True' is not valid for classification models.が発生します。セマンティックセグメンテーションおよび深度推定モデル('nms=True' is not valid for semantic models. Forcing 'nms=None'.)とRT-DETRモデル('nms=True' is not available for end2end models or non-YOLO heads. Forcing 'nms=None'.)では、警告を表示して無視されます。
  • NMS-freeヘッド:nms=False には、YOLO26やYOLOv10など、NMS-freeヘッドを持つモデルが必要です。YOLO11などのその他のモデルでは、エクスポート時に This model has no one-to-one head; using one-to-many outputs. の警告が表示され、rawの (1, 84, 8400) 出力が書き込まれます。

その他のエラーについては、よくある問題のガイドを参照してください。

OpenVINOを使用したYOLO26のベンチマーク#

以下の表では、すべてのYOLO26検出モデルについて、PyTorchとFP32、FP16、INT8のOpenVINOモデルを比較しています。最初の表はサーバーCPU上でCOCO val2017の精度とともに測定した結果です。2つ目の表は3種類のIntel Core Ultraプロセッサ上で、各CPUとGPU、およびそのうち2種類のプロセッサのNPUを使って測定した結果です。YOLO26モデルページでは、すべてのモデルの精度、CPU ONNX速度、T4 TensorRT速度を掲載しています。

サーバーCPU上のFP32、FP16、INT8#

このセクションのすべての値はIntel CPUではなく、AMD EPYC 9655 96コアプロセッサを2基搭載した1台のサーバーのCPU上で測定しました。PyTorchは8スレッド、OpenVINOは96スレッドで実行しました。これらはUltralyticsとOpenVINOがそのサーバーで選択したデフォルト値であるため、PyTorchとOpenVINOの列ではランタイムだけでなくスレッド数も異なります。また、PyTorchの検証では、各画像をアスペクト比に合わせた長方形(480x640画像の場合は512x672)にパディングする矩形推論を使用しました。一方、静的OpenVINOモデルは常に640x640で実行しました。

画像1枚あたりのミリ秒数です。値が小さいほど高速です。各モデルで最速の形式を太字で示しています。

モデルimgszPyTorchOpenVINO 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

同じ8基のCPU上でのYOLO26n(PyTorchとOpenVINOの両方を、そのサーバーのCPU 0~7にtasksetで固定):

指標PyTorchOpenVINO FP32OpenVINO FP16OpenVINO INT8
レイテンシ(ms/画像)9.287.137.146.71
mAPval 50-9540.840.940.940.3
  • OpenVINO FP32は、上記のデフォルトのスレッド数でPyTorchより3.9~6.7倍高速に動作し、精度差は0.1 mAP以内でした。両方を同じ8基のCPUに固定すると、デフォルト設定よりPyTorch自体が高速になりましたが、OpenVINO FP32はYOLO26nをPyTorchより1.3倍高速に実行し、INT8はFP32より1.06倍高速に実行しました。
  • FP16では、FP32と0.1 mAP以内の精度を保ちながらモデルサイズが半分になり、レイテンシはFP32と同等(差は3%以内)でした。
  • INT8はFP32より1.02~1.33倍高速に動作し、モデルサイズを3.1~3.9分の1に縮小しました。mAPの低下は0.5~0.9でした。

2026年11月14日に、ultralytics 8.4.212、OpenVINO 2026.4.1、NNCF 3.4.0、PyTorch 2.15.0をbatch=1で使用して測定しました。レイテンシはvalが報告する推論ステージの値で、前処理と後処理は含みません。PyTorch、FP32、FP16の値は3回の実行の平均です。実行間の差はPyTorchで最大26%、OpenVINOで最大6%でした。INT8モデルはCOCO train2017の591枚の画像(split=train fraction=0.005)でキャリブレーションし、3回ビルドしました。INT8の値は3回のビルドの平均です。8 CPUの表では、1回のINT8ビルドを3回実行しています。

Intel Core Ultra CPU、GPU、NPU#

これらの表は、3種類のIntel Core Ultraプロセッサ上で、openvino 2026.2.1を使い、ベンチマークモードでmodel.benchmark(data="coco128.yaml", format="openvino", device=...)を指定し、deviceをcpu、xpu、またはnpuに設定して測定しました。精度は128枚の画像からなるCOCO128データセットでのmAP50-95であるため、上記のCOCO val2017の値とは比較できません。PyTorchは同じプロセッサのCPU上で動作しました。YOLO26モデルは、Intel Core Ultra 2xxVシリーズ、3xxシリーズ、およびそれ以降のプロセッサに搭載されたNPU上でのみ動作します。

Intel Core Ultra X7 358H#

Intel Core Ultra X7 358H(Panther Lake)は、CPUコア、Intel Arc内蔵GPU、Intel AI Boost NPUを搭載しています。

画像あたりのミリ秒数。値が小さいほど優れています。各モデルで最速の列を太字で示しています。

モデルPyTorch CPUCPU 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

旧世代のIntel Core Ultraプロセッサ#

Intel Core Ultra 7 258V(Lunar Lake)

画像あたりのミリ秒数。値が小さいほど優れています。各モデルで最速の列を太字で示しています。

モデルPyTorch CPUCPU 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)

画像あたりのミリ秒数。値が小さいほど優れています。各モデルで最速の列を太字で示しています。

モデルPyTorch CPUCPU 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

3つのプロセッサ全体では、次のとおりです。

  • CPU: INT8はFP32より1.2~3.8倍、PyTorchより2.9~6.0倍高速でした。X7 358Hと155Hでは、FP32はPyTorchより1.6~2.5倍高速でしたが、258VではYOLO26m、YOLO26l、YOLO26xでPyTorchより低速でした。
  • GPU: 内蔵GPUでは、FP32モデルがCPU上のPyTorchより3.6~29.1倍高速でした。X7 358Hと258Vでは、YOLO26nを除くすべてのモデルでINT8がFP32より高速で、最大2.3倍でした。
  • NPU(X7 358Hと258V): FP32モデルはCPU上のPyTorchより1.2~16.2倍高速で、INT8はFP32の0.88~1.19倍の速度でした。これらのINT8モデルは、device=npuで対称アクティベーションが選択される前にエクスポートされたため、表にはNPU向けに最適化されたINT8エクスポートは掲載されていません。
  • すべてのデバイスで、FP16のレイテンシはFP32との差が5%以内で、INT8ではmAP50-95が0.1~2.7ポイント低下しました。

OpenVINOについて#

OpenVINOは、オープンなビジュアル推論とニューラルネットワーク最適化を略した名称であり、PyTorchなどのフレームワークからモデルをIR形式に変換し、単一のAPIを通じてIntelのCPU、GPU、NPU上で実行します。完全なリファレンスについては、OpenVINOのドキュメントをご覧ください。

OpenVINO Intel AI inference toolkit



視聴: 推論を高速化するためにUltralytics YOLO26をIntel OpenVINO形式にエクスポートする方法 🚀

よくある質問#

  • はい、CPUで動作します。OpenVINOのCPUデバイスはx86-64およびARM64プロセッサで動作します。このページのサーバーCPUベンチマークはAMD EPYCプロセッサで測定されており、同じエクスポートはAppleシリコンでも動作します。GPUおよびNPUデバイスにはIntelハードウェアが必要なため、他のマシンではdevice=xpuおよびdevice=npuは警告を出してフォールバックします。他のターゲットについては、モデルデプロイオプションガイドをご覧ください。

  • デバイスによって異なります。FP16(quantize=16)はキャリブレーションデータが不要で、モデルサイズを半分にでき、ベンチマークではFP32の精度とレイテンシを維持できたため、モデルサイズが重要な場合に適しています。ほとんどのモデルでは、INT8(quantize=8)がCPUレイテンシを最も低くしました。サーバーCPUでは、YOLO26sのレイテンシが画像あたり5.18 msから4.51 msに短縮され、mAPval 50-95は47.6となりました(FP32では48.5)。また、Intel Core Ultra CPUではFP32より1.2~3.8倍高速でした。内蔵Intel GPUでのINT8の速度向上は小さく、最大2.3倍でした。また、今回の実行で使用したNPUでは、device=npuを使わずにエクスポートしたINT8モデルは、FP32とほぼ同じ速度でした。INT8では代表的なキャリブレーションデータが必要になるため、採用する前にご自身のデータでINT8モデルを検証してください。

  • dynamic=Trueを指定してエクスポートし、予測時に必要なバッチサイズとimgszを渡します。画像サイズはモデルのストライドの倍数である必要があります。分類モデルを除く公式YOLO26チェックポイントのストライドは32です。例外についてはデプロイをご覧ください。

    動的エクスポート
    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)  # 320ピクセルの画像を4枚まとめたバッチ
  • デプロイ先のハードウェアがIntelの場合はOpenVINOを使用してください。device=xpuとdevice=npuでIntel GPUとNPUを選択でき、ベンチマークでは、INT8のOpenVINOモデルがIntel Core Ultra CPU上でFP32より1.2~3.8倍高速でした。1つのファイルをNVIDIAまたはAMDのGPU、あるいはOpenVINO以外のランタイムでも実行する必要がある場合は、ONNXを使用してください。Windowsでは、Windows MLを使ってONNXモデル向けにIntelハードウェアを選択できます。

コメント23

質問したり、結果を共有したり、ほかの人をサポートしたりできます。

  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(編集済み)

      @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(編集済み)

      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(編集済み)

      @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(編集済み)

      @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(編集済み)

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