Intel OpenVINO-Export
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.
| Aufgabe | YOLOv8 | YOLO11 | YOLO26 |
|---|---|---|---|
| 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.
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/'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")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#
| Argument | Typ | Standard | Beschreibung |
|---|---|---|---|
format | str | 'openvino' | Zielformat des exportierten Modells, das die Kompatibilität mit verschiedenen Bereitstellungsumgebungen festlegt. |
imgsz | int oder tuple | 640 | Gewünschte Bildgröße für die Modelleingabe. Kann eine Ganzzahl für quadratische Bilder oder ein Tupel (height, width) für bestimmte Abmessungen sein. |
quantize | int oder str | None | Quantisierungsgenauigkeit: 16 (FP16) oder 8 (INT8/PTQ; benötigt Kalibrierung data/fraction); 32/nicht gesetzt entspricht FP32. Ersetzt die veralteten Flags half/int8. |
dynamic | bool | False | Ermöglicht dynamische Eingabegrößen und sorgt so für mehr Flexibilität beim Umgang mit unterschiedlichen Bildabmessungen. |
nms | bool, optional | None | Wähle die Rohausgabe (None, Standard), eingebettetes NMS (True) oder den NMS-freien Kopf (False). |
batch | int | 1 | Gibt 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. |
data | str | None | Pfad 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. |
fraction | float, int oder list | 1.0 | Kalibrierungsteilstichprobe 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. |
device | str | None | OpenVINO-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.
OpenVINO™ ist mit den meisten Intel®-Prozessoren kompatibel. Für optimale Leistung solltest du jedoch:
-
OpenVINO™-Unterstützung überprüfen Prüfe anhand der Intel-Kompatibilitätsliste, ob dein Intel®-Chip offiziell von OpenVINO™ unterstützt wird.
-
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.
-
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#
- Leistung: OpenVINO ermöglicht leistungsstarke Inferenz auf Intel-CPUs, integrierten und separaten GPUs sowie NPUs.
- 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.
- 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.
- 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:
- XML-Datei: Beschreibt die Netzwerktopologie.
- BIN-Datei: Enthält die binären Daten zu Gewichten und Biases.
- Metadatendatei:
metadata.yamlenthä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:
-
Verwende das Paket
ultralytics, das eine High-Level-API bereitstellt und die OpenVINO Runtime einbindet. -
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 sollDieser 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:
- Initialisiere OpenVINO, indem du
core = Core()erstellst. - Lade das Modell mit der Methode
core.read_model(). - Kompiliere das Modell mit der Funktion
core.compile_model(). - Bereite die Eingabe vor (Bild, Text, Audio usw.).
- 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.
-
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
openvinoausgefü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#
Detaillierte Benchmark-Ergebnisse
| Modell | Format | Precision | Status | Größe (MB) | metrics/mAP50-95(B) | Inferenzzeit (ms/Bild) |
|---|---|---|---|---|---|---|
| YOLO26n | PyTorch (CPU) | FP32 | ✅ | 5.3 | 0.4765 | 29.28 |
| YOLO26n | OpenVINO | FP32 | ✅ | 9.7 | 0.4762 | 4.09 |
| YOLO26n | OpenVINO | FP16 | ✅ | 5.1 | 0.4762 | 4.03 |
| YOLO26n | OpenVINO | INT8 | ✅ | 3.2 | 0.4634 | 4.24 |
| YOLO26s | PyTorch (CPU) | FP32 | ✅ | 19.5 | 0.5703 | 59.32 |
| YOLO26s | OpenVINO | FP32 | ✅ | 36.7 | 0.5616 | 5.08 |
| YOLO26s | OpenVINO | FP16 | ✅ | 18.7 | 0.5616 | 5.14 |
| YOLO26s | OpenVINO | INT8 | ✅ | 10.0 | 0.5462 | 4.47 |
| YOLO26m | PyTorch (CPU) | FP32 | ✅ | 42.2 | 0.6196 | 143.21 |
| YOLO26m | OpenVINO | FP32 | ✅ | 78.4 | 0.6166 | 7.1 |
| YOLO26m | OpenVINO | FP16 | ✅ | 39.5 | 0.6166 | 7.06 |
| YOLO26m | OpenVINO | INT8 | ✅ | 20.6 | 0.6055 | 5.61 |
| YOLO26l | PyTorch (CPU) | FP32 | ✅ | 50.7 | 0.6215 | 181.16 |
| YOLO26l | OpenVINO | FP32 | ✅ | 95.3 | 0.6205 | 8.45 |
| YOLO26l | OpenVINO | FP16 | ✅ | 48.1 | 0.6205 | 8.49 |
| YOLO26l | OpenVINO | INT8 | ✅ | 25.2 | 0.5938 | 6.25 |
| YOLO26x | PyTorch (CPU) | FP32 | ✅ | 113.2 | 0.6512 | 379.75 |
| YOLO26x | OpenVINO | FP32 | ✅ | 213.3 | 0.6568 | 13.03 |
| YOLO26x | OpenVINO | FP16 | ✅ | 107.1 | 0.6568 | 12.98 |
| YOLO26x | OpenVINO | INT8 | ✅ | 54.8 | 0.6385 | 8.74 |
Intel® Core™ Ultra™ 7 258V#
Detaillierte Benchmark-Ergebnisse
| Modell | Format | Precision | Status | Größe (MB) | metrics/mAP50-95(B) | Inferenzzeit (ms/Bild) |
|---|---|---|---|---|---|---|
| YOLO26n | PyTorch (CPU) | FP32 | ✅ | 5.3 | 0.4765 | 27.33 |
| YOLO26n | OpenVINO | FP32 | ✅ | 9.6 | 0.4764 | 3.33 |
| YOLO26n | OpenVINO | FP16 | ✅ | 5.1 | 0.4764 | 3.34 |
| YOLO26n | OpenVINO | INT8 | ✅ | 3.2 | 0.4634 | 3.46 |
| YOLO26s | PyTorch (CPU) | FP32 | ✅ | 19.5 | 0.5703 | 60.2 |
| YOLO26s | OpenVINO | FP32 | ✅ | 36.7 | 0.5616 | 4.66 |
| YOLO26s | OpenVINO | FP16 | ✅ | 18.6 | 0.5616 | 4.65 |
| YOLO26s | OpenVINO | INT8 | ✅ | 10.0 | 0.5462 | 3.99 |
| YOLO26m | PyTorch (CPU) | FP32 | ✅ | 42.2 | 0.6196 | 152.87 |
| YOLO26m | OpenVINO | FP32 | ✅ | 78.4 | 0.6168 | 9.03 |
| YOLO26m | OpenVINO | FP16 | ✅ | 39.5 | 0.6168 | 8.98 |
| YOLO26m | OpenVINO | INT8 | ✅ | 20.6 | 0.6055 | 5.7 |
| YOLO26l | PyTorch (CPU) | FP32 | ✅ | 50.7 | 0.6215 | 201.57 |
| YOLO26l | OpenVINO | FP32 | ✅ | 95.3 | 0.6203 | 11.32 |
| YOLO26l | OpenVINO | FP16 | ✅ | 48.1 | 0.6203 | 11.36 |
| YOLO26l | OpenVINO | INT8 | ✅ | 25.2 | 0.5938 | 7.45 |
| YOLO26x | PyTorch (CPU) | FP32 | ✅ | 113.2 | 0.6512 | 431.04 |
| YOLO26x | OpenVINO | FP32 | ✅ | 213.2 | 0.6568 | 19.08 |
| YOLO26x | OpenVINO | FP16 | ✅ | 107.1 | 0.6568 | 19.63 |
| YOLO26x | OpenVINO | INT8 | ✅ | 54.8 | 0.6385 | 13.69 |
Intel® Core™ Ultra™ 7 155H#
Detaillierte Benchmark-Ergebnisse
| Modell | Format | Precision | Status | Größe (MB) | metrics/mAP50-95(B) | Inferenzzeit (ms/Bild) |
|---|---|---|---|---|---|---|
| YOLO26n | PyTorch (CPU) | FP32 | ✅ | 5.3 | 0.4765 | 33.19 |
| YOLO26n | OpenVINO | FP32 | ✅ | 9.6 | 0.4758 | 9.13 |
| YOLO26n | OpenVINO | FP16 | ✅ | 5.1 | 0.4758 | 9.07 |
| YOLO26n | OpenVINO | INT8 | ✅ | 3.2 | 0.4573 | 5.79 |
| YOLO26s | PyTorch (CPU) | FP32 | ✅ | 19.5 | 0.5703 | 70.92 |
| YOLO26s | OpenVINO | FP32 | ✅ | 36.7 | 0.5616 | 16.37 |
| YOLO26s | OpenVINO | FP16 | ✅ | 18.6 | 0.5616 | 16.65 |
| YOLO26s | OpenVINO | INT8 | ✅ | 10.0 | 0.545 | 9.27 |
| YOLO26m | PyTorch (CPU) | FP32 | ✅ | 42.2 | 0.6196 | 192.45 |
| YOLO26m | OpenVINO | FP32 | ✅ | 78.4 | 0.6167 | 34.47 |
| YOLO26m | OpenVINO | FP16 | ✅ | 39.5 | 0.6167 | 35.71 |
| YOLO26m | OpenVINO | INT8 | ✅ | 20.6 | 0.6039 | 15.46 |
| YOLO26l | PyTorch (CPU) | FP32 | ✅ | 50.7 | 0.6215 | 239.19 |
| YOLO26l | OpenVINO | FP32 | ✅ | 95.3 | 0.621 | 43.24 |
| YOLO26l | OpenVINO | FP16 | ✅ | 48.1 | 0.621 | 43.4 |
| YOLO26l | OpenVINO | INT8 | ✅ | 25.2 | 0.5999 | 19.72 |
| YOLO26x | PyTorch (CPU) | FP32 | ✅ | 113.2 | 0.6512 | 511.89 |
| YOLO26x | OpenVINO | FP32 | ✅ | 213.2 | 0.6552 | 79.49 |
| YOLO26x | OpenVINO | FP16 | ✅ | 107.1 | 0.6552 | 79.45 |
| YOLO26x | OpenVINO | INT8 | ✅ | 54.8 | 0.642 | 34.66 |
Unsere Ergebnisse reproduzieren#
Um die obigen Ultralytics-Benchmarks für alle Exportformate zu reproduzieren, führe diesen Code aus:
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:
Beispielfrom 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:
- Leistung: Erzielt eine bis zu dreimal höhere Geschwindigkeit bei CPU-Inferenz und nutzt Intel-GPUs und -NPUs zur Beschleunigung.
- Modellkonvertierung: Konvertiert, optimiert und führt Modelle aus beliebten Frameworks wie PyTorch, TensorFlow und ONNX aus.
- Benutzerfreundlichkeit: Eine große Auswahl an Tutorial-Notebooks erleichtert den Einstieg, darunter auch Notebooks für YOLO26.
- 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:
Beispielfrom 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:
Beispielfrom 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.
Heyujie96
how can i export a trained cls or obb kind model to openvino kind
EduardoNew
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.appimage 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?
Glenn JocherUltralytics(bearbeitet)@EduardoNew the exit code 0xC0000005 often indicates a memory access violation. Let's address this step-by-step:
-
Path Format: Try using forward slashes in your OpenVINO model path:
"yolov8n_openvino_model/"instead of backslashes. -
OpenVINO Version: Ultralytics requires
openvino>=2024.0.0. Try upgrading to a recent release:
pip install -U openvino- 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!
-
Ranjith3436
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.
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.
Ranjith3436
how do i can know about model's ability?
Glenn JocherUltralyticsTo 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.
kimchi2020
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
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
-
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/' -
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! 🚀
-
kimchi2020
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
Glenn JocherUltralyticsHi @kimchi2020,
Thank you for reaching out! The error you're encountering seems to be related to a circular import issue with the
torchvisionlibrary. This can happen if there's a naming conflict or an import loop in your code.Steps to Resolve the Issue:
-
Check for Naming Conflicts: Ensure that your script name (
onnx.py) is not conflicting with any library names. Rename your script to something unique, likerun_inference.py. -
Verify Installation: Make sure you have the latest versions of
torch,torchvision, andultralyticsinstalled. You can update them using:pip install --upgrade torch torchvision ultralytics -
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! 🚀
-
YA12SHYAM
Hi @glenn-jocher , what if i want to use intel GPU's for the inference, using device=GPU doesn't seems to works , it looks for cuda i.e nvidia gpu
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 withdevice="intel:gpu", for exampleov_model("bus.jpg", device="intel:gpu"). For more details, please refer to the OpenVINO integration guide.YA12SHYAM
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
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.
kanishkasw
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'
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
torchandultralytics. Please run the following commands to update your packages:pip install --upgrade torch ultralyticsNext, 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 requiresopenvino>=2024.0.0). You can install it using the following command:pip install -U openvinoOnce you've updated the packages, try exporting the model again:
yolo export model=runs/classify/train/weights/best.pt format=openvinoIf 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! 😊
renato-rodrig
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.
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
YouROS12
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.
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 ONNXopsetargument does not apply and the oldmoModel 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 trymodel.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.YouROS12
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.
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.
