Amazon JumpStart Image Embedding
Introduction to JumpStart - Image Embedding
This notebook's CI test result for us-west-2 is as follows. CI test results in other regions can be found at the end of the notebook.
Welcome to Amazon SageMaker JumpStart! You can use JumpStart to solve many Machine Learning tasks through one-click in SageMaker Studio, or through SageMaker JumpStart API.
In this demo notebook, we demonstrate how to use the JumpStart API for Image Embedding. Image Embedding is the task of converting an image into meaningful vector representations. We show how to use pre-trained model to find image embeddings.
Note: This notebook was tested on ml.t3.medium instance in Amazon SageMaker Studio with Python 3 (Data Science) kernel and in Amazon SageMaker Notebook instance with conda_python3 kernel.
1. Set Up
Before executing the notebook, there are some initial steps required for set up. This notebook requires latest version of sagemaker and ipywidgets
Permissions and environment variables
To host on Amazon SageMaker, we need to set up and authenticate the use of AWS services. Here, we use the execution role associated with the current notebook as the AWS account role with SageMaker access.
2. Select a model
Here, we download jumpstart model_manifest file from the jumpstart s3 bucket, filter-out all the Image Embedding models and select a model for inference.
Chose a model for Inference
3. Retrieve JumpStart Artifacts & Deploy an Endpoint
We start by retrieving the deploy_image_uri, deploy_source_uri, and model_uri for the pre-trained model. To host the pre-trained model, we create an instance of sagemaker.model.Model and deploy it. This may take a few minutes.
4. Download example images for inference
We download example images from the JumpStart assets S3 bucket.
5. Query endpoint and parse response
Input to the endpoint is a single image in binary format. Output of the endpoint is a json with the image embedding.
6. Clean up the endpoint
Notebook CI Test Results
This notebook was tested in multiple regions. The test results are as follows, except for us-west-2 which is shown at the top of the notebook.