Meet YOLO26: next-gen vision AI.
Ultralytics
Back to Ultralytics Glossary

ONNX (Open Neural Network Exchange)

Explore the Open Neural Network Exchange (ONNX) format. Learn how to export Ultralytics YOLO26 to ONNX for fast, cross-platform deployment and hardware optimization.

ONNX (Open Neural Network Exchange) is an open-source format designed to represent machine learning models, allowing interoperability between various AI frameworks and tools. It serves as a universal translator for deep learning, enabling developers to build models in one framework—such as PyTorch, TensorFlow, or Scikit-learn—and seamlessly deploy them in another environment optimized for inference. By defining a common set of operators and a standard file format, ONNX eliminates the need for complex, custom conversion scripts that were historically required to move models from research to production. This flexibility is crucial for modern AI workflows, where training might occur on powerful cloud GPUs while deployment targets diverse hardware like edge devices, mobile phones, or web browsers.

Link to this sectionThe Role of ONNX in Modern AI#

In the rapidly evolving landscape of artificial intelligence, researchers and engineers often use different tools for different stages of the development lifecycle. A data scientist might prefer the flexibility of PyTorch for experimentation and training, while a production engineer needs the optimized performance of TensorRT or OpenVINO for deployment. Without a standard exchange format, moving a model between these ecosystems is difficult and error-prone.

ONNX bridges this gap by providing a shared definition of the computation graph. When a model is exported to ONNX, it is serialized into a format that captures the network structure (layers, connections) and parameters (weights, biases) in a framework-agnostic way. This allows inference engines specifically tuned for hardware acceleration—such as the ONNX Runtime—to execute the model efficiently across multiple platforms, including Linux, Windows, macOS, Android, and iOS.

Link to this sectionKey Benefits of Using ONNX#

Adopting the Open Neural Network Exchange format offers several strategic advantages for AI projects:

  • Framework Interoperability: Developers can switch between frameworks without getting locked into a single ecosystem. You can train a model using the user-friendly Ultralytics Python API and export it for use in a C++ application or a web-based JavaScript environment.
  • Hardware Optimization: Many hardware manufacturers provide specialized execution providers that interface with ONNX. This means a single .onnx file can be accelerated on NVIDIA GPUs, Intel CPUs, or mobile NPUs (Neural Processing Units) using tools like OpenVINO or CoreML.
  • Faster Inference: The ONNX Runtime applies graph optimizations—such as node fusion and constant folding—that can significantly reduce inference latency. This is essential for real-time applications like autonomous vehicles or high-speed manufacturing lines.
  • Simplified Deployment: Instead of maintaining separate deployment pipelines for every training framework, engineering teams can standardize on ONNX as the delivery format, streamlining ModelOps processes.

Link to this sectionReal-World Applications#

The versatility of ONNX makes it a staple in diverse industries. Here are two concrete examples of its application:

Link to this section1. Edge AI on Mobile Devices#

Consider a mobile application designed for real-time crop health monitoring. The model might be trained on a powerful cloud server using a large dataset of plant images. However, the app needs to run offline on a farmer's smartphone. By exporting the trained model to ONNX, developers can integrate it into the mobile app using ONNX Runtime Mobile. This allows the phone's processor to run object detection locally, identifying pests or diseases instantly without needing an internet connection.

Link to this section2. Cross-Platform Web Inference#

In e-commerce, a "virtual try-on" feature might use pose estimation to overlay clothing on a user's webcam feed. Training this model might happen in Python, but the deployment target is a web browser. Using ONNX, the model can be converted and run directly in the user's browser via ONNX Runtime Web. This utilizes the client's device capabilities (WebGL or WebAssembly) to perform computer vision tasks, ensuring a smooth, privacy-preserving experience since video data never leaves the user's computer.

It is helpful to distinguish ONNX from other model formats and tools:

  • vs. TensorRT: While ONNX is an exchange format, TensorRT is an inference engine and optimizer specifically for NVIDIA GPUs. A common workflow involves exporting a model to ONNX first, and then parsing that ONNX file into TensorRT to achieve maximum throughput on NVIDIA hardware.
  • vs. TensorFlow SavedModel: SavedModel is the native serialization format for TensorFlow. While robust within the Google ecosystem, it is less universally compatible than ONNX. Tools often exist to convert SavedModels into ONNX to gain broader platform support.
  • vs. CoreML: CoreML is Apple's framework for on-device machine learning. While distinct, models are frequently converted from PyTorch to ONNX, and then from ONNX to CoreML (or directly) to run efficiently on iPhones and iPads.

Link to this sectionExporting to ONNX with Ultralytics#

The Ultralytics ecosystem simplifies the process of converting state-of-the-art models like YOLO26 into the ONNX format. The export functionality is built directly into the library, handling the complex graph traversal and operator mapping automatically.

The following example demonstrates how to export a pre-trained YOLO26 model to ONNX format for deployment:

from ultralytics import YOLO

# Load the YOLO26n model (Nano version recommended for edge deployment)
model = YOLO("yolo26n.pt")

# Export the model to ONNX format
# The 'dynamic' argument enables variable input sizes
path = model.export(format="onnx", dynamic=True)

print(f"Model exported successfully to: {path}")

Once exported, this .onnx file can be utilized in the Ultralytics Platform for management or deployed directly to edge devices using the ONNX Runtime, making high-performance computer vision accessible in virtually any environment.

Explore solutions

Real-time AI that works with your team

AI 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
Real-time AI that works with your team

AI in Logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Real-time AI that works with your team

AI in Retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Real-time AI that works with your team

AI in Healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Real-time AI that works with your team

AI in Manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Real-time AI that works with your operation

AI 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
Real-time AI tailored to your operation

AI 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
Real-time AI that works with your team

AI 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
Real-time AI that works with your team

AI in Logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Real-time AI that works with your team

AI in Retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Real-time AI that works with your team

AI in Healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Real-time AI that works with your team

AI in Manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Real-time AI that works with your operation

AI 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
Real-time AI tailored to your operation

AI 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
Real-time AI that works with your team

AI 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
Real-time AI that works with your team

AI in Logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Real-time AI that works with your team

AI in Retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Real-time AI that works with your team

AI in Healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Real-time AI that works with your team

AI in Manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Real-time AI that works with your operation

AI 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
Real-time AI tailored to your operation

AI 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