SAM3

हमारे Serverless Hosted API के माध्यम से Meta के SAM3 मॉडल का उपयोग करें

हम Meta के Segment Anything Model 3arrow-up-right इन्फरेंस के माध्यम से समर्थन करते हैं Serverless Hosted API. हम दो अलग-अलग SAM3 endpoints प्रदान करते हैं:

  • Promptable concept segmentation (PCS), सेगमेंटेशन का उपयोग करके text prompts

  • [WIP] Promptable visual segmentation (PVS), interactive segmentation का उपयोग करके points/boxes

Code sample

नीचे एक कोड उदाहरण है जो SAM3 इन्फरेंस के लिए PCS endpoint का उपयोग करता है। उपयोगकर्ता को पास करना होगा Roboflow's API Keyarrow-up-right के माध्यम से API_KEY env variable.

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 time

Endpoints

SAM3 PCS (promptable concept segmentation)

post

Concept Segmentation (Text Prompts)

Allows you to segment objects using text prompts.

Image Input: The image field accepts either:

  • {"type": "url", "value": "<IMAGE_URL>"} - A publicly accessible image URL

  • {"type": "base64", "value": "<BASE64_DATA>"} - Base64 encoded image data

Prompts: Each prompt in the prompts array should have type: "text" and a text field with the object description.

Query parameters
api_keystringRequired

Your Roboflow API Key. Get one at https://app.roboflow.com/settings/api

Body
formatstringOptional

One of 'polygon', 'rle'

Default: polygon
image_idstringOptional

Optional ID for caching embeddings.

output_prob_threshnumberOptional

Score threshold for outputs.

Default: 0.5
model_idstringOptional

The model ID of SAM3. Use 'sam3/sam3_final' to target the generic base model.

Default: sam3/sam3_final
nms_iou_thresholdnumberOptional

IoU threshold for cross-prompt NMS. If not set, NMS is disabled. Must be in [0.0, 1.0] when set.

Responses
chevron-right
200

Successful Response

application/json
post
/sam3/concept_segment

Last updated

Was this helpful?