【发布时间】:2019-10-08 20:14:53
【问题描述】:
我已经使用 sagemaker 训练了一个语义分割模型,并且输出已保存到 s3 存储桶中。我想从 s3 加载这个模型来预测 sagemaker 中的一些图像。
我知道如何预测我在训练后是否让笔记本实例继续运行,因为它只是一个简单的部署,但如果我想使用旧模型并没有真正的帮助。
我查看了这些资源并能够自己提出一些建议,但它不起作用,因此我在这里:
https://course.fast.ai/deployment_amzn_sagemaker.html#deploy-to-sagemaker https://aws.amazon.com/getting-started/tutorials/build-train-deploy-machine-learning-model-sagemaker/
https://sagemaker.readthedocs.io/en/stable/pipeline.html
我的代码是这样的:
from sagemaker.pipeline import PipelineModel
from sagemaker.model import Model
s3_model_bucket = 'bucket'
s3_model_key_prefix = 'prefix'
data = 's3://{}/{}/{}'.format(s3_model_bucket, s3_model_key_prefix, 'model.tar.gz')
models = ss_model.create_model() # ss_model is my sagemaker.estimator
model = PipelineModel(name=data, role=role, models= [models])
ss_predictor = model.deploy(initial_instance_count=1, instance_type='ml.c4.xlarge')
【问题讨论】:
标签: python amazon-web-services amazon-s3 boto3 amazon-sagemaker