Erste Schritte

Intel OpenVINO-Export

OpenVINO Intel AI inference toolkit

Diese Anleitung behandelt den Export von Ultralytics YOLO26-Modellen ins Format OpenVINO, das die CPU um bis zu das Dreifache beschleunigen und die YOLO-Inferenz auf Intel-GPU- und NPU-Hardware beschleunigen kann.

OpenVINO, die Abkürzung für Open Visual Inference & Toolkit zur Optimierung neuronaler Netze, ist Intels Toolkit zur Optimierung und Bereitstellung von KI-Inferenzmodellen. Obwohl der Name den Begriff Visual enthält, unterstützt OpenVINO auch zahlreiche weitere Aufgaben, darunter Sprache, Audio und Zeitreihen.



Ansehen: So exportierst du Ultralytics YOLO26 ins Intel OpenVINO-Format, um die Inferenz zu beschleunigen 🚀

Unterstützte Aufgaben#

Der OpenVINO-Export unterstützt alle sieben Ultralytics-Aufgaben. Semantische Segmentierung und Tiefenschätzung sind nur mit YOLO26 verfügbar, der einzigen Modellfamilie, die diese Köpfe enthält.

AufgabeYOLOv8YOLO11YOLO26
Erkennung✅✅✅
Segmentierung✅✅✅
Semantik❌❌✅
Tiefe❌❌✅
Klassifizierung✅✅✅
Pose✅✅✅
OBB✅✅✅

Installation#

Installiere die Abhängigkeiten für den OpenVINO-Export mit:

pip install "ultralytics[export-openvino]"

Diese Abhängigkeiten sind auch in ultralytics[export] enthalten und werden bei Bedarf automatisch für einen Export installiert.

Anwendungsbeispiele#

Das OpenVINO-Format unterstützt die Modi Export, Vorhersage und Validierung. Exportiere dein Modell und lade es anschließend, um Inferenz auszuführen oder seine Genauigkeit auf einer Intel-CPU, einer integrierten oder separaten GPU oder einer NPU zu überprüfen.

Exportieren
from ultralytics import YOLO

# Ein YOLO26-Modell laden
model = YOLO("yolo26n.pt")

# Modell ins OpenVINO-Format exportieren
model.export(format="openvino")  # creates 'yolo26n_openvino_model/'
Vorhersagen
from ultralytics import YOLO

# Das exportierte OpenVINO-Modell laden
model = YOLO("yolo26n_openvino_model/")

# Inferenz ausführen
results = model("https://ultralytics.com/images/bus.jpg")

# Inferenz auf einem bestimmten Intel-Gerät ausführen: "cpu", "xpu" (GPU) oder "npu"; ist kein Gerät festgelegt, wird OpenVINO AUTO verwendet
results = model("https://ultralytics.com/images/bus.jpg", device="xpu")
Validieren
from ultralytics import YOLO

# Das exportierte OpenVINO-Modell laden
model = YOLO("yolo26n_openvino_model/")

# Die Genauigkeit anhand des COCO8-Datensatzes validieren
metrics = model.val(data="coco8.yaml")

Exportargumente#

ArgumentTypStandardBeschreibung
formatstr'openvino'Zielformat des exportierten Modells, das die Kompatibilität mit verschiedenen Bereitstellungsumgebungen festlegt.
imgszint oder tuple640Gewünschte Bildgröße für die Modelleingabe. Kann eine Ganzzahl für quadratische Bilder oder ein Tupel (height, width) für bestimmte Abmessungen sein.
quantizeint oder strNoneQuantisierungsgenauigkeit: 16 (FP16) oder 8 (INT8/PTQ; benötigt Kalibrierung data/fraction); 32/nicht gesetzt entspricht FP32. Ersetzt die veralteten Flags half/int8.
dynamicboolFalseErmöglicht dynamische Eingabegrößen und sorgt so für mehr Flexibilität beim Umgang mit unterschiedlichen Bildabmessungen.
nmsbool, optionalNoneWähle die Rohausgabe (None, Standard), eingebettetes NMS (True) oder den NMS-freien Kopf (False).
batchint1Gibt die Batchgröße für die Inferenz des Exportmodells oder die Höchstzahl der Bilder an, die das exportierte Modell gleichzeitig im predict-Modus verarbeiten kann.
datastrNonePfad zur YAML-Datei des Datensatzes, die für die Quantisierung erforderlich ist; bei der Klassifizierung wird stattdessen ein Datensatzverzeichnis oder der Name eines integrierten Datensatzes verwendet. Wenn quantize=8 nicht angegeben ist, wählt Ultralytics den Standard-Kalibrierungsdatensatz für die jeweilige Modellaufgabe aus.
fractionfloat, int oder list1.0Kalibrierungsteilstichprobe als Verhältnis, Bildanzahl oder [train, val, test]-Verhältnisse/-Anzahlen. Bei Listen mit zwei Elementen bleibt test vollständig erhalten, während 0 es überspringt.
devicestrNoneOpenVINO-Exporte werden immer auf der CPU nachverfolgt. Mit quantize=8 wählt device=npu symmetrische INT8-Aktivierungen für YOLO-Modelle zur Erkennung, Segmentierung, Posenschätzung und OBB aus. Diese laufen auf Intel-NPUs bis zu 2-mal schneller.

Weitere Informationen zum Exportvorgang findest du auf der Ultralytics-Dokumentationsseite zum Export.

Warnung

OpenVINO™ ist mit den meisten Intel®-Prozessoren kompatibel. Für optimale Leistung solltest du jedoch:

  1. OpenVINO™-Unterstützung überprüfen Prüfe anhand der Intel-Kompatibilitätsliste, ob dein Intel®-Chip offiziell von OpenVINO™ unterstützt wird.

  2. Finde heraus, welche Beschleuniger verfügbar sind Prüfe anhand des Hardware-Leitfadens von Intel, ob dein Prozessor eine integrierte NPU (neuronale Verarbeitungseinheit) oder GPU enthält.

  3. Neueste Treiber installieren Wenn dein Chip eine NPU oder GPU unterstützt, OpenVINO™ diese aber nicht erkennt, musst du möglicherweise die entsprechenden Treiber installieren oder aktualisieren. Folge der Anleitung zur Treiberinstallation, um die volle Beschleunigung zu aktivieren.

Mit diesen drei Schritten stellst du sicher, dass OpenVINO™ optimal auf deiner Intel®-Hardware läuft.

Vorteile von OpenVINO#

  1. Leistung: OpenVINO ermöglicht leistungsstarke Inferenz auf Intel-CPUs, integrierten und separaten GPUs sowie NPUs.
  2. Unterstützung heterogener Ausführung: OpenVINO bietet eine API, mit der du einmal schreibst und die Lösung auf jeder unterstützten Intel-Hardware (CPU, GPU, NPU) bereitstellst.
  3. Modellkonvertierung: Die Modellkonvertierungs-API von OpenVINO importiert, konvertiert und optimiert Modelle aus gängigen Deep-Learning-Frameworks wie PyTorch, TensorFlow, TensorFlow Lite, ONNX und PaddlePaddle.
  4. Einfache Nutzung: Das Toolkit enthält eine umfangreiche Sammlung von Tutorial-Notebooks, darunter YOLO26-Optimierung, die verschiedene Aspekte des Toolkits vermitteln.

Aufbau des OpenVINO-Exports#

Beim Export eines Modells ins OpenVINO-Format wird ein Verzeichnis mit den folgenden Dateien erstellt:

  1. XML-Datei: Beschreibt die Netzwerktopologie.
  2. BIN-Datei: Enthält die binären Daten zu Gewichten und Biases.
  3. Metadatendatei: metadata.yaml enthält Modellmetadaten wie Klassennamen, Bildgröße und Aufgabe, die Ultralytics beim Laden des Modells ausliest.

Mit diesen Dateien kannst du Inferenz mit der OpenVINO Runtime ausführen.

OpenVINO-Export bei der Bereitstellung verwenden#

Nachdem du dein Modell erfolgreich ins OpenVINO-Format exportiert hast, stehen dir zwei Hauptoptionen für die Inferenz zur Verfügung:

  1. Verwende das Paket ultralytics, das eine High-Level-API bereitstellt und die OpenVINO Runtime einbindet.

  2. Verwende das native Paket openvino, um das Inferenzverhalten umfassender oder individueller zu steuern.

Inferenz mit Ultralytics#

Das Paket ultralytics führt die Inferenz des exportierten OpenVINO-Modells mit der Methode predict aus. Mit dem Geräteargument kannst du auch das Intel-Zielgerät angeben (cpu, xpu für die GPU oder npu). Ohne Angabe wählt OpenVINO AUTO das Gerät aus. Unter Inferenzgeräte erfährst du, wie die einzelnen Formate Gerätenamen zuordnen.

from ultralytics import YOLO

# Das exportierte OpenVINO-Modell laden
ov_model = YOLO("yolo26n_openvino_model/")  # Pfad zu deinem exportierten OpenVINO-Modell
# Inferenz mit dem exportierten Modell ausführen
ov_model.predict(device="xpu")  # Gib das Gerät an, auf dem die Inferenz ausgeführt werden soll

Dieser Ansatz eignet sich für schnelles Prototyping oder die Bereitstellung, wenn du keine vollständige Kontrolle über die Inferenzpipeline benötigst.

Inferenz mit der OpenVINO Runtime#

Die OpenVINO Runtime bietet eine einheitliche API für die Inferenz auf allen unterstützten Intel-Geräten. Außerdem bietet sie erweiterte Funktionen wie den Lastausgleich zwischen Intel-Geräten und die asynchrone Ausführung.

Beachte: Für die korrekte Einrichtung und Verwendung des Modells mit der Runtime benötigst du die XML- und BIN-Dateien sowie anwendungsspezifische Einstellungen wie Eingabegröße, Skalierungsfaktor für die Normalisierung usw.

In deiner Bereitstellungsanwendung würdest du normalerweise die folgenden Schritte ausführen:

  1. Initialisiere OpenVINO, indem du core = Core() erstellst.
  2. Lade das Modell mit der Methode core.read_model().
  3. Kompiliere das Modell mit der Funktion core.compile_model().
  4. Bereite die Eingabe vor (Bild, Text, Audio usw.).
  5. Führe die Inferenz mit compiled_model(input_data) aus.

Ausführlichere Schritte und Codebeispiele findest du in der OpenVINO-Dokumentation oder im API-Tutorial.

YOLO26-Benchmarks mit OpenVINO#

Das Ultralytics-Team hat YOLO26 mit verschiedenen Modellformaten und Genauigkeitsstufen (FP32, FP16 und INT8) auf unterschiedlichen Intel-Geräten getestet, die mit OpenVINO kompatibel sind, und dabei Geschwindigkeit und Genauigkeit bewertet.

Hinweis
  • Die folgenden Benchmark-Ergebnisse dienen nur als Referenz. Sie können je nach genauer Hardware- und Softwarekonfiguration des Systems sowie der aktuellen Systemauslastung während der Messung abweichen.

  • Alle Benchmarks wurden mit der Version 2026.2.1 des Python-Pakets openvino ausgeführt.

  • YOLO26-Modelle werden auf NPUs nur auf Intel® Core™ Ultra™-Systemen der Reihen 2xxV und 3xx sowie neueren Reihen unterstützt.

Intel® Core™ Ultra#

Die Intel® Core™ Ultra™-Serie vereint CPU-Kerne, eine integrierte GPU und eine dedizierte neuronale Verarbeitungseinheit (NPU) in einem Chip. So kann ein System herkömmliche Verarbeitungsaufgaben, GPU-beschleunigte Arbeitslasten und KI-Inferenz direkt auf dem Gerät ausführen.

Dank dieses Hybridaufbaus kann OpenVINO Inferenz je nach Latenz-, Durchsatz- und Leistungsbedarf einer Anwendung auf der CPU, GPU oder NPU ausführen. Die Produktreihe reicht von energieeffizienten Ausführungen bis zu leistungsstarken Varianten mit der Kennzeichnung „H“, die für Laptops und kompakte Geräte mit höherem Rechenbedarf vorgesehen sind.

Die folgenden Benchmarks wurden mit Intel® Core™ Ultra™ X7 358H, Intel® Core™ Ultra™ 7 258V und Intel® Core™ Ultra™ 7 155H mit FP32-, FP16- und INT8-Genauigkeit ausgeführt.

Intel® Core™ Ultra™ X7 358H#

Benchmarks
YOLO26 OpenVINO benchmarks on the Intel Core Ultra X7 358H integrated Arc GPU
Detaillierte Benchmark-Ergebnisse
ModellFormatPrecisionStatusGröße (MB)metrics/mAP50-95(B)Inferenzzeit (ms/Bild)
YOLO26nPyTorch (CPU)FP32✅5.30.476529.28
YOLO26nOpenVINOFP32✅9.70.47624.09
YOLO26nOpenVINOFP16✅5.10.47624.03
YOLO26nOpenVINOINT8✅3.20.46344.24
YOLO26sPyTorch (CPU)FP32✅19.50.570359.32
YOLO26sOpenVINOFP32✅36.70.56165.08
YOLO26sOpenVINOFP16✅18.70.56165.14
YOLO26sOpenVINOINT8✅10.00.54624.47
YOLO26mPyTorch (CPU)FP32✅42.20.6196143.21
YOLO26mOpenVINOFP32✅78.40.61667.1
YOLO26mOpenVINOFP16✅39.50.61667.06
YOLO26mOpenVINOINT8✅20.60.60555.61
YOLO26lPyTorch (CPU)FP32✅50.70.6215181.16
YOLO26lOpenVINOFP32✅95.30.62058.45
YOLO26lOpenVINOFP16✅48.10.62058.49
YOLO26lOpenVINOINT8✅25.20.59386.25
YOLO26xPyTorch (CPU)FP32✅113.20.6512379.75
YOLO26xOpenVINOFP32✅213.30.656813.03
YOLO26xOpenVINOFP16✅107.10.656812.98
YOLO26xOpenVINOINT8✅54.80.63858.74

Intel® Core™ Ultra™ 7 258V#

Benchmarks
YOLO26 OpenVINO benchmarks on the Intel Core Ultra 7 258V integrated Arc GPU
Detaillierte Benchmark-Ergebnisse
ModellFormatPrecisionStatusGröße (MB)metrics/mAP50-95(B)Inferenzzeit (ms/Bild)
YOLO26nPyTorch (CPU)FP32✅5.30.476527.33
YOLO26nOpenVINOFP32✅9.60.47643.33
YOLO26nOpenVINOFP16✅5.10.47643.34
YOLO26nOpenVINOINT8✅3.20.46343.46
YOLO26sPyTorch (CPU)FP32✅19.50.570360.2
YOLO26sOpenVINOFP32✅36.70.56164.66
YOLO26sOpenVINOFP16✅18.60.56164.65
YOLO26sOpenVINOINT8✅10.00.54623.99
YOLO26mPyTorch (CPU)FP32✅42.20.6196152.87
YOLO26mOpenVINOFP32✅78.40.61689.03
YOLO26mOpenVINOFP16✅39.50.61688.98
YOLO26mOpenVINOINT8✅20.60.60555.7
YOLO26lPyTorch (CPU)FP32✅50.70.6215201.57
YOLO26lOpenVINOFP32✅95.30.620311.32
YOLO26lOpenVINOFP16✅48.10.620311.36
YOLO26lOpenVINOINT8✅25.20.59387.45
YOLO26xPyTorch (CPU)FP32✅113.20.6512431.04
YOLO26xOpenVINOFP32✅213.20.656819.08
YOLO26xOpenVINOFP16✅107.10.656819.63
YOLO26xOpenVINOINT8✅54.80.638513.69

Intel® Core™ Ultra™ 7 155H#

Benchmarks
YOLO26 OpenVINO benchmarks on the Intel Core Ultra 7 155H integrated Arc GPU
Detaillierte Benchmark-Ergebnisse
ModellFormatPrecisionStatusGröße (MB)metrics/mAP50-95(B)Inferenzzeit (ms/Bild)
YOLO26nPyTorch (CPU)FP32✅5.30.476533.19
YOLO26nOpenVINOFP32✅9.60.47589.13
YOLO26nOpenVINOFP16✅5.10.47589.07
YOLO26nOpenVINOINT8✅3.20.45735.79
YOLO26sPyTorch (CPU)FP32✅19.50.570370.92
YOLO26sOpenVINOFP32✅36.70.561616.37
YOLO26sOpenVINOFP16✅18.60.561616.65
YOLO26sOpenVINOINT8✅10.00.5459.27
YOLO26mPyTorch (CPU)FP32✅42.20.6196192.45
YOLO26mOpenVINOFP32✅78.40.616734.47
YOLO26mOpenVINOFP16✅39.50.616735.71
YOLO26mOpenVINOINT8✅20.60.603915.46
YOLO26lPyTorch (CPU)FP32✅50.70.6215239.19
YOLO26lOpenVINOFP32✅95.30.62143.24
YOLO26lOpenVINOFP16✅48.10.62143.4
YOLO26lOpenVINOINT8✅25.20.599919.72
YOLO26xPyTorch (CPU)FP32✅113.20.6512511.89
YOLO26xOpenVINOFP32✅213.20.655279.49
YOLO26xOpenVINOFP16✅107.10.655279.45
YOLO26xOpenVINOINT8✅54.80.64234.66

Unsere Ergebnisse reproduzieren#

Um die obigen Ultralytics-Benchmarks für alle Exportformate zu reproduzieren, führe diesen Code aus:

Beispiel
from ultralytics import YOLO

# Ein YOLO26n-PyTorch-Modell laden
model = YOLO("yolo26n.pt")

# Benchmark für Geschwindigkeit und Genauigkeit von YOLO26n auf dem COCO128-Datensatz für alle Exportformate
results = model.benchmark(data="coco128.yaml")

# Nur OpenVINO auf einem bestimmten Intel-Gerät benchmarken: "cpu", "xpu" oder "npu"
results = model.benchmark(data="coco128.yaml", format="openvino", device="npu")

Beachte, dass die Benchmark-Ergebnisse je nach genauer Hard- und Softwarekonfiguration eines Systems sowie der aktuellen Arbeitslast zum Zeitpunkt der Messung variieren können. Für möglichst zuverlässige Ergebnisse solltest du einen Datensatz mit vielen Bildern verwenden, zum Beispiel COCO (data='coco.yaml', 5000 Validierungsbilder).

Fazit#

Die Benchmark-Ergebnisse zeigen die Vorteile des Exports von YOLO26-Modellen ins OpenVINO-Format. Bei verschiedenen Modellgrößen und Intel-Geräten führt OpenVINO Inferenz wesentlich schneller als PyTorch aus und hält dabei eine vergleichbare Genauigkeit aufrecht.

Durch die Konvertierung von Modellen in das OpenVINO-Format können Entwickler deutliche Leistungssteigerungen auf Intel-CPUs, -GPUs und -NPUs erzielen. Dadurch lassen sich diese Modelle leichter in realen Anwendungen einsetzen.

Ausführlichere Informationen und Anleitungen zur Verwendung von OpenVINO findest du in der offiziellen OpenVINO-Dokumentation.

Häufig gestellte Fragen#

  • Der Export von YOLO26-Modellen ins OpenVINO-Format kann die CPU-Geschwindigkeit deutlich erhöhen und GPU- sowie NPU-Beschleunigung auf Intel-Hardware ermöglichen. Für den Export kannst du wie unten gezeigt entweder Python oder die CLI verwenden:

    Beispiel
    from ultralytics import YOLO
    
    # Ein YOLO26n-PyTorch-Modell laden
    model = YOLO("yolo26n.pt")
    
    # Modell exportieren
    model.export(format="openvino")  # creates 'yolo26n_openvino_model/'

    Weitere Informationen findest du in der Dokumentation zu Exportformaten.

  • Die Verwendung des OpenVINO-Toolkits von Intel mit YOLO26-Modellen bietet mehrere Vorteile:

    1. Leistung: Erzielt eine bis zu dreimal höhere Geschwindigkeit bei CPU-Inferenz und nutzt Intel-GPUs und -NPUs zur Beschleunigung.
    2. Modellkonvertierung: Konvertiert, optimiert und führt Modelle aus beliebten Frameworks wie PyTorch, TensorFlow und ONNX aus.
    3. Benutzerfreundlichkeit: Eine große Auswahl an Tutorial-Notebooks erleichtert den Einstieg, darunter auch Notebooks für YOLO26.
    4. Heterogene Ausführung: Stelle Modelle mit einer einheitlichen API auf unterschiedlicher Intel-Hardware bereit.

    Ausführliche Leistungsvergleiche findest du in unserem Benchmark-Abschnitt.

  • Nachdem du ein YOLO26n-Modell ins OpenVINO-Format exportiert hast, kannst du die Inferenz mit Python oder der CLI ausführen:

    Beispiel
    from ultralytics import YOLO
    
    # Das exportierte OpenVINO-Modell laden
    ov_model = YOLO("yolo26n_openvino_model/")
    
    # Inferenz ausführen
    results = ov_model("https://ultralytics.com/images/bus.jpg")

    Weitere Informationen findest du in unserer Dokumentation zum Vorhersagemodus.

  • Ultralytics YOLO26 ist für die Objekterkennung in Echtzeit mit hoher Genauigkeit und Geschwindigkeit optimiert. In Verbindung mit OpenVINO bietet YOLO26 insbesondere:

    • Bis zu dreifache Beschleunigung auf Intel-CPUs
    • Bereitstellung auf Intel-GPUs und -NPUs
    • Konstante und vergleichbare Genauigkeit über verschiedene Exportformate hinweg

    Eine ausführliche Leistungsanalyse findest du in unseren detaillierten YOLO26-Benchmarks für unterschiedliche Hardware.

  • Ja, du kannst YOLO26-Modelle in verschiedenen Formaten benchmarken, darunter PyTorch, TorchScript, ONNX und OpenVINO. Mit dem folgenden Codeausschnitt kannst du Benchmarks für deinen ausgewählten Datensatz ausführen:

    Beispiel
    from ultralytics import YOLO
    
    # Ein YOLO26n-PyTorch-Modell laden
    model = YOLO("yolo26n.pt")
    
    # Geschwindigkeit und Genauigkeit von YOLO26n auf dem COCO8-Datensatz für alle Exportformate benchmarken
    results = model.benchmark(data="coco8.yaml")

    Ausführliche Benchmark-Ergebnisse findest du in unserem Benchmark-Abschnitt und in der Dokumentation zu Exportformaten.

Kommentare23

Stell eine Frage, teile deine Ergebnisse oder hilf jemand anderem.

  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(bearbeitet)

      @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(bearbeitet)

      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(bearbeitet)

      @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(bearbeitet)

      @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(bearbeitet)

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