如何在SageMaker管道中创建一个模型包?

huangapple go评论48阅读模式
英文:

how to create a model package in sagemaker pipeline?

问题

根据此文档链接,https://github.com/aws/sagemaker-python-sdk/blob/master/doc/amazon_sagemaker_model_building_pipeline.rst#model-step,我可以链接SageMaker管道步骤(下面是示例代码)。我想知道,如果需要的话,是否可以直接传递模型所在的S3 URI,而不是step_train.properties.ModelArtifacts.S3ModelArtifacts,以便model_data = s3://somebucket/modelfile.tar...

step_train = TrainingStep(...)
model = Model(
    image_uri=pytorch_estimator.training_image_uri(),
    model_data=step_train.properties.ModelArtifacts.S3ModelArtifacts,
    sagemaker_session=pipeline_session,
    role=role,
)

# 我们可能还想创建一个SageMaker模型
step_model_create = ModelStep(
   name="MyModelCreationStep",
   step_args=model.create(instance_type="ml.m5.xlarge"),
)

# 此外,我们可能还想将模型注册到SageMaker模型注册表
register_model_step_args = model.register(
    content_types=["*"],
    response_types=["application/json"],
    inference_instances=["ml.m5.xlarge"],
    transform_instances=["ml.m5.xlarge"],
    description="MyModelPackage",
)

step_model_registration = ModelStep(
   name="MyModelRegistration",
   step_args=register_model_step_args,
)
...
英文:

based on the documentation here , https://github.com/aws/sagemaker-python-sdk/blob/master/doc/amazon_sagemaker_model_building_pipeline.rst#model-step, I can chain sagemaker pipeline step (sample code below) . i want to know , if needed, is it possible to pass the s3 uri , where model is located directly , instead of step_train.properties.ModelArtifacts.S3ModelArtifacts, such that model_data = s3://somebucket/modelfile.tar...

step_train = TrainingStep(...)
model = Model(
    image_uri=pytorch_estimator.training_image_uri(),
    model_data=step_train.properties.ModelArtifacts.S3ModelArtifacts,
    sagemaker_session=pipeline_session,
    role=role,
)

# we might also want to create a SageMaker Model
step_model_create = ModelStep(
   name="MyModelCreationStep",
   step_args=model.create(instance_type="ml.m5.xlarge"),
)

# in addition, we might also want to register a model to SageMaker Model Registry
register_model_step_args = model.register(
    content_types=["*"],
    response_types=["application/json"],
    inference_instances=["ml.m5.xlarge"],
    transform_instances=["ml.m5.xlarge"],
    description="MyModelPackage",
)

step_model_registration = ModelStep(
   name="MyModelRegistration",
   step_args=register_model_step_args,
)
...

答案1

得分: 1

是的,你可以直接传递URL。

英文:

Yes, you can pass the URL directly.

huangapple
  • 本文由 发表于 2023年4月11日 04:38:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/75980538.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定