Ultralytics YOLO27: Join the waitlist.
License YOLO
Integrations

Using the ONNX integration to export Ultralytics YOLO models

Learn how to export Ultralytics YOLO11 models to ONNX, run inference with the exported model, and deploy it across CPUs, GPUs, mobile and edge devices.

Abirami VinaAbirami Vina10 min read

Listen to this article

Learn how to export Ultralytics YOLO11 models to ONNX, run inference with the exported model, and deploy it across CPUs, GPUs, mobile and edge devices.

When AI solutions first started gaining attention, most models were deployed on powerful servers in controlled environments. However, as technology has advanced, deployment has expanded far beyond the data center.

Today, AI models run on everything from cloud servers and desktops to smartphones and edge devices. This shift supports faster processing, offline functionality, and smarter systems that operate closer to where the data is generated.

One area where this is especially clear is computer vision - a branch of AI that enables machines to interpret visual data. It is being used to drive applications like facial recognition, autonomous driving, and real-time video analysis. As these use cases grow, so does the need for models that can run smoothly across diverse hardware and platforms.

But deploying computer vision models across a range of deployment targets isn’t always simple. Devices differ in terms of hardware, operating systems, and supported frameworks, making flexibility and compatibility essential.

That’s why having the option to export computer vision models like Ultralytics YOLO11 to different formats is key. For instance, the ONNX (Open Neural Network Exchange) integration supported by Ultralytics provides a practical way to bridge the gap between training and deployment. ONNX is an open format that makes models framework-agnostic and deployment-ready across platforms.

ONNX enabling a model trained in one framework to run in another

Fig 1. ONNX helps you take a model trained in one framework and run it in another easily.

In this article, we’ll take a closer look at the ONNX integration supported by Ultralytics and explore how you can export your YOLO11 model for flexible, cross-platform deployment.

What is ONNX and ONNX Runtime?#

The Open Neural Network Exchange is an open-source project that defines a standard format for machine learning models. Originally developed by Microsoft and Facebook, it allows developers to train a model in one framework, like PyTorch, and run it in another, such as TensorFlow. This makes AI development more flexible, collaborative, and accessible, especially in fields like computer vision.

ONNX provides a common set of operators and a unified file format, making it easier to move models between different tools, frameworks, runtimes, and compilers. Normally, a model trained in one framework isn’t easily compatible with another - but with ONNX, you can export your model once and deploy it almost anywhere: on CPUs (Central Processing Units), GPUs (Graphics Processing Units), mobile devices, or edge hardware.

Also, ONNX Runtime is a high-performance inference engine developed specifically to run models in the ONNX format. It’s designed to make ONNX models run faster and more efficiently across a wide range of platforms - including servers, mobile devices, and edge hardware. ONNX Runtime is compatible with popular frameworks like PyTorch, TensorFlow, TensorFlow Lite, and scikit-learn, making it easy to integrate into different workflows and deploy models wherever they’re needed.

ONNX and ONNX Runtime enabling cross-platform model deployment

Fig 2. ONNX and ONNX Runtime enable flexible cross-platform model deployment.

Key features of ONNX#

Before we discuss how to export Ultralytics YOLO11 to ONNX format, let’s check out some key features of the ONNX model format.

Whether you're switching between tools, deploying to different devices, or upgrading systems, ONNX helps keep everything running smoothly. Here’s what makes the ONNX model format unique:

  • One standard format: ONNX uses a common way to describe how models are built, like layers and operations (think of them as building blocks). When a model is converted to ONNX, it follows this standard so that any system that supports ONNX can understand and run it.
  • Backward compatibility: Even as ONNX continues to improve, it ensures that older models still work with newer versions. This means you don’t have to retrain or rebuild your models every time ONNX gets an update.
  • Graph-based model design: ONNX models are structured as computation graphs, where each node represents an operation (such as a layer or mathematical function), and edges indicate the flow of data. This graph-based design facilitates integration with various systems that utilize similar computational graph structures.
  • Developer-friendly tools: It comes with a wide range of tools that help you convert, validate, and optimize your models. These tools simplify the process of moving models between different frameworks and can speed up deployment - especially for computer vision applications.

An overview of the ONNX integration#

Exporting Ultralytics YOLO models like Ultralytics YOLO11 in ONNX format is straightforward and it can be done in a few steps.

To get started, install the Ultralytics Python package using a package manager like pip. This can be done by running pip install ultralytics in your command prompt or terminal.

With the Ultralytics package, you can easily train, test, fine-tune, export, and deploy models for various computer vision tasks - making the whole process faster and more efficient. While installing it, if you encounter any difficulties, you can refer to the Common Issues guide for solutions and tips.

Once the Ultralytics package is installed, you can load and export the YOLO11 model to ONNX format using the code below. This example loads a pre-trained YOLO11 model (yolo11n.pt) and exports it as an ONNX file (yolo11n.onnx), making it ready for deployment across different platforms and devices.

from ultralytics import YOLO

model = YOLO("yolo11n.pt")
model.export(format="onnx")

The same steps work for newer models such as Ultralytics YOLO26. After converting your model to ONNX format and confirming that it gives the same results as the original, you can deploy it on a variety of platforms.

The example below shows how to load the exported YOLO11 model (yolo11n.onnx) and run inference with it. Inference simply means using the trained model to make predictions on new data. In this case, we’ll use the URL of an image of a bus to test the model.

onnx_model = YOLO("yolo11n.onnx")
results = onnx_model("https://ultralytics.com/images/bus.jpg", save=True)

When you run this code, the following output image will be saved in the runs/detect/predict folder.

Running an inference using the exported Ultralytics YOLO11 model on an image

Fig 3. Running an inference using the exported Ultralytics YOLO11 model on an image.

When should you choose the ONNX integration?#

The Ultralytics Python package supports exporting models to several formats, including TorchScript, CoreML, TensorRT, and ONNX. So, why choose ONNX?

What makes ONNX stand out is that it’s a framework-agnostic format. While many other export formats are tied to specific tools or environments, ONNX uses a standardized format and a shared set of operators. This makes it highly portable, hardware-friendly, and ideal for cross-platform deployment - whether you're working with cloud servers, mobile apps, or edge devices.

Here are some reasons why the ONNX integration could be the ideal choice for your Ultralytics YOLO11 projects:

  • Portable deployment: Once exported to ONNX, your Ultralytics YOLO11 model can be deployed on various platforms without code changes or retraining.
  • Industry-wide support: ONNX is supported by major AI companies and frameworks, making it a reliable, widely accepted format. It ensures long-term compatibility, much like how PDFs work across devices.
  • Future-proof development: Using ONNX helps protect your model investments. As tools evolve, ONNX keeps your models relevant and usable, even in new or different environments.
  • No vendor lock-in: Some tools tie you to using only their system, which can limit what your model can do. ONNX avoids that by letting you choose the platform that works best for your needs, without being stuck with a single setup.

Applications of Ultralytics YOLO11 and the ONNX model format#

Next, let’s explore some real-world applications where Ultralytics YOLO11 can be deployed with the help of the ONNX integration.

Tracking inventory at warehouses using Ultralytics YOLO11#

In busy warehouses, it’s difficult to keep an eye on every product and package at all times. Computer vision systems can help workers find products on shelves and get insights such as the number of products, type, etc. Such systems can help businesses automatically manage their vast inventory and save warehouse workers a lot of time.

Specifically, in smart warehouses, Ultralytics YOLO11 models exported to ONNX can be used to identify and count items in real time using cameras and edge devices. The exported model can help scan shelves or pallets to detect stock levels, missing items, or empty spots. Since ONNX models run efficiently on a wide range of hardware, the model can run directly on small edge devices, such as smart cameras, removing the need for expensive servers or constant cloud access.

An example of using Ultralytics YOLO11 to detect and count packages

Fig 4. An example of using YOLO11 to detect and count packages.

Hospital waste management with Ultralytics YOLO11#

Hospitals all around the world create large amounts of waste every day, from used gloves and syringes to equipment used during surgery (such as single-use or contaminated scissors and scalpels). In fact, research shows that hospitals produce more than 5 million tons of waste every year, which is 29 pounds of waste per bed per day.

Sorting such waste properly is essential for hygiene, safety, and following regulations. With Ultralytics YOLO11 models exported in ONNX format, hospitals can use computer vision in healthcare to automate and monitor waste disposal in real time.

For instance, cameras placed near waste bins in areas like operating rooms or hallways can monitor items as they are discarded. A custom Ultralytics YOLO11 model, trained to recognize different types of medical waste, can analyze the footage and identify what’s being thrown away. If an item ends up in the wrong bin, like a used syringe in regular trash, the system can be set up to immediately alert staff with a light or sound, helping to prevent contamination and ensure compliance.

Using Ultralytics YOLO11 to detect medical instruments

Fig 5. Using Ultralytics YOLO11 to detect medical instruments.

Ultralytics YOLO11-enabled crop monitoring#

Knowing the right time to harvest crops can have a big impact on both the quality of the produce and the overall productivity of a farm. Traditionally, farmers rely on experience and manual inspections - but with recent advances in technology, that’s starting to change.

Now, with computer vision innovations like YOLO11, exported in ONNX format, farmers can bring automation and precision into the field. By using drones or cameras mounted on tractors or poles, farmers can capture images of their crops (such as tomatoes, apples, or wheat). YOLO11 can then be used to detect key indicators like color, size, and the distribution of crops. Based on this information, farmers can determine whether the crops are ready to harvest, still maturing, or already past their peak.

Ultralytics YOLO11 detecting crops in aerial drone footage

Fig 6. YOLO11 can be used to detect crops in aerial drone footage.

ONNX limitations to consider#

While ONNX offers numerous benefits, such as portability, cross-platform compatibility, and framework interoperability, there are some limitations to keep in mind:

  • Model size: Converting models to ONNX format can sometimes result in larger file sizes compared to their original formats. Techniques like quantization and pruning can help mitigate this issue by reducing model size without significantly impacting performance.
  • Runtime compatibility: Although ONNX Runtime is designed for cross-platform compatibility, performance and support can vary across different hardware and operating systems.
  • Debugging challenges: Debugging ONNX models can be more complex than in native frameworks like PyTorch or TensorFlow. Error messages may be less descriptive, making it harder to pinpoint issues. However, tools like Netron for model visualization and ONNX Runtime's logging capabilities can assist in troubleshooting.

Key takeaways#

Exporting Ultralytics YOLO11 to ONNX makes it easy to take a trained computer vision model and deploy it almost anywhere - whether that’s on a laptop, mobile device, or even a compact smart camera. With the ONNX integration, you’re not tied to a single framework or platform, giving you the flexibility to run your model in the environment that suits your application best.

This makes the transition from training to real-world deployment faster and more efficient. Whether you're tracking inventory in a warehouse or ensuring hospital waste is disposed of correctly, this setup helps systems run more smoothly, reduces errors, and saves valuable time.

Want to learn more about computer vision and AI? Explore our GitHub repository, connect with our community, and check out our licensing options to jumpstart your computer vision project. If you're exploring innovations like AI in manufacturing and computer vision in the automotive industry, visit our solutions pages to discover more.

Written by

Abirami Vina
Abirami Vina

Content Creator · Ultralytics

Starting her career as a computer vision engineer, Abirami Vina built a strong foundation in vision AI and machine learning. She is a Content Creator for Ultralytics and the Founder and Chief Writer at Scribe of AI, where she crafts high-quality technical content for AI-focused companies. Driven by a passion for making AI both understandable and engaging, her work bridges the gap between cutting-edge technology and real-world impact.

Comments

Ask a question, share your results, or help someone else.

Explore solutions

Computer vision in sports

Computer vision in sports

Discover how Ultralytics YOLO powers sports vision with player and ball tracking, performance analytics, coaching insights, and athlete rehabilitation.
Learn more
Computer vision for aerial imagery

Computer vision for aerial imagery

Turn drone and aerial imagery into real-time insights for agriculture, aquaculture, conservation, and geospatial analysis with Ultralytics YOLO.
Learn more
Computer vision in aerospace

Computer vision in aerospace

Apply computer vision in aerospace with Ultralytics YOLO for aircraft inspection, runway FOD detection, airport ground operations, and composite defect detection.
Learn more
Computer vision in security

Computer vision in security

Protect every site with Ultralytics YOLO models. Vision AI powers perimeter monitoring, threat detection, license-plate recognition, and workplace safety.
Learn more
Computer vision in robotics

Computer vision in robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Computer vision in logistics

Computer vision in logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Computer vision in retail

Computer vision in retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Computer vision in healthcare

Computer vision in healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Computer vision in manufacturing

Computer vision in manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Computer vision in automotive

Computer vision in automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Computer vision in agriculture

Computer vision in agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more

Let's build the future of AI together!

Begin your journey with the future of machine learning