SAM3
Use Meta's SAM3 model through our Serverless Hosted API
Code sample
import os
import requests
import base64
import cv2
import numpy as np
# From "https://media.roboflow.com/notebooks/examples/dog.jpeg"
image = cv2.imread("./dog.jpeg")
# Encode image as base64
_, buffer = cv2.imencode('.jpg', image)
image_base64 = base64.b64encode(buffer).decode('utf-8')
payload = {
"image": { "type": "base64", "value": image_base64 },
"prompts": [
{ "type": "text", "text": "person" },
{ "type": "text", "text": "dog" },
],
"output_prob_thresh": 0.5,
"format": "polygon",
}
url = "https://serverless.roboflow.com/sam3/concept_segment?api_key=" + os.getenv("API_KEY")
response = requests.post(url, json=payload)
data = response.json()
for key in data:
print(key) # Should be prompt_results and timeEndpoints
Query parameters
api_keystringRequired
Your Roboflow API Key. Get one at https://app.roboflow.com/settings/api
Body
formatstringOptionalDefault:
One of 'polygon', 'rle'
polygonimage_idstringOptional
Optional ID for caching embeddings.
output_prob_threshnumberOptionalDefault:
Score threshold for outputs.
0.5model_idstringOptionalDefault:
The model ID of SAM3. Use 'sam3/sam3_final' to target the generic base model.
sam3/sam3_finalnms_iou_thresholdnumberOptional
IoU threshold for cross-prompt NMS. If not set, NMS is disabled. Must be in [0.0, 1.0] when set.
Responses
200
Successful Response
application/json
422
Validation Error
application/json
post
/sam3/concept_segmentLast updated
Was this helpful?