首页 > 解决方案 > 如何在 Mac 本地运行张量流模型

问题描述

我在 Sagemaker 中部署了 ML 模型。我将模型(tar.gz)复制到我的 Mac 并尝试在本地编写运行该 tar.gz 模型文件。我需要将输入作为图像传递,该图像将通过此模型并在本地为我提供输出。如何编写 python 代码以在本地运行此完整设置。

标签: amazon-sagemaker

解决方案


一种解决方案是使用 SageMaker Python SDK 的本地模式功能:

from sagemaker.tensorflow.serving import Model

model = Model(
    model_data='s3://bucket/path/to/your/model',
    ...  # fill in your other params
)

predictor = model.deploy(1, 'local')
predictor.predict(your_data)

更多信息:https ://sagemaker.readthedocs.io/en/stable/overview.html#local-mode

如果您不想使用 SageMaker 的本地模式,可以在https://www.tensorflow.org/tfx/guide/serving找到通用的 TF Serving 文档。


推荐阅读