# Supported Export Formats for YOLOv5 Models: CoreML, TFLite, ONNX and More

> Export YOLOv5 models to 12 formats like CoreML TFLite ONNX TensorRT TFJS and more. Easily deploy your models everywhere with ultralytics YOLOv5.

- Repository: [Ultralytics/yolov5](https://github.com/ultralytics/yolov5)
- Tags: supported-formats
- Published: 2026-03-06

---

**YOLOv5 supports 12 deployment formats including PyTorch, TorchScript, ONNX, OpenVINO, TensorRT, CoreML, TensorFlow SavedModel, GraphDef, TFLite, Edge TPU, TF.js, and PaddlePaddle, configurable via the `--include` argument in [`export.py`](https://github.com/ultralytics/yolov5/blob/main/export.py).**

The ultralytics/yolov5 repository provides a unified export pipeline that converts trained PyTorch checkpoints into deployment-ready formats for mobile, edge, and cloud inference. Understanding the supported export formats for YOLOv5 models enables developers to optimize latency and compatibility across iOS, Android, and embedded hardware.

## Complete List of YOLOv5 Export Formats

The canonical enumeration of supported formats is defined in the `export_formats()` function located at lines 165–178 of [`export.py`](https://github.com/ultralytics/yolov5/blob/main/export.py). This function returns a structured table mapping each format to its CLI argument, file suffix, and hardware compatibility.

| Format | CLI Argument (`--include`) | File Suffix | Training Support | Inference Support |
|--------|----------------------------|-------------|------------------|-------------------|
| **PyTorch** | `-` | `.pt` | ✅ | ✅ |
| **TorchScript** | `torchscript` | `.torchscript` | ✅ | ✅ |
| **ONNX** | `onnx` | `.onnx` | ✅ | ✅ |
| **OpenVINO** | `openvino` | `_openvino_model` | ✅ | ❌ |
| **TensorRT** | `engine` | `.engine` | ❌ | ✅ |
| **CoreML** | `coreml` | `.mlpackage` | ✅ | ❌ |
| **TensorFlow SavedModel** | `saved_model` | `_saved_model` | ✅ | ✅ |
| **TensorFlow GraphDef** | `pb` | `.pb` | ✅ | ✅ |
| **TensorFlow Lite** | `tflite` | `.tflite` | ✅ | ❌ |
| **TensorFlow Edge TPU** | `edgetpu` | `_edgetpu.tflite` | ❌ | ❌ |
| **TensorFlow.js** | `tfjs` | `_web_model` | ❌ | ❌ |
| **PaddlePaddle** | `paddle` | `_paddle_model` | ✅ | ✅ |

TensorRT, Edge TPU, and TF.js are inference-only formats, while CoreML and TFLite support training but not GPU inference according to the source configuration.

## How the Export Pipeline Works

### Model Preparation and Loading

The export process begins with a trained PyTorch checkpoint produced by [`train.py`](https://github.com/ultralytics/yolov5/blob/main/train.py) or [`detect.py`](https://github.com/ultralytics/yolov5/blob/main/detect.py). In [`export.py`](https://github.com/ultralytics/yolov5/blob/main/export.py), the script loads the model and creates a dummy input tensor with shape `(1, 3, 640, 640)`. It then sets `model.export = True`, a flag defined in [`models/yolo.py`](https://github.com/ultralytics/yolov5/blob/main/models/yolo.py) that modifies the forward pass to return raw predictions only, excluding loss calculations and training-specific outputs.

### Format-Specific Export Functions

Each supported format implements a dedicated export function (e.g., `export_coreml()`, `export_tflite()`, `export_onnx()`) within [`export.py`](https://github.com/ultralytics/yolov5/blob/main/export.py). These functions are decorated with `@try_export`, which wraps the conversion logic in error handling that logs success status, runtime duration, and output file size. The decorator ensures that a failure in one format does not abort the entire export job.

### CLI Invocation and Batch Export

Users trigger exports via the command line using the `--include` flag followed by one or more format arguments from the table above. The parser validates inputs against the `export_formats()` DataFrame and executes the corresponding function for each requested target.

```bash
python export.py --weights yolov5s.pt --include coreml tflite onnx

```

This command generates `yolov5s.mlmodel`, `yolov5s.tflite`, and `yolov5s.onnx` in a single execution.

### Post-Export Validation

After file generation, the pipeline optionally loads the exported model using the appropriate runtime (e.g., `coremltools`, `onnxruntime`, or TensorFlow) and compares inference results against the original PyTorch baseline to verify numerical equivalence.

## Exporting to CoreML and TensorFlow Lite

### Command-Line Export

To convert a YOLOv5-S model to CoreML for iOS deployment and TensorFlow Lite for Android edge devices simultaneously:

```bash
python export.py \
  --weights yolov5s.pt \
  --include coreml tflite \
  --device 0

```

The `--device 0` flag specifies GPU acceleration for formats that require CUDA during the conversion process.

### Programmatic Export

For integration into custom training workflows, invoke the export functions directly from Python:

```python
from pathlib import Path
import torch
from export import export_coreml, export_tflite

# Load checkpoint

ckpt = torch.load('yolov5s.pt', map_location='cpu')
model = ckpt['model'].float().eval()

# Create dummy input (batch 1, 3 channels, 640x640)

img = torch.zeros(1, 3, 640, 640)

# Export to CoreML

export_coreml(model, img, Path('yolov5s.mlmodel'), 
              int8=False, half=False, nms=True)

# Export to TFLite via intermediate SavedModel

export_tflite(model, img, Path('yolov5s.tflite'),
              int8=False, half=False)

```

### Listing Available Formats Programmatically

Access the format registry directly to inspect supported targets:

```python
import pandas as pd
from export import export_formats

df = export_formats()
print(df[['Format', 'Argument', 'Suffix']])

```

## Key Source Files and Functions

- **[`export.py`](https://github.com/ultralytics/yolov5/blob/main/export.py)**: Central export script containing `export_formats()` (lines 165–178) and all format-specific exporters such as `export_coreml()` and `export_tflite()`.
- **[`models/yolo.py`](https://github.com/ultralytics/yolov5/blob/main/models/yolo.py)**: Defines the `self.export` boolean flag that alters the model's forward pass behavior for export compatibility.
- **`@try_export`**: Decorator applied to export functions within [`export.py`](https://github.com/ultralytics/yolov5/blob/main/export.py) for standardized logging and exception handling.

## Summary

- **12 formats supported**: The `export_formats()` function in [`export.py`](https://github.com/ultralytics/yolov5/blob/main/export.py) enumerates PyTorch, TorchScript, ONNX, OpenVINO, TensorRT, CoreML, TensorFlow variants (SavedModel, GraphDef, Lite, Edge TPU, JS), and PaddlePaddle.
- **CLI-driven workflow**: Use `--include` with space-separated arguments to batch export multiple formats in one command.
- **Hardware-specific limitations**: TensorRT, Edge TPU, and TF.js are inference-only; CoreML and TFLite do not support GPU inference but allow CPU training.
- **Validation included**: The pipeline verifies exported model accuracy against the PyTorch baseline before completion.

## Frequently Asked Questions

### What export formats support training versus inference only?

According to the `export_formats()` DataFrame in [`export.py`](https://github.com/ultralytics/yolov5/blob/main/export.py), most formats support training on CPU. However, **TensorRT** (`engine`), **TensorFlow Edge TPU** (`edgetpu`), and **TensorFlow.js** (`tfjs`) are strictly inference-only. CoreML and TFLite support training but restrict inference to CPU only.

### How do I export a YOLOv5 model to CoreML for iOS deployment?

Run `python export.py --weights yolov5s.pt --include coreml`. The `export_coreml()` function in [`export.py`](https://github.com/ultralytics/yolov5/blob/main/export.py) utilizes `coremltools` to generate a `.mlpackage` file optimized for the Apple Neural Engine. You can enable NMS (Non-Maximum Suppression) integration by passing `nms=True` to the export function.

### Can I export to multiple formats simultaneously?

Yes. The `--include` argument accepts multiple space-separated values. For example, `python export.py --weights model.pt --include onnx tflite coreml` generates ONNX, TensorFlow Lite, and CoreML models in a single execution. Each export runs independently thanks to the `@try_export` decorator error isolation.

### Where is the export format configuration defined in the codebase?

The canonical list is defined in the `export_formats()` function at lines 165–178 of [`export.py`](https://github.com/ultralytics/yolov5/blob/main/export.py). This function returns a pandas DataFrame mapping human-readable format names to CLI arguments, file suffixes, and boolean flags indicating training and inference compatibility.