Skip to content

Deploy an endpoint for the base EfficientNet model

The base EfficientNet model provides image classification on the 1000 ImageNet labels.

Custom model

To create a custom model to classify images in based in custom labels see the Training page.

1. Subscribe to the offering

  1. Log in to AWS with a user with administrative privileges
  2. Navigate to the EfficientNet-B3 listing on the AWS Marketplace
  3. Click Continue to Subscribe
  4. Click on Accept offer (it might take 1 or 2 minutes for AWS to accept the offer).

    Note that there is no charge for subscribing to this offering only when launching the model on SageMaker

  5. Once you are subscribed click Continue to Configuration

  6. On the Configure and launch page
    1. Select SageMaker console as the Launch Method (you can also use the AWS CLI)
    2. Select the version and region where you want to launch the model endpoint
    3. On Amazon SageMaker options select Create a real-time inference endpoint
  7. Click on View in Amazon SageMaker

2. Create the endpoint

In the Create endpoint page:

  1. Select a Model name e.g. efficientnet-b3
  2. Select or create a new IAM role for executing the model
  3. Under Container definition
    1. Verify Use a model package subscription from AWS Marketplace is selected
  4. Click on Next
  5. Select an Endpoint name e.g. efficientnet-b3
  6. Under Attach endpoint configuration select Create a new endpoint configuration
  7. Under New endpoint configuration
    1. Verify the new model (e.g. efficientnet-b3) is listed under Production variants
    2. Click on Edit in the Actions column and select the instance types you want for the endpoint. The minimun recommended is ml.c5.xlarge
    3. Click on Create endpoint configuration
  8. Finally click on Submit

A new endpoint will be created (this can take a couple of minutes).

SageMaker efficientnet-b3 endpoint

3. Making a query

With the endpoint ready you will have an URL to make predictions, for example:

https://runtime.sagemaker.us-east-1.amazonaws.com/endpoints/efficientnet-b3/invocations

How to query the Invocations endpoint

For complete documentation on how to query this endpoint see the AWS Docs: InvokeEndpoint documentation in AWS.

The key part being how to handlee the AWS Signature Version 4, for example using Python.

A simple example using boto and this photo as input:

Horses

You can use the Python boto3 library to make a query.

import boto3

client = boto3.client("sagemaker-runtime")
endpoint_name = "efficientnet-b3"

content_type = "image/jpeg"

with open("validation/horses.jpg", "rb") as f:
    payload = bytearray(f.read())

response = client.invoke_endpoint(
    EndpointName=endpoint_name, ContentType=content_type, Body=payload
)

print(response["Body"].read())

Response:

["sorrel","cowboy hat, ten-gallon hat","hartebeest","worm fence, snake fence, snake-rail fence, Virginia fence","horse cart, horse-cart"]

Sorrel

Note that sorrel is a type of horse.

Full API docs

For the complete documentation of the API including the different inputs and responses and more ways to query the Invocations endpoint see the API page.