Zum Inhalt springen

Optimizing YOLO11 Inferences with Neural Magic's DeepSparse Engine

When deploying object detection models like Ultralytics YOLO11 on various hardware, you can bump into unique issues like optimization. This is where YOLO11's integration with Neural Magic's DeepSparse Engine steps in. It transforms the way YOLO11 models are executed and enables GPU-level performance directly on CPUs.

This guide shows you how to deploy YOLO11 using Neural Magic's DeepSparse, how to run inferences, and also how to benchmark performance to ensure it is optimized.

Neural Magic's DeepSparse

Neural Magic's DeepSparse Übersicht

Neural Magic's DeepSparse is an inference run-time designed to optimize the execution of neural networks on CPUs. It applies advanced techniques like sparsity, pruning, and quantization to dramatically reduce computational demands while maintaining accuracy. DeepSparse offers an agile solution for efficient and scalable neural network execution across various devices.

Benefits of Integrating Neural Magic's DeepSparse with YOLO11

Bevor Sie sich mit der Bereitstellung befassen YOLOV8 Lassen Sie uns mit DeepSparse die Vorteile der Verwendung von DeepSparse verstehen. Einige wichtige Vorteile sind:

  • Enhanced Inference Speed: Achieves up to 525 FPS (on YOLO11n), significantly speeding up YOLO11's inference capabilities compared to traditional methods.

Erhöhte Inferenzgeschwindigkeit

  • Optimized Model Efficiency: Uses pruning and quantization to enhance YOLO11's efficiency, reducing model size and computational requirements while maintaining accuracy.

Optimierte Modell-Effizienz

  • Hohe Leistung auf Standard-CPUs: Bietet eine GPU-ähnliche Leistung auf CPUs und damit eine leichter zugängliche und kostengünstige Option für verschiedene Anwendungen.

  • Streamlined Integration and Deployment: Offers user-friendly tools for easy integration of YOLO11 into applications, including image and video annotation features.

  • Support for Various Model Types: Compatible with both standard and sparsity-optimized YOLO11 models, adding deployment flexibility.

  • Kosteneffiziente und skalierbare Lösung: Reduziert die Betriebskosten und bietet eine skalierbare Bereitstellung von fortschrittlichen Objekterkennungsmodellen.

Wie funktioniert die DeepSparse-Technologie von Neural Magic?

Neural MagicDie Deep Sparse-Technologie von ist von der Effizienz des menschlichen Gehirns bei der Berechnung neuronaler Netze inspiriert. Es übernimmt zwei Schlüsselprinzipien aus dem Gehirn:

  • Sparsity: The process of sparsification involves pruning redundant information from deep learning networks, leading to smaller and faster models without compromising accuracy. This technique reduces the network's size and computational needs significantly.

  • Lokalität der Referenz: DeepSparse verwendet eine einzigartige Ausführungsmethode, bei der das Netzwerk in Tensor Spalten aufgeteilt wird. Diese Spalten werden in der Tiefe ausgeführt und passen vollständig in den Cache von CPU. Dieser Ansatz ahmt die Effizienz des Gehirns nach, indem er die Datenbewegungen minimiert und die Nutzung des Caches von CPU maximiert.

So funktioniert Neural Magic's DeepSparse Technologie

Weitere Details zur Funktionsweise der DeepSparse-Technologie von Neural Magic findest du in ihrem Blogbeitrag.

Creating A Sparse Version of YOLO11 Trained on a Custom Dataset

SparseZoo, an open-source model repository by Neural Magic, offers a collection of pre-sparsified YOLO11 model checkpoints. With SparseML, seamlessly integrated with Ultralytics, users can effortlessly fine-tune these sparse checkpoints on their specific datasets using a straightforward command-line interface.

Checkout Neural Magic's SparseML YOLO11 documentation for more details.

Verwendung: Einsatz von YOLOV8 mit DeepSparse

Deploying YOLO11 with Neural Magic's DeepSparse involves a few straightforward steps. Before diving into the usage instructions, be sure to check out the range of YOLO11 models offered by Ultralytics. This will help you choose the most appropriate model for your project requirements. Here's how you can get started.

Schritt 1: Installation

Um die benötigten Pakete zu installieren, führe sie aus:

Installation

# Install the required packages
pip install deepsparse[yolov8]

Step 2: Exporting YOLO11 to ONNX Format

DeepSparse Engine requires YOLO11 models in ONNX format. Exporting your model to this format is essential for compatibility with DeepSparse. Use the following command to export YOLO11 models:

Modell Export

# Export YOLO11 model to ONNX format
yolo task=detect mode=export model=yolo11n.pt format=onnx opset=13

Dieser Befehl speichert die yolo11n.onnx Modell auf deiner Festplatte.

Schritt 3: Einsetzen und Ausführen von Schlussfolgerungen

With your YOLO11 model in ONNX format, you can deploy and run inferences using DeepSparse. This can be done easily with their intuitive Python API:

Einsetzen und Ausführen von Schlussfolgerungen

from deepsparse import Pipeline

# Specify the path to your YOLO11 ONNX model
model_path = "path/to/yolo11n.onnx"

# Set up the DeepSparse Pipeline
yolo_pipeline = Pipeline.create(task="yolov8", model_path=model_path)

# Run the model on your images
images = ["path/to/image.jpg"]
pipeline_outputs = yolo_pipeline(images=images)

Schritt 4: Benchmarking der Leistung

It's important to check that your YOLO11 model is performing optimally on DeepSparse. You can benchmark your model's performance to analyze throughput and latency:

Benchmarking

# Benchmark performance
deepsparse.benchmark model_path="path/to/yolo11n.onnx" --scenario=sync --input_shapes="[1,3,640,640]"

Schritt 5: Zusätzliche Funktionen

DeepSparse provides additional features for practical integration of YOLO11 in applications, such as image annotation and dataset evaluation.

Zusätzliche Merkmale

# For image annotation
deepsparse.yolov8.annotate --source "path/to/image.jpg" --model_filepath "path/to/yolo11n.onnx"

# For evaluating model performance on a dataset
deepsparse.yolov8.eval --model_path "path/to/yolo11n.onnx"

Wenn du den Befehl annotate ausführst, wird dein angegebenes Bild verarbeitet, Objekte werden erkannt und das annotierte Bild mit Begrenzungsrahmen und Klassifizierungen gespeichert. Das mit Anmerkungen versehene Bild wird in einem Ordner mit den Ergebnissen der Anmerkungen gespeichert. So kannst du dir ein Bild von den Erkennungsfähigkeiten des Modells machen.

Bildkommentar-Funktion

After running the eval command, you will receive detailed output metrics such as precision, recall, and mAP (mean Average Precision). This provides a comprehensive view of your model's performance on the dataset. This functionality is particularly useful for fine-tuning and optimizing your YOLO11 models for specific use cases, ensuring high accuracy and efficiency.

Zusammenfassung

This guide explored integrating Ultralytics' YOLO11 with Neural Magic's DeepSparse Engine. It highlighted how this integration enhances YOLO11's performance on CPU platforms, offering GPU-level efficiency and advanced neural network sparsity techniques.

For more detailed information and advanced usage, visit Neural Magic's DeepSparse documentation. Also, check out Neural Magic's documentation on the integration with YOLO11 here and watch a great session on it here.

Additionally, for a broader understanding of various YOLO11 integrations, visit the Ultralytics integration guide page, where you can discover a range of other exciting integration possibilities.

FAQ

What is Neural Magic's DeepSparse Engine and how does it optimize YOLO11 performance?

Neural Magic's DeepSparse Engine is an inference runtime designed to optimize the execution of neural networks on CPUs through advanced techniques such as sparsity, pruning, and quantization. By integrating DeepSparse with YOLO11, you can achieve GPU-like performance on standard CPUs, significantly enhancing inference speed, model efficiency, and overall performance while maintaining accuracy. For more details, check out the Neural Magic's DeepSparse section.

How can I install the needed packages to deploy YOLO11 using Neural Magic's DeepSparse?

Installing the required packages for deploying YOLO11 with Neural Magic's DeepSparse is straightforward. You can easily install them using the CLI. Here's the command you need to run:

pip install deepsparse[yolov8]

Once installed, follow the steps provided in the Installation section to set up your environment and start using DeepSparse with YOLO11.

How do I convert YOLO11 models to ONNX format for use with DeepSparse?

To convert YOLO11 models to the ONNX format, which is required for compatibility with DeepSparse, you can use the following CLI command:

yolo task=detect mode=export model=yolo11n.pt format=onnx opset=13

This command will export your YOLO11 model (yolo11n.pt) in ein Format (yolo11n.onnx), die von der DeepSparse Engine genutzt werden können. Weitere Informationen zum Modellexport findest du in der Abschnitt Modellexport.

How do I benchmark YOLO11 performance on the DeepSparse Engine?

Benchmarking YOLO11 performance on DeepSparse helps you analyze throughput and latency to ensure your model is optimized. You can use the following CLI command to run a benchmark:

deepsparse.benchmark model_path="path/to/yolo11n.onnx" --scenario=sync --input_shapes="[1,3,640,640]"

Dieser Befehl liefert dir wichtige Leistungskennzahlen. Weitere Informationen findest du im Abschnitt Benchmarking der Leistung.

Why should I use Neural Magic's DeepSparse with YOLO11 for object detection tasks?

Integrating Neural Magic's DeepSparse with YOLO11 offers several benefits:

  • Enhanced Inference Speed: Achieves up to 525 FPS, significantly speeding up YOLO11's capabilities.
  • Optimierte Modelleffizienz: Verwendet Sparsity-, Pruning- und Quantisierungstechniken, um die Modellgröße und den Rechenaufwand zu reduzieren und gleichzeitig die Genauigkeit zu erhalten.
  • Hohe Leistung auf Standard-CPUs: Bietet GPU-ähnliche Leistung auf kostengünstiger CPU Hardware.
  • Optimierte Integration: Benutzerfreundliche Tools für eine einfache Bereitstellung und Integration.
  • Flexibility: Supports both standard and sparsity-optimized YOLO11 models.
  • Kosteneffektiv: Reduziert die Betriebskosten durch effiziente Ressourcennutzung.

For a deeper dive into these advantages, visit the Benefits of Integrating Neural Magic's DeepSparse with YOLO11 section.

📅 Created 9 months ago ✏️ Updated 22 days ago

Kommentare