CLI tool to convert TensorFlow models to ONNX
Top 19.3% on sourcepulse
This repository provides tf2onnx
, a tool for converting TensorFlow, Keras, TensorFlow.js, and TFLite models to the ONNX format. It's designed for developers and researchers who need to deploy TensorFlow-based models on platforms supporting ONNX, enabling cross-compatibility and hardware acceleration.
How It Works
The converter processes TensorFlow models by first performing a 1:1 conversion of the protobuf format to ONNX. It then rewrites subgraphs for complex operations like transpose and LSTM, and processes individual ops by mapping TensorFlow types to ONNX equivalents. TensorFlow ops that are composed of multiple simpler ONNX ops (e.g., ReLU6) are handled by composing the ONNX equivalent. Finally, it optimizes the ONNX graph by removing redundant operations, fusing ops, and ensuring topological sorting.
Quick Start & Requirements
pip install -U tf2onnx
python -m tf2onnx.convert --saved-model <path> --output model.onnx
Highlighted Details
Maintenance & Community
The project is actively maintained by the ONNX community. Further details on community engagement and roadmaps are available on the project's GitHub repository.
Licensing & Compatibility
Limitations & Caveats
TensorFlow.js support is experimental. Some TensorFlow ops may not have direct ONNX equivalents and might require custom handling or may not convert successfully. The converter relies on specific TensorFlow versions for testing.
2 weeks ago
1 day