Implementation:Roboflow Rf detr Onnx Simplify
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Deployment, Model_Optimization |
| Last Updated | 2026-02-08 15:00 GMT |
Overview
Concrete tool for simplifying exported ONNX models using graph optimization and the onnxsim library.
Description
onnx_simplify() applies a two-stage optimization: first using the custom OnnxOptimizer for RF-DETR-specific graph passes, then using onnxsim.simplify() for general ONNX simplification with numerical validation. The simplified model is saved with a .sim.onnx suffix.
Usage
Called automatically when model.export(simplify=True) is used, or can be called standalone on an existing ONNX file.
Code Reference
Source Location
- Repository: rf-detr
- File: rfdetr/deploy/export.py
- Lines: L89-114 (onnx_simplify)
- File: rfdetr/deploy/_onnx/optimizer.py
- Lines: L27-39 (OnnxOptimizer.__init__)
Signature
def onnx_simplify(
onnx_dir: str,
input_names: List[str],
input_tensors: List[torch.Tensor],
force: bool = False,
) -> str:
"""
Simplify an ONNX model file.
Args:
onnx_dir: Path to input ONNX file
input_names: Model input names
input_tensors: Sample input tensors for validation
force: Overwrite existing simplified file
Returns:
Path to simplified ONNX file (.sim.onnx)
"""
Import
from rfdetr.deploy.export import onnx_simplify
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| onnx_dir | str | Yes | Path to input ONNX file |
| input_names | List[str] | Yes | Model input names (e.g. ["input"]) |
| input_tensors | List[Tensor] | Yes | Sample inputs for numerical validation |
| force | bool | No | Overwrite existing simplified file (default: False) |
Outputs
| Name | Type | Description |
|---|---|---|
| simplified file | str | Path to simplified ONNX file ({name}.sim.onnx) |
Usage Examples
Via Export API
from rfdetr import RFDETRBase
model = RFDETRBase()
model.export(simplify=True)
# Produces both inference_model.onnx and inference_model.sim.onnx
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment