Skip to content

Instantly share code, notes, and snippets.

@azarnyx
Last active May 1, 2021 17:13
Show Gist options
  • Save azarnyx/c4f1c53fcac039f6f8b00362f979dfab to your computer and use it in GitHub Desktop.
Save azarnyx/c4f1c53fcac039f6f8b00362f979dfab to your computer and use it in GitHub Desktop.
from sagemaker.predictor import RealTimePredictor, json_deserializer
import sagemaker
from sagemaker.pytorch import PyTorch, PyTorchModel
from sagemaker.sklearn import SKLearn
role = sagemaker.get_execution_role()
## Class to accept output in JSON format
class Predictor(RealTimePredictor):
def __init__(self, endpoint_name, sagemaker_session):
super().__init__(endpoint_name, sagemaker_session=sagemaker_session, serializer=None,
deserializer=json_deserializer, content_type='application/json')
model = PyTorch(entry_point='serve.py',
name="twitter-fake-true-torch",
role=role,
framework_version='1.7',
py_version='py36',
source_dir='mysrc',
instance_count=1,
instance_type='ml.m5.4xlarge',
predictor_cls=Predictor)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment