amazon-sagemaker - 如何在 Mac 本地运行张量流模型
问题描述
我在 Sagemaker 中部署了 ML 模型。我将模型(tar.gz)复制到我的 Mac 并尝试在本地编写运行该 tar.gz 模型文件。我需要将输入作为图像传递,该图像将通过此模型并在本地为我提供输出。如何编写 python 代码以在本地运行此完整设置。
解决方案
一种解决方案是使用 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 文档。
推荐阅读
- ruby-on-rails - `redirect_to @article` 在 Blog::ArticlesController#create 中抛出 `NoMethodError` 错误
- node.js - 在现有 kubernetes pod 中按需创建容器
- office-js - 使用带有 VueJS 的 on-send 加载项 Office Outlook 2002 构建
- java - 为什么即使使用 CascadeType.ALL 也会出现 DataIntegrityViolationException?
- python - 使用 Python 为 Valve QC 文件生成代码
- elasticsearch - 如何在 Elasticsearch 中存储国家/州/城市信息
- ios - 通过 Xcode 在我自己的设备上安装应用程序
- r - 通过 ODBC 连接到 Firebird DB
- active-directory - 以编程方式将 RoleAssignment 添加到资源组
- python - 如何创建一个可以从终端访问的模块?