For the complete documentation index, see llms.txt. This page is also available as Markdown.

SAM2

हमारे Serverless Hosted API के माध्यम से Meta के SAM2 model का उपयोग करें

हम Meta के Segment Anything Model 2 हमारे माध्यम से इन्फरेंसिंग Serverless Hosted API. SAM2 एक promptable visual segmentation model है जो prompts के रूप में points और bounding boxes स्वीकार करता है। हम दो SAM2 endpoints प्रदान करते हैं:

  • /sam2/embed_image, जो एक image embedding उत्पन्न करता है और cache करता है

  • /sam2/segment_image, जो दिए गए prompts के लिए instance segmentation masks लौटाता है

कोड नमूना

SAM2 को HTTP endpoint के माध्यम से सीधे चलाएँ: curl, या inference-sdk रैपर के साथ।

1

अपनी API Key प्राप्त करें

एक Roboflow खाता बनाएं, अपनी key यहाँ पर ढूँढें Roboflow API settings page और इसे अपने shell में उपलब्ध कराएँ:

export ROBOFLOW_API_KEY="your-key-here"
2

मॉडल चलाएँ

को कॉल करें /sam2/segment_image एंडपॉइंट को curl:

curl --location 'https://serverless.roboflow.com/sam2/segment_image' \
  --header 'Content-Type: application/json' \
  --data '{
    \"api_key\": \"'\"$ROBOFLOW_API_KEY\"'\",
    "image": {"type": "url", "value": "https://media.roboflow.com/quickstart/traffic.jpg"},
    "prompts": {"prompts": [{"points": [{"x": 520, "y": 470, "positive": true}]}]},
    "sam2_version_id": "hiera_tiny"
  }'

Inference speed

Latency मापी गई Roboflow Inference 1x NVIDIA L4 पर, batch size 1, warmup के बाद का औसत।

मॉडल
विलंबता (ms)

sam2

177.7

के साथ मापा गया segment_image पर hiera_large checkpoint. SAM2 image embeddings को cache करता है, इसलिए यह figure हर call में एक fresh image का उपयोग करती है और पूर्ण encode plus decode cost को दर्शाती है। पहले से encoded image को फिर से prompt करना काफ़ी तेज़ है।

सेट करें api_url को अपने deployment target से मिलाएँ:

  • https://serverless.roboflow.com Serverless Hosted API के लिए।

  • http://localhost:9001 एक local Inference server.

  • आपका Dedicated Deployment एक private endpoint के लिए URL.

embedding caching और box prompts सहित अतिरिक्त usage details के लिए, देखें Inference documentation.

अंतिम अपडेट

क्या यह उपयोगी था?