# 将 TensorFlow 或 Keras 模型转换为 TensorFlow Lite 格式

Source: [https://docs.qualcomm.com/doc/80-70014-54Y/topic/convert-a-tensorflow-or-keras-model-to-tensorflow-lite-format.html](https://docs.qualcomm.com/doc/80-70014-54Y/topic/convert-a-tensorflow-or-keras-model-to-tensorflow-lite-format.html)

TensorFlow 框架提供 Python API 和 CLI 工具，用于将 TensorFlow 或 Keras 模型转换为 TensorFlow Lite 格式。

- Python API：TensorFlow 提供 API 来将模型转换、优化和量化为 TensorFlow Lite 格式。
- CLI：可以使用 CLI 工具将模型转换为 TensorFlow Lite 格式，但它仅适用于基本模型转换。

Note: TensorFlow 到 TensorFlow Lite 的 Python API 提供了更多灵活性，可以根据您的需求转换、优化和量化模型。

- **[使用 Python API 进行转换和量化](https://docs.qualcomm.com/doc/80-70014-54Y/topic/convert-and-quantize-using-python-apis.html)**  

TensorFlow 提供 API 来将 TensorFlow Saved Model 或 Keras 模型转换为 TensorFlow Lite 模型。
- **[使用离线转换工具 (CLI) 进行转换](https://docs.qualcomm.com/doc/80-70014-54Y/topic/convert-using-offline-converter-tool-cli.html)**  

TensorFlow Lite 转换工具 tflite\_convert 可离线使用，包含在 TensorFlow pip 包中，适用于 TensorFlow 2.x 及以上版本。

**Parent Topic:** [转换 TensorFlow Lite 模型](https://docs.qualcomm.com/doc/80-70014-54Y/topic/convert-tensorflow-lite-models.html)

Last Published: Aug 06, 2024

[Previous Topic
使用现有的 TensorFlow Lite 模型](https://docs.qualcomm.com/bundle/publicresource/80-70014-54Y/topics/use-an-existing-tensorflow-lite-model.md) [Next Topic
使用 Python API 进行转换和量化](https://docs.qualcomm.com/bundle/publicresource/80-70014-54Y/topics/convert-and-quantize-using-python-apis.md)