Automatically trigger sagemaker inference endpoints

0

I have created a sagemaker inference endpoint to detect objects on videos. The videos can be about 20 mins long. I want to invoke the endpoint when there is a new video file uploaded to s3 or schedule it run on batches of videos every night. Any pointers on how to invoke the endpoint automatically would be helpful.

I cannot use a lambda s3 trigger here, since max timeout on lambda is 15 mins and it takes longer for my processes.

Thanks.

3 Answers
0
Accepted Answer

If the maximum timeout of AWS Lambda is not sufficient for your video processing needs, you can explore alternative approaches to automatically invoke your SageMaker inference endpoint when new videos are uploaded to Amazon S3 or schedule it to run on batches of videos every night. Here are a couple of suggestions:

AWS Step Functions: AWS Step Functions is a serverless workflow service that enables you to coordinate multiple AWS services into serverless workflows. You can create a Step Function workflow that triggers the SageMaker inference endpoint and handles the processing of your videos. Here's a high-level overview of the approach:

Configure an event notification on your S3 bucket to trigger an AWS Lambda function whenever a new video file is uploaded. This Lambda function will start the Step Function workflow. Define a Step Function workflow that includes a task to invoke your SageMaker inference endpoint for each video file. You can use the AWS SDK or Boto3 library in a Lambda function to call the SageMaker endpoint. Handle the batching or parallel processing of videos within the Step Function workflow, ensuring that the processing time stays within the allowed limits. Configure the workflow to run automatically every night using a scheduled event (e.g., AWS CloudWatch Events). With this approach, you can handle videos of any length as the Step Function workflow can span longer durations without the limitations of a Lambda function.

AWS Batch: AWS Batch is a fully managed service for running batch computing workloads. It allows you to efficiently run large-scale, parallel, and high-performance computing (HPC) applications in the AWS Cloud. You can use AWS Batch to process your videos in batches, either as individual videos or as a group.

Here's a high-level overview of the approach:

Configure an event notification on your S3 bucket to trigger an AWS Lambda function whenever a new video file is uploaded. This Lambda function will create a job in AWS Batch. Define an AWS Batch job that runs the processing logic for a single video or a group of videos. Configure AWS Batch to handle the necessary resources and parallelism required for your video processing. You can specify the desired instance types and count to optimize the processing speed and cost. Schedule AWS Batch jobs to run every night using AWS CloudWatch Events or other scheduling mechanisms available in AWS (e.g., Amazon EventBridge). This approach allows you to process videos in batches and efficiently utilize computing resources for parallel processing.

By utilizing AWS Step Functions or AWS Batch, you can overcome the time limitations of AWS Lambda and automate the invocation of your SageMaker inference endpoint when new videos are uploaded or on a scheduled basis. Choose the approach that best suits your requirements and workload characteristics.

AWS
answered 10 months ago
0

If the process takes more than 15 minutes, ECS or AWS Batch would be an option.
In addition, if the size of the file is reasonably large, it may take a considerable amount of time to batch process the file in one go.
So, how about creating an EventBridge that triggers an event when a file is put to S3 to run an ECS job?
The following document uses SNS as the target but could be achieved by selecting ECS.
https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-s3-object-created-tutorial.html

profile picture
EXPERT
answered 10 months ago
  • Any resource to set up a batch for object detection models - input being a json or video?

0

Hi, you will obtain maximum flexibility by using the Lambda trigger that you mention. This lambda should then start a Step Function as described in https://awstip.com/invoking-step-function-from-lambda-fb400ee63f18

From this StepFunction, you can then start waiting loops. trigger ECS / Fargate containers or other Lambdas to develop a Step workflow exactly matching your requirements.

See https://docs.aws.amazon.com/step-functions/latest/dg/welcome.html

profile pictureAWS
EXPERT
answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions