🔧 系统要求
- Android:需安装 Android Studio
- Linux/macOS:Python 3.7+ 环境
- Windows:Visual Studio 2019 或更高版本
📥 安装方式
通过 pip 安装
pip install tflite-runtime
✅ 适用于快速开发,支持 Python 3.7-3.10
下载预编译库
- TensorFlow Lite 官方下载页面
- 选择对应平台的
.aarchive
文件(如 Android)
从源码编译
🧱 执行以下命令:git clone https://github.com/tensorflow/tensorflow.git cd tensorflow ./configure bazel build //tensorflow/lite:libtensorflowlite.so
🧪 验证安装
运行示例代码:
import tensorflow as tf
interpreter = tf.lite.Interpreter(model_path="model.tflite")
interpreter.allocate_tensors()
📌 注意:确保已安装 TensorFlow 基础库
🔗 扩展阅读:TensorFlow Lite 入门教程