TensorFlow Serving 是一个开源的高性能 TensorFlow 模型部署解决方案。它使得部署 TensorFlow 模型变得更加简单,并且可以轻松地在生产环境中运行。
快速开始
安装 TensorFlow Serving
- 使用 pip 安装 TensorFlow Serving:
pip install tensorflow-serving-api
- 下载 TensorFlow Serving 的预构建版本。
- 使用 pip 安装 TensorFlow Serving:
准备模型
- 将你的 TensorFlow 模型转换为 SavedModel 格式。
启动 TensorFlow Serving
- 使用以下命令启动 TensorFlow Serving:
tensorflow_model_server --model_name=my_model --model_base_path=/path/to/my_model
- 使用以下命令启动 TensorFlow Serving:
使用客户端进行预测
- 使用
grpcurl
或其他客户端进行预测。
- 使用
示例
以下是一个简单的使用 grpcurl
进行预测的例子:
grpcurl -d '{"instances":[{"input": [1.0, 2.0, 3.0]}]}' localhost:8500/tensorflow/serving/api/v1/predict -H "Content-Type: application/json"
资源
TensorFlow Serving