This weblog submit is co-written with George Orlin from Meta.
In the present day, we’re excited to announce that Meta’s Segment Anything Model (SAM) 2.1 imaginative and prescient segmentation mannequin is publicly obtainable by way of Amazon SageMaker JumpStart to deploy and run inference. Meta SAM 2.1 offers state-of-the-art video and picture segmentation capabilities in a single mannequin. This cutting-edge mannequin helps long-context processing, complicated segmentation eventualities, and fine-grained evaluation, making it very best for automating processes for varied industries comparable to medical imaging in healthcare, satellite tv for pc imagery for surroundings monitoring, and object segmentation for autonomous methods. Meta SAM 2.1 is effectively fitted to zero-shot object segmentation and correct object detection based mostly on easy prompts comparable to level coordinates and bounding bins in a body for video monitoring and picture masking.
This mannequin was predominantly educated on AWS, and AWS can even be the primary cloud supplier to make it obtainable to clients. On this submit, we stroll by way of methods to uncover and deploy the Meta SAM 2.1 mannequin utilizing SageMaker JumpStart.
Meta SAM 2.1 overview
Meta SAM 2.1 is a state-of-the-art imaginative and prescient segmentation mannequin designed for high-performance pc imaginative and prescient duties, enabling superior object detection and segmentation workflows. Constructing upon its predecessor, model 2.1 introduces enhanced segmentation accuracy, strong generalization throughout numerous datasets, and scalability for production-grade purposes. These options allow AI researchers and builders in pc imaginative and prescient, picture processing, and data-driven analysis to enhance duties that require detailed evaluation segmentation throughout a number of fields.
Meta SAM 2.1 has a streamlined structure that’s optimized for integration with well-liked model-serving frameworks like TorchServe and will be deployed on Amazon SageMaker AI to energy real-time or batch inference pipelines. Meta SAM 2.1 empowers organizations to attain exact segmentation outcomes in vision-centric workflows with minimal configuration and most effectivity.
Meta SAM 2.1 affords a number of variants—Tiny, Small, Base Plus, and Giant—obtainable now on SageMaker JumpStart, balancing mannequin measurement, velocity, and segmentation efficiency to cater to numerous software wants.
SageMaker JumpStart overview
SageMaker JumpStart affords entry to a broad choice of publicly obtainable basis fashions (FMs). These pre-trained fashions function highly effective beginning factors that may be deeply personalized to handle particular use circumstances. Now you can use state-of-the-art mannequin architectures, comparable to language fashions, pc imaginative and prescient fashions, and extra, with out having to construct them from scratch.
With SageMaker JumpStart, you’ll be able to deploy fashions in a safe surroundings. Fashions hosted on JumpStart will be provisioned on devoted SageMaker Inference cases, together with AWS Trainium and AWS Inferentia based mostly cases, and are remoted inside your digital non-public cloud (VPC). This enforces knowledge safety and compliance, as a result of the fashions function below your personal VPC controls, reasonably than in a shared public surroundings. After deploying an FM, you’ll be able to additional customise and fine-tune it utilizing the in depth capabilities of SageMaker AI, together with SageMaker Inference for deploying fashions and container logs for improved observability. With SageMaker AI, you’ll be able to streamline the whole mannequin deployment course of.
Stipulations
Be sure you have the next conditions to deploy Meta SAM 2.1 and run inference:
- An AWS account that can include all of your AWS sources.
- An AWS Id and Entry Administration (IAM) position to entry SageMaker AI. To study extra about how IAM works with SageMaker AI, check with Id and Entry Administration for Amazon SageMaker AI.
- Entry to Amazon SageMaker Studio or a SageMaker pocket book occasion or an interactive improvement surroundings (IDE) comparable to PyCharm or Visible Studio Code. We suggest utilizing SageMaker Studio for easy deployment and inference.
- Entry to accelerated cases (GPUs) for internet hosting the mannequin.
Uncover Meta SAM 2.1 in SageMaker JumpStart
SageMaker JumpStart offers FMs by way of two major interfaces: SageMaker Studio and the SageMaker Python SDK. This offers a number of choices to find and use a whole lot of fashions to your particular use case.
SageMaker Studio is a complete IDE that gives a unified, web-based interface for performing all features of the machine studying (ML) improvement lifecycle. From getting ready knowledge to constructing, coaching, and deploying fashions, SageMaker Studio offers purpose-built instruments to streamline the whole course of. In SageMaker Studio, you’ll be able to entry SageMaker JumpStart to find and discover the in depth catalog of FMs obtainable for deployment to inference capabilities on SageMaker Inference.
You’ll be able to entry the SageMaker JumpStart UI by way of both Amazon SageMaker Unified Studio or SageMaker Studio. To deploy Meta SAM 2.1 utilizing the SageMaker JumpStart UI, full the next steps:
In SageMaker Unified Studio, on the Construct menu, select JumpStart fashions.
For those who’re already on the SageMaker Studio console, select JumpStart within the navigation pane.

You can be prompted to create a mission, after which you’ll be able to start deployment.
Alternatively, you need to use the SageMaker Python SDK to programmatically entry and use SageMaker JumpStart fashions. This method permits for better flexibility and integration with present AI/ML workflows and pipelines. By offering a number of entry factors, SageMaker JumpStart helps you seamlessly incorporate pre-trained fashions into your AI/ML improvement efforts, no matter your most popular interface or workflow.
Deploy Meta SAM 2.1 for inference utilizing SageMaker JumpStart
On the SageMaker JumpStart touchdown web page, you’ll be able to uncover the general public pre-trained fashions provided by SageMaker AI. You’ll be able to select the Meta mannequin supplier tab to find the Meta fashions obtainable.
For those who’re utilizing SageMaker Studio and don’t see the SAM 2.1 fashions, replace your SageMaker Studio model by shutting down and restarting. For extra details about model updates, check with Shut down and Replace Studio Basic Apps.

You’ll be able to select the mannequin card to view particulars in regards to the mannequin comparable to license, knowledge used to coach, and methods to use. You may also discover two buttons, Deploy and Open Pocket book, which show you how to use the mannequin.

Whenever you select Deploy, you need to be prompted to the subsequent display to decide on an endpoint title and occasion kind to provoke deployment.

Upon defining your endpoint settings, you’ll be able to proceed to the subsequent step to make use of the mannequin.
Deploy Meta SAM 2.1 imaginative and prescient segmentation mannequin for inference utilizing the Python SDK
Whenever you select Deploy, mannequin deployment will begin. Alternatively, you’ll be able to deploy by way of the instance pocket book by selecting Open Pocket book. The pocket book offers end-to-end steering on methods to deploy the mannequin for inference and clear up sources.
To deploy utilizing a pocket book, you begin by deciding on an applicable mannequin, specified by the model_id. You’ll be able to deploy any of the chosen fashions on SageMaker AI.
You’ll be able to deploy a Meta SAM 2.1 imaginative and prescient segmentation mannequin utilizing SageMaker JumpStart with the next SageMaker Python SDK code:
This deploys the mannequin on SageMaker AI with default configurations, together with default occasion kind and default VPC configurations. You’ll be able to change these configurations by specifying non-default values in JumpStartModel. After it’s deployed, you’ll be able to run inference towards the deployed endpoint by way of the SageMaker predictor. There are three duties which might be obtainable with this endpoint: automated masks generator, picture predictor, and video predictor. We offer a code snippet for every later on this submit. To make use of the predictor, a sure payload schema must be adopted. The endpoint has sticky classes enabled, so to begin inference, it’s good to ship a start_session payload:
The start_session invocation wants an enter media kind of both picture or video and the base64 encoded knowledge of the media. It will launch a session with an occasion of the mannequin and cargo the media to be segmented.
To shut a session, ship a close_session invocation:
If x-amzn-sagemaker-closed-session-id exists as a header, then the session has been efficiently closed.
To proceed a session and retrieve the session ID of the prevailing session, the response header could have the x-amzn-sagemaker-session-id key with the present session ID for any operation that’s not start_session or close_session. Operations that aren’t start_session or close_session must be invoked with a response stream. That is because of the measurement of the ensuing payload being bigger than what SageMaker real-time endpoints can return.
It is a primary instance of interacting with the SAM 2.1 SageMaker JumpStart endpoint with sticky classes. The next examples for every of the duties reference these operations with out repeating them. The returned knowledge is of mime kind JSONL. For extra full examples, check with the instance notebooks for Meta SAM 2.1 on SageMaker Jumpstart.
Beneficial cases and benchmarks
The next desk lists all of the Meta SAM 2.1 fashions obtainable in SageMaker JumpStart together with the model_id, default occasion sorts, and most variety of whole tokens (sum of variety of enter tokens and variety of generated tokens) supported for every of those fashions. For elevated context size, you’ll be able to modify the default occasion kind within the SageMaker JumpStart UI.
| Mannequin Title | Mannequin ID | Default Occasion Sort | Supported Occasion Sorts |
| Meta SAM 2.1 Tiny | meta-vs-sam-2-1-hiera-tiny | ml.g6.24xlarge (5.5 MB whole picture or video measurement) |
ml.g5.24xlarge ml.g5.48xlarge ml.g6.24xlarge ml.g6.48xlarge ml.p4d.24xlarge ml.p4de.24xlarge |
| Meta SAM 2.1 Small | meta-vs-sam-2-1-hiera-small | ml.g6.24xlarge (5.5 MB whole picture or video measurement) |
ml.g5.24xlarge ml.g5.48xlarge ml.g6.24xlarge ml.g6.48xlarge ml.p4d.24xlarge ml.p4de.24xlarge |
| Meta SAM 2.1 Base Plus | meta-vs-sam-2-1-hiera-base-plus | ml.g6.24xlarge (5.5 MB whole picture or video measurement) |
ml.g5.24xlarge ml.g5.48xlarge ml.g6.24xlarge ml.g6.48xlarge ml.p4d.24xlarge ml.p4de.24xlarge |
| Meta SAM 2.1 Giant | meta-vs-sam-2-1-hiera-large | ml.g6.24xlarge (5.5 MB whole picture or video measurement) |
ml.g5.24xlarge ml.g5.48xlarge ml.g6.24xlarge ml.g6.48xlarge ml.p4d.24xlarge ml.p4de.24xlarge |
Meta SAM 2.1 use circumstances: Inference and immediate examples
After you deploy the mannequin utilizing SageMaker JumpStart, it is best to be capable of see a reference Jupyter pocket book that references the parser and helper features wanted to start utilizing Meta SAM 2.1. After you observe these cells within the pocket book, you need to be prepared to start utilizing the mannequin’s imaginative and prescient segmentation capabilities.
Meta SAM 2.1 affords assist for 3 totally different duties (automated masks generator, picture predictor, video predictor) to generate masks for varied objects in photographs, together with object monitoring in movies. Within the following examples, we display methods to use the automated masks generator and picture predictor on a JPG of a truck. This truck.jpg file is saved within the jumpstart-cache-prod bucket; you’ll be able to entry it with the next code:
After you’ve got your picture and it’s encoded, you’ll be able to create masks for objects within the picture. To be used circumstances the place you wish to generate masks for each object within the picture, you need to use the automated masks generator job.
Automated masks generator
The automated masks generator is nice for AI researchers for pc imaginative and prescient duties and purposes comparable to medical imaging and diagnostics to routinely section areas of curiosity like tumors or particular organs to offer extra correct diagnostic assist. Moreover, the automated masks generator will be notably helpful within the autonomous car area, during which it could section out parts in a digicam like pedestrians, automobiles, and different objects. Let’s use the automated masks generator to generate masks for all of the objects in truck.jpg.

The next code is the immediate to generate masks to your base64 encoded picture:
We obtain the next output (parsed and visualized).

Picture predictor
Moreover, you’ll be able to select which objects within the offered picture you wish to create a masks for by including factors inside that object for Meta SAM 2.1 to create. A use case for the picture predictor will be priceless for duties associated to design and modeling by automating processes that usually require guide efforts. For instance, the picture predictor can automate turning 2D photographs into 3D fashions by analyzing 2D photographs of blueprints, sketches, or ground plans and producing preliminary 3D fashions. That is one in every of many examples of how the picture predictor can act as a bridge between 2D and 3D development throughout many alternative duties. We use the next picture with the factors that we used to immediate Meta SAM 2.1 for masking the article.

The next code is used to immediate Meta SAM 2.1 and plot the coordinates:
We obtain the next output (parsed and visualized).

Video predictor
We now display methods to immediate Meta SAM 2.1 for object monitoring on video. One use case could be for ergonomic knowledge assortment and coaching functions. You should use the video predictor to research the motion and posture of people in actual time, serving as a solution to cut back damage and enhance efficiency by setting alarms for dangerous posture or actions. Let’s begin by accessing the basketball-layup.mp4 file [1] from the jumpstart-cache-prod S3 bucket outlined within the following code:
Video:
The next code reveals how one can arrange the immediate format to trace objects within the video. The primary object will use coordinates to trace and never monitor, and the second object will monitor one coordinate.
We obtain the next output (parsed and visualized).
Video:
Right here we are able to see that Meta SAM 2.1 Tiny was capable of efficiently monitor the objects based mostly off the coordinates that had been offered in immediate.
Clear up
To keep away from incurring pointless prices, if you’re executed, delete the SageMaker AI endpoints utilizing the next code:
Alternatively, to make use of the SageMaker AI console, full the next steps:
- On the SageMaker AI console, below Inference within the navigation pane, select
- Seek for the embedding and textual content era endpoints.
- On the endpoint particulars web page, select Delete.
- Select Delete once more to verify.
Conclusion
On this submit, we explored how SageMaker JumpStart empowers knowledge scientists and ML engineers to find, entry, and deploy a variety of pre-trained FMs for inference, together with Meta’s most superior and succesful fashions to this point. Get began with SageMaker JumpStart and Meta SAM 2.1 fashions in the present day. For extra details about SageMaker JumpStart, see SageMaker JumpStart pretrained fashions and Getting began with Amazon SageMaker JumpStart.
Sources:
[1] Erčulj F, Štrumbelj E (2015) Basketball Shot Sorts and Shot Success in Completely different Ranges of Aggressive Basketball. PLOS ONE 10(6): e0128885. https://doi.org/10.1371/journal.pone.0128885
Concerning the Authors
Marco Punio is a Sr. Specialist Options Architect centered on generative AI technique, utilized AI options, and conducting analysis to assist clients hyper-scale on AWS. As a member of the third Celebration Mannequin Supplier Utilized Sciences Options Structure staff at AWS, he’s a World Lead for the Meta – AWS Partnership and technical technique. Primarily based in Seattle, WA, Marco enjoys writing, studying, exercising, and constructing purposes in his free time.
Deepak Rupakula is a Principal GTM lead within the specialists group at AWS. He focuses on creating GTM technique for giant language fashions like Meta throughout AWS companies like Amazon Bedrock and Amazon SageMaker AI. With over 15 years of expertise within the tech business, his expertise consists of management roles in product administration, buyer success, and analytics.
Harish Rao is a Senior Options Architect at AWS, specializing in large-scale distributed AI coaching and inference. He empowers clients to harness the facility of AI to drive innovation and clear up complicated challenges. Outdoors of labor, Harish embraces an lively way of life, having fun with the tranquility of climbing, the depth of racquetball, and the psychological readability of mindfulness practices.
Baladithya Balamurugan is a Options Architect at AWS centered on ML deployments for inference and utilizing AWS Neuron to speed up coaching and inference. He works with clients to allow and speed up their ML deployments on companies comparable to Amazon SageMaker AI and Amazon EC2. Primarily based in San Francisco, Baladithya enjoys tinkering, creating purposes, and constructing his homelab in his free time.
Banu Nagasundaram leads product, engineering, and strategic partnerships for Amazon SageMaker JumpStart, SageMaker AI’s machine studying and generative AI hub. She is captivated with constructing options that assist clients speed up their AI journey and unlock enterprise worth.
Naman Nandan is a software program improvement engineer at AWS, specializing in enabling large-scale AI/ML inference workloads on Amazon SageMaker AI utilizing TorchServe, a mission collectively developed by AWS and Meta. In his free time, he enjoys taking part in tennis and occurring hikes.

