Salta para o conteúdo

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 MagicVisão geral do DeepSparse da 's

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

Antes de mergulhar em como implantar YOLOV8 usando DeepSparse, vamos entender os benefícios de usar DeepSparse. Algumas vantagens principais incluem:

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

Velocidade de inferência melhorada

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

Eficiência do modelo optimizado

  • Alto desempenho em CPUs padrão: Oferece um desempenho semelhante ao do GPU em CPUs, proporcionando uma opção mais acessível e económica para várias aplicações.

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

  • Solução económica e escalável: Reduz as despesas operacionais e oferece uma implementação escalável de modelos avançados de deteção de objectos.

Como funciona a tecnologia DeepSparse da Neural Magic?

Neural Magic A tecnologia Deep Sparse da é inspirada na eficiência do cérebro humano na computação de redes neurais. Ele adota dois princípios-chave do cérebro, como segue:

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

  • Localidade de referência: O DeepSparse usa um método de execução exclusivo, dividindo a rede em Tensor Colunas. Essas colunas são executadas em profundidade, cabendo inteiramente no cache do CPU. Essa abordagem imita a eficiência do cérebro, minimizando a movimentação de dados e maximizando o uso do cache do CPU.

Como funciona a tecnologia DeepSparse da Neural Magic

Para mais informações sobre o funcionamento da tecnologia DeepSparse da Neural Magic, consulta a publicação no blogue.

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.

Usa: Implementando YOLOV8 usando 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.

Passo 1: Instalação

Para instalar os pacotes necessários, executa:

Instalação

# 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:

Modelo de exportação

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

Este comando guarda o yolo11n.onnx para o teu disco.

Etapa 3: Implantação e execução de inferências

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:

Implantação e execução de inferências

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)

Passo 4: Aferição do desempenho

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:

Avaliação comparativa

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

Passo 5: Características adicionais

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

Características adicionais

# 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"

A execução do comando de anotação processa a imagem especificada, detectando objectos e guardando a imagem anotada com caixas delimitadoras e classificações. A imagem anotada será armazenada em uma pasta de resultados de anotação. Isto ajuda a fornecer uma representação visual das capacidades de deteção do modelo.

Recurso de anotação de imagens

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.

Resumo

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) para um formato (yolo11n.onnx) que pode ser utilizado pelo DeepSparse Engine. Mais informações sobre a exportação de modelos podem ser encontradas no Secção Exportação de modelos.

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]"

Este comando fornece-te métricas de desempenho vitais. Para obter mais detalhes, consulte a secção Desempenho de avaliação comparativa.

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.
  • Eficiência optimizada do modelo: Usa técnicas de esparsidade, poda e quantização para reduzir o tamanho do modelo e as necessidades computacionais, mantendo a precisão.
  • Alto desempenho em CPUs padrão: Oferece um desempenho semelhante ao de GPU em hardware CPU económico.
  • Integração simplificada: Ferramentas fáceis de utilizar para uma fácil implementação e integração.
  • Flexibility: Supports both standard and sparsity-optimized YOLO11 models.
  • Rentável: Reduz as despesas operacionais através da utilização eficiente dos recursos.

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

Comentários