SAM2
हमारे Serverless Cloud API के माध्यम से Meta के SAM2 मॉडल का उपयोग करें
कोड नमूना
2
मॉडल चलाएँ
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"
}'3
मॉडल चलाएँ
import os
import cv2
import supervision as sv
from inference_sdk import InferenceHTTPClient
image = sv.load_image_from_url("https://media.roboflow.com/quickstart/traffic.jpg")
height, width = image.shape[:2]
client = InferenceHTTPClient(
api_url="https://serverless.roboflow.com",
api_key=os.environ["ROBOFLOW_API_KEY"],
)
result = client.sam2_segment_image(
inference_input=image,
prompts=[
{"points": [{"x": 520, "y": 470, "positive": True}]}
],
sam2_version_id="hiera_tiny",
)
detections = sv.Detections.from_sam3(sam3_result=result, resolution_wh=(width, height))
annotated = sv.MaskAnnotator().annotate(image.copy(), detections)
cv2.imwrite("traffic_annotated.png", annotated)
इन्फरेंस गति
मॉडल
विलंबता (ms)
Inference के साथ उपयोग करें (सेल्फ-होस्टेड)
Docker में चलाएँ
Python में मॉडल लोड करें
वर्कफ़्लोज़ में वीडियो ट्रैकिंग
वर्कफ़्लोज़ में निष्पादन मोड
यह भी देखें
अंतिम अपडेट
क्या यह उपयोगी था?