SAM3
Meta の SAM3 モデルを Serverless Cloud API で使用します
コンセプトセグメンテーション(PCS)
テキストプロンプト
import os
import requests
payload = {
"image": {"type": "url", "value": "https://media.roboflow.com/inference/people-walking.jpg"},
"prompts": [
{"type": "text", "text": "person"},
{"type": "text", "text": "backpack"},
],
"output_prob_thresh": 0.5,
"format": "polygon", # または "rle"
}
response = requests.post(
"https://serverless.roboflow.com/sam3/concept_segment",
params={"api_key": os.environ["ROBOFLOW_API_KEY"]},
json=payload,
)
for prompt_result in response.json()["prompt_results"]:
print(prompt_result["echo"], len(prompt_result["predictions"]), "instances")見本ボックスプロンプト
テキストと見本を組み合わせたプロンプト
ビジュアルセグメンテーション(PVS)
推論速度
エンドポイント
Your Roboflow API Key. Get one at https://app.roboflow.com/settings/api
One of 'polygon', 'rle'
polygonOptional ID for caching embeddings.
Score threshold for outputs.
0.5The model ID of SAM3. Use 'sam3/sam3_final' to target the generic base model.
sam3/sam3_finalIoU threshold for cross-prompt NMS. If not set, NMS is disabled. Must be in [0.0, 1.0] when set.
Successful Response
The time in seconds it took to produce the segmentation including preprocessing
Validation Error
POST /sam3/concept_segment?api_key=text HTTP/1.1
Host: serverless.roboflow.com
Content-Type: application/json
Accept: */*
Content-Length: 206
{
"image": {
"type": "url",
"value": "https://media.roboflow.com/notebooks/examples/dog.jpeg"
},
"prompts": [
{
"type": "text",
"text": "person"
},
{
"type": "text",
"text": "car"
}
],
"output_prob_thresh": 0.5,
"format": "polygon"
}{
"prompt_results": [
{
"prompt_index": 0,
"echo": {
"prompt_index": 0,
"type": "text",
"text": "dog",
"num_boxes": 0
},
"predictions": [
{
"masks": [
[
[
345,
251
],
[
344,
252
],
[
343,
253
]
]
],
"confidence": 0.89453125,
"format": "polygon"
}
]
}
],
"time": 0.221
}Your Roboflow API Key. Get one at https://app.roboflow.com/settings/api
SAM2 visual segmentation request.
The ID of the image to be segmented used to retrieve cached embeddings. If an embedding is cached, it will be used instead of generating a new embedding. If no embedding is cached, a new embedding will be generated and cached.
image_idThe format of the response. Must be one of 'json', 'rle', or 'binary'. If binary, masks are returned as binary numpy arrays. If json, masks are converted to polygons. If rle, masks are converted to RLE format.
jsonExample: jsonThe version ID of SAM to be used for this request. Must be one of hiera_tiny, hiera_small, hiera_large, hiera_b_plus
hiera_largeExample: hiera_largeIf true, the model will return three masks. For ambiguous input prompts (such as a single click), this will often produce better masks than a single prediction.
trueExample: trueIf True, saves the low-resolution logits to the cache for potential future use.
falseIf True, attempts to load previously cached low-resolution logits for the given image and prompt set.
falseSuccessful Response
The time in seconds it took to produce the segmentation including preprocessing
Validation Error
POST /sam3/visual_segment?api_key=text HTTP/1.1
Host: serverless.roboflow.com
Content-Type: application/json
Accept: */*
Content-Length: 294
{
"image": {
"type": "url",
"value": "http://www.example-image-url.com"
},
"image_id": "image_id",
"prompts": [
{
"prompts": [
{
"points": [
{
"positive": true,
"x": 100,
"y": 100
}
]
}
]
}
],
"format": "json",
"sam2_version_id": "hiera_large",
"multimask_output": true,
"save_logits_to_cache": false,
"load_logits_from_cache": false
}{
"prompt_results": [
{
"prompt_index": 1,
"predictions": []
}
],
"time": 1
}Inference(セルフホスト型)で使用
Docker で実行
Python でモデルを読み込む
Python での対話型セグメンテーション
Workflows で使用
動画トラッキング
SAM3-3D(ベータ)
あわせて参照
最終更新
役に立ちましたか?