Skip to content

Instantly share code, notes, and snippets.

@ResidentMario
Last active April 16, 2020 11:03
Show Gist options
  • Save ResidentMario/9de138a804e521fae8ec0aa06ea0c4e1 to your computer and use it in GitHub Desktop.
Save ResidentMario/9de138a804e521fae8ec0aa06ea0c4e1 to your computer and use it in GitHub Desktop.
import sagemaker as sage
# get and pass the auth role and image path, same as before
# this step is unchanged from the training script
role = sage.get_execution_role()
sess = sage.Session()
account = sess.boto_session.client('sts').get_caller_identity()['Account']
region = sess.boto_session.region_name
image = '{}.dkr.ecr.{}.amazonaws.com/quiltdata/sagemaker-demo'.format(account, region)
# create a new Model object
clf = Model(
# insert model path below
model_data='s3://quilt-example/quilt/quilt_sagemaker_demo/model/sagemaker-demo-[...]/output/model.tar.gz',
image=image,
role=role,
sagemaker_session=sess
)
# deploy it to an endpoint
predictor = clf.deploy(1, 'ml.c4.2xlarge')
# connect to the endpoint
predictor = sage.predictor.RealTimePredictor(
'sagemaker-demo-[...]', # insert model name here
sagemaker_session=sess,
content_type="text/csv"
)
@nielsrolf
Copy link

Hi, awesome tutorial! But where does the Model in line 12 come from?

@aflaisler
Copy link

aflaisler commented Jan 29, 2020

@nielsrolf

Hi, awesome tutorial! But where does the Model in line 12 come from?

sagemaker.model.Model

@s-nt-s
Copy link

s-nt-s commented Apr 16, 2020

why you store clf.deploy(1, 'ml.c4.2xlarge') in predictor if later your overwrite predictor with sage.predictor.RealTimePredictor(...?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment