onnx/tensorflow-onnx

Convert TensorFlow, Keras, Tensorflow.js and Tflite models to ONNX

What it solves

tf2onnx converts machine learning models trained in TensorFlow, Keras, TensorFlow.js, and TFLite into the standard ONNX format. This allows models built in the TensorFlow ecosystem to run on platforms and runtimes that support ONNX.

How it works

The project provides a command-line interface and a Python API to parse source models and translate their underlying operations into equivalent ONNX graph nodes. Users can specify custom target ONNX opsets, transpose inputs and outputs between NHWC and NCHW formats, handle large models exceeding 2 GB with external tensor storage, and map custom operations.

Who it’s for

This tool is for machine learning engineers and developers who want to take models built with TensorFlow frameworks and deploy them on ONNX-compatible runtimes.

Highlights

  • Supports multiple input formats including TensorFlow SavedModel, checkpoints, GraphDef, TFLite, and experimental TensorFlow.js support.
  • Provides both a command-line tool and Python functions like from_keras, from_function, from_graph_def, and from_tflite.
  • Allows control over the target ONNX opset version (e.g., opset 15 through 21).
  • Includes options for handling large models larger than 2 GB using external tensor storage.

Related

  • Project
  • Project
  • Project
  • Project
  • Project