Spaces:
Runtime error
Runtime error
from sagemaker.huggingface import HuggingFaceModel | |
import boto3 | |
iam_client = boto3.client('iam') | |
role = iam_client.get_role(RoleName='{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}')['Role']['Arn'] | |
# Hub Model configuration. https://huggingface.co/models | |
hub = { | |
'HF_MODEL_ID':'dalle-mini/dalle-mini', | |
'HF_TASK':'image-classification' | |
} | |
# create Hugging Face Model Class | |
huggingface_model = HuggingFaceModel( | |
transformers_version='4.17.0', | |
pytorch_version='1.10.2', | |
py_version='py38', | |
env=hub, | |
role=role, | |
) | |
# deploy model to SageMaker Inference | |
predictor = huggingface_model.deploy( | |
initial_instance_count=1, # number of instances | |
instance_type='ml.m5.xlarge' # ec2 instance type | |
) | |
predictor.predict({ | |
'inputs': "Astronaut riding a horse" | |
}) |