Sagemaker Endpoint Deployment


Amazon SageMaker is a cloud service that helps data scientists and developers to prepare, build, train, and deploy high-quality machine learning (ML) models quickly. In this guide, we'll show how to deploy the Vody Color Classification service on SageMaker as an endpoint.


Ensure you have the AWS Command Line Interface (CLI) installed and configured with the necessary permissions.

The Docker image for your model should be hosted on Amazon Elastic Container Registry (ECR) or another accessible container registry.

An AWS SageMaker execution role with necessary permissions.
Deployment Steps

  1. Push the Docker Image to Amazon Elastic Container Registry (ECR)
    • If your image isn't on ECR yet:

Create a repository in ECR:

aws ecr create-repository --repository-name vody-color-classification

Authenticate Docker to the ECR registry:

$(aws ecr get-login --no-include-email --region us-east-1)

Tag and push the Docker image to ECR:

# Tag the Docker image

docker tag [YOUR_ACCOUNT_ID]

# Push the image to ECR

docker push [YOUR_ACCOUNT_ID]

Replace [YOUR_ACCOUNT_ID] with your AWS account ID.

  1. Create a SageMaker Model
    • To deploy a model with SageMaker, you first need to create a model by providing the location of the Docker container:
aws sagemaker create-model  
    --model-name vody-color-classification  
    --primary-container Image=[YOUR_ACCOUNT_ID],ModelDataUrl=s3://path-to-your-model/model.tar.gz  
    --execution-role-arn arn:aws:iam::[YOUR_ACCOUNT_ID]\:role/service-role/AmazonSageMaker-ExecutionRole-YYYYMMDDTXXXXXX

Replace the placeholders [YOUR_ACCOUNT_ID] with your AWS account ID and s3://path-to-your-model/model.tar.gz with the S3 location of your model artifacts if any.

  1. Create a SageMaker Endpoint Configuration
aws sagemaker create-endpoint-config  
    --endpoint-config-name vody-color-config  
    --production-variants VariantName="variant-1",ModelName="vody-color-classification",InstanceType="ml.m4.xlarge",InitialInstanceCount=1
  1. Deploy the SageMaker Endpoint
aws sagemaker create-endpoint  
    --endpoint-name vody-color-endpoint  
    --endpoint-config-name vody-color-config

Once the endpoint status changes to "InService", it's ready to serve predictions.

  1. Invoke the SageMaker Endpoint
    • To get predictions from the endpoint:
aws sagemaker-runtime invoke-endpoint  
    --endpoint-name vody-color-endpoint  
    --body fileb://input.json  

Replace input.json with your input data file and output.json is where the predictions will be saved.

Advantages of Deploying on SageMaker

  • Fully Managed Service: SageMaker handles the heavy lifting of model deployment, scaling, and management.
  • Automatic Scaling: SageMaker can auto-scale the number of instances available to your endpoint.
  • A/B Testing: You can set up different model variants for A/B testing to see which performs better.
  • Integrated with AWS Ecosystem: Seamless integration with other AWS services such as CloudWatch for monitoring and AWS Lambda for event-driven operations.
  • Security: Use AWS IAM to control access to your SageMaker endpoints and integrate with AWS Key Management Service (KMS) for data encryption.


Amazon SageMaker provides a robust, scalable, and fully-managed platform for deploying machine learning models. Utilizing SageMaker, developers and data scientists can focus on refining their models without being bogged down by the complexities of deployment and infrastructure management.