Vai al contenuto

How to Export to NCNN from YOLO11 for Smooth Deployment

Deploying computer vision models on devices with limited computational power, such as mobile or embedded systems, can be tricky. You need to make sure you use a format optimized for optimal performance. This makes sure that even devices with limited processing power can handle advanced computer vision tasks well.

The export to NCNN format feature allows you to optimize your Ultralytics YOLO11 models for lightweight device-based applications. In this guide, we'll walk you through how to convert your models to the NCNN format, making it easier for your models to perform well on various mobile and embedded devices.

Perché dovresti esportare su NCNN?

NCNN panoramica

The NCNN framework, developed by Tencent, is a high-performance neural network inference computing framework optimized specifically for mobile platforms, including mobile phones, embedded devices, and IoT devices. NCNN is compatible with a wide range of platforms, including Linux, Android, iOS, and macOS.

NCNN is known for its fast processing speed on mobile CPUs and enables rapid deployment of deep learning models to mobile platforms. This makes it easier to build smart apps, putting the power of AI right at your fingertips.

Caratteristiche principali dei modelli NCNN

NCNN models offer a wide range of key features that enable on-device machine learning by helping developers run their models on mobile, embedded, and edge devices:

  • Efficient and High-Performance: NCNN models are made to be efficient and lightweight, optimized for running on mobile and embedded devices like Raspberry Pi with limited resources. They can also achieve high performance with high accuracy on various computer vision-based tasks.

  • Quantization: NCNN models often support quantization which is a technique that reduces the precision of the model's weights and activations. This leads to further improvements in performance and reduces memory footprint.

  • Compatibilità: i modelli di NCNN sono compatibili con i più diffusi framework di deep learning come TensorFlow, Caffe e ONNX. Questa compatibilità consente agli sviluppatori di utilizzare facilmente i modelli e i flussi di lavoro esistenti.

  • Facile da usare: i modelli di NCNN sono progettati per essere facilmente integrati in varie applicazioni, grazie alla loro compatibilità con i più diffusi framework di deep learning. Inoltre, NCNN offre strumenti di facile utilizzo per convertire i modelli tra diversi formati, garantendo un'interoperabilità senza problemi in tutto il panorama dello sviluppo.

Opzioni di distribuzione con NCNN

Before we look at the code for exporting YOLO11 models to the NCNN format, let's understand how NCNN models are normally used.

NCNN I modelli, progettati per garantire efficienza e prestazioni, sono compatibili con un'ampia gamma di piattaforme di distribuzione:

  • Distribuzione mobile: Ottimizzato in modo specifico per Android e iOS, consente una perfetta integrazione nelle applicazioni mobili per un'inferenza efficiente sul dispositivo.

  • Sistemi embedded e dispositivi IoT: Se trovi che l'esecuzione dell'inferenza su un Raspberry Pi con la guidaUltralytics non sia abbastanza veloce, il passaggio a un modello esportato da NCNN può aiutarti a velocizzare le cose. NCNN è ottimo per dispositivi come Raspberry Pi e NVIDIA Jetson, soprattutto in situazioni in cui hai bisogno di un'elaborazione rapida direttamente sul dispositivo.

  • Distribuzione su desktop e server: È in grado di essere distribuito in ambienti desktop e server su Linux, Windows e macOS, supportando lo sviluppo, la formazione e la valutazione con capacità di calcolo superiori.

Export to NCNN: Converting Your YOLO11 Model

You can expand model compatibility and deployment flexibility by converting YOLO11 models to NCNN format.

Installazione

Per installare i pacchetti necessari, esegui:

Installazione

# Install the required package for YOLO11
pip install ultralytics

For detailed instructions and best practices related to the installation process, check our Ultralytics Installation guide. While installing the required packages for YOLO11, if you encounter any difficulties, consult our Common Issues guide for solutions and tips.

Utilizzo

Before diving into the usage instructions, it's important to note that while all Ultralytics YOLO11 models are available for exporting, you can ensure that the model you select supports export functionality here.

Utilizzo

from ultralytics import YOLO

# Load the YOLO11 model
model = YOLO("yolo11n.pt")

# Export the model to NCNN format
model.export(format="ncnn")  # creates '/yolo11n_ncnn_model'

# Load the exported NCNN model
ncnn_model = YOLO("./yolo11n_ncnn_model")

# Run inference
results = ncnn_model("https://ultralytics.com/images/bus.jpg")
# Export a YOLO11n PyTorch model to NCNN format
yolo export model=yolo11n.pt format=ncnn  # creates '/yolo11n_ncnn_model'

# Run inference with the exported model
yolo predict model='./yolo11n_ncnn_model' source='https://ultralytics.com/images/bus.jpg'

Per maggiori dettagli sulle opzioni di esportazione supportate, visita la pagina di documentazione diUltralytics sulle opzioni di distribuzione.

Deploying Exported YOLO11 NCNN Models

After successfully exporting your Ultralytics YOLO11 models to NCNN format, you can now deploy them. The primary and recommended first step for running a NCNN model is to utilize the YOLO("./model_ncnn_model") method, as outlined in the previous usage code snippet. However, for in-depth instructions on deploying your NCNN models in various other settings, take a look at the following resources:

  • Android: This blog explains how to use NCNN models for performing tasks like object detection through Android applications.

  • macOS: Capire come utilizzare i modelli di NCNN per eseguire attività con macOS.

  • Linux: Esplora questa pagina per scoprire come distribuire i modelli NCNN su dispositivi a risorse limitate come Raspberry Pi e altri dispositivi simili.

  • Windows x64 con VS2017: Esplora questo blog per scoprire come distribuire i modelli NCNN su Windows x64 utilizzando Visual Studio Community 2017.

Sommario

In this guide, we've gone over exporting Ultralytics YOLO11 models to the NCNN format. This conversion step is crucial for improving the efficiency and speed of YOLO11 models, making them more effective and suitable for limited-resource computing environments.

Per istruzioni dettagliate sull'uso, consulta la documentazione ufficiale di NCNN .

Also, if you're interested in exploring other integration options for Ultralytics YOLO11, be sure to visit our integration guide page for further insights and information.

DOMANDE FREQUENTI

How do I export Ultralytics YOLO11 models to NCNN format?

To export your Ultralytics YOLO11 model to NCNN format, follow these steps:

  • Python: Usa il tasto export della classe YOLO .

    from ultralytics import YOLO
    
    # Load the YOLO11 model
    model = YOLO("yolo11n.pt")
    
    # Export to NCNN format
    model.export(format="ncnn")  # creates '/yolo11n_ncnn_model'
    
  • CLI: Usa il tasto yolo con il comando export argomento.

    yolo export model=yolo11n.pt format=ncnn  # creates '/yolo11n_ncnn_model'
    

Per informazioni dettagliate sulle opzioni di esportazione, consulta la pagina Esportazione della documentazione.

What are the advantages of exporting YOLO11 models to NCNN?

Exporting your Ultralytics YOLO11 models to NCNN offers several benefits:

  • Efficienza: i modelli di NCNN sono ottimizzati per i dispositivi mobili ed embedded, garantendo prestazioni elevate anche con risorse di calcolo limitate.
  • Quantizzazione: NCNN supporta tecniche come la quantizzazione che migliorano la velocità del modello e riducono l'utilizzo della memoria.
  • Ampia compatibilità: Puoi distribuire i modelli NCNN su diverse piattaforme, tra cui Android, iOS, Linux e macOS.

Per maggiori dettagli, consulta la sezione Esportazione in NCNN nella documentazione.

Perché dovrei utilizzare NCNN per le mie applicazioni AI per dispositivi mobili?

NCNN, sviluppato da Tencent, è specificamente ottimizzato per le piattaforme mobili. I motivi principali per utilizzare NCNN sono:

  • Prestazioni elevate: Progettato per un'elaborazione efficiente e veloce sulle CPU mobili.
  • Cross-Platform: Compatible with popular frameworks such as TensorFlow and ONNX, making it easier to convert and deploy models across different platforms.
  • Supporto della comunità: Il supporto attivo della comunità garantisce miglioramenti e aggiornamenti continui.

Per saperne di più, visita la panoramica diNCNN nella documentazione.

What platforms are supported for NCNN model deployment?

NCNN è versatile e supporta diverse piattaforme:

  • Mobile: Android, iOS.
  • Sistemi embedded e dispositivi IoT: Dispositivi come Raspberry Pi e NVIDIA Jetson.
  • Desktop e server: Linux, Windows e macOS.

Se l'esecuzione dei modelli su un Raspberry Pi non è abbastanza veloce, la conversione nel formato NCNN potrebbe accelerare le cose, come spiegato nella nostra Guida per Raspberry Pi.

How can I deploy Ultralytics YOLO11 NCNN models on Android?

To deploy your YOLO11 models on Android:

  1. Costruire per Android: Segui la guida NCNN Build for Android.
  2. Integrazione con la tua applicazione: Usa l'SDK di NCNN Android per integrare il modello esportato nella tua applicazione per un'inferenza efficiente sul dispositivo.

For step-by-step instructions, refer to our guide on Deploying YOLO11 NCNN Models.

Per guide e casi d'uso più avanzati, visita la pagina di documentazione di Ultralytics .

📅 Created 7 months ago ✏️ Updated 22 days ago

Commenti