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

SAM3

Meta의 SAM3 모델을 Serverless Cloud API를 통해 사용하세요.

Meta의 Segment Anything Model 3 추론을 지원합니다 Serverless Cloud API. 두 가지 서로 다른 SAM3 엔드포인트를 제공합니다:

Roboflow에서 SAM3 모델 학습은 유료 요금제 에 제공되며, 이 요금제에는 사용량 기반 청구가 포함됩니다. 그런 다음 SAM3 아키텍처의 "Request Feature" 버튼으로 액세스를 요청하여 기능을 사용할 수 있습니다 학습 흐름.

미세 조정된 SAM3 모델은 Serverless Cloud API에서 실행할 수 없습니다. 이를 전용 배포 또는 자체 호스팅 Inference에 배포하세요. 호스팅되는 sam3 이 페이지의 엔드포인트는 영향을 받지 않습니다.

  • 프롬프트 기반 개념 분할 (PCS), 이미지 내 개념의 모든 인스턴스를 분할합니다. 개념은 텍스트 프롬프트, 예시 상자 또는 둘 다로 설명됩니다.

  • 프롬프트 기반 시각 분할 (PVS), SAM2 스타일로 포인트 또는 상자에서 요청당 하나의 객체를 대화형으로 분할합니다.

이 표를 사용하여 엔드포인트를 선택하세요:

보유한 항목
원하는 항목
사용

텍스트 설명(예: "person")

일치하는 모든 인스턴스의 마스크

/sam3/concept_segment

예시 객체 하나를 둘러싼 상자

유사한 모든 인스턴스의 마스크

/sam3/concept_segment

객체를 포함하거나 제외하기 위한 텍스트와 예시 상자

일치하는 모든 인스턴스의 마스크

/sam3/concept_segment

특정 객체 하나에 대한 클릭 또는 상자

해당 객체만의 마스크

/sam3/visual_segment

다음 항목을 전달하세요: API 키 다음으로 api_key 모든 요청의 쿼리 매개변수로 사용하세요.

개념 분할(PCS)

POST https://serverless.roboflow.com/sam3/concept_segment

다음의 각 항목: prompts 는 하나의 개념을 설명합니다. 응답에는 하나의 prompt_results 항목이 프롬프트당 하나씩 포함되며, 각 항목은 발견된 모든 인스턴스를 보유합니다. 요청은 최대 16개의 프롬프트를 허용합니다.

텍스트 프롬프트

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"]), "인스턴스")

이미지는 인라인으로도 다음과 같이 전송할 수 있습니다 {"type": "base64", "value": "<BASE64_IMAGE>"}.

예시 상자 프롬프트

텍스트 대신 예시, 즉 예시 객체 하나를 둘러싼 상자로 프롬프트를 지정할 수 있습니다. 모델은 상자로 둘러싼 객체뿐 아니라 예시와 일치하는 모든 인스턴스를 찾습니다.

상자는 절대 픽셀 좌표를 사용합니다. 두 가지 형식이 허용됩니다:

  • {"x": ..., "y": ..., "width": ..., "height": ...} 여기서 x, y 는 왼쪽 상단 모서리입니다

  • {"x0": ..., "y0": ..., "x1": ..., "y1": ...} 명시적 모서리용

box_labels 는 다음 경우 필수입니다 boxes 가 설정되며 상자당 하나의 항목이 있어야 합니다: 1 은 양성 예시를 표시합니다(이와 같은 객체 찾기). 0 은 음성 예시를 표시합니다(이와 같은 객체 제외).

텍스트 및 예시 결합 프롬프트

하나의 프롬프트는 텍스트와 예시 상자를 모두 포함할 수 있습니다. 이는 시각적 예시로 텍스트 개념을 좁히거나 음성 예시로 유사한 객체를 제외하는 데 유용합니다:

여기서 모델은 첫 번째(양성) 예시와 일치하는 사람을 분할하는 한편, 두 번째(음성) 예시와 유사한 인스턴스는 억제합니다.

시각 분할(PVS)

POST https://serverless.roboflow.com/sam3/visual_segment

PVS는 클릭 또는 상자로 지정된 특정 객체 하나를 분할합니다. 대화형 휴먼 인 더 루프 마스크 보정에 사용하세요. 개념의 모든 인스턴스가 필요하다면 PCS를 사용하세요.

프롬프트에는 다음이 포함될 수 있습니다 points, 하나의 box, 또는 둘 다:

  • points 는 절대 픽셀 좌표입니다. "positive": true 는 클릭한 영역을 포함하고, false 는 이를 제외합니다. 마스크를 보정하려면 포인트를 더 추가하세요.

  • box 는 중심 기준 좌표를 사용합니다: x, y 는 상자의 중심이며, 왼쪽 상단 기준인 PCS 상자와 다릅니다.

응답에는 프롬프트에 대한 신뢰도가 가장 높은 단일 마스크가 포함됩니다. multimask_output 는 모델이 생성하는 내부 마스크 제안 수를 제어합니다(true일 때 3개). 하지만 응답에는 항상 최상의 제안이 선택됩니다.

OpenCV를 사용하는 대화형 데모는 다음을 참조하세요 GitHub Gist, 이 동영상에서 사용되었습니다:

추론 속도

다음을 사용하여 측정한 지연 시간 Roboflow Inference 에서 1x NVIDIA L4, 배치 크기 1, 워밍업 후 평균.

모델
지연 시간(ms)

sam3

251.4

단일 텍스트 프롬프트의 개념 분할로 측정했습니다.

엔드포인트

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
200

Successful Response

application/json
timenumberRequired

The time in seconds it took to produce the segmentation including preprocessing

post/sam3/concept_segment
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
}

SAM3 PVS (promptable visual segmentation)

post

Interactive Segmentation (SAM 2 Style)

SAM 3 also supports interactive segmentation using points and boxes.

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

Note: NumPy arrays are NOT supported on the serverless API. Use URL or base64 encoding only.

Prompts: Support point-based prompts with positive/negative clicks for interactive segmentation.

Query parameters
api_keystringRequired

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

Body

SAM2 visual segmentation request.

image_idstringOptional

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.

Example: image_id
formatstringOptional

The 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.

Default: jsonExample: json
sam2_version_idstringOptional

The version ID of SAM to be used for this request. Must be one of hiera_tiny, hiera_small, hiera_large, hiera_b_plus

Default: hiera_largeExample: hiera_large
multimask_outputbooleanOptional

If 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.

Default: trueExample: true
save_logits_to_cachebooleanOptional

If True, saves the low-resolution logits to the cache for potential future use.

Default: false
load_logits_from_cachebooleanOptional

If True, attempts to load previously cached low-resolution logits for the given image and prompt set.

Default: false
Responses
200

Successful Response

application/json
timenumberRequired

The time in seconds it took to produce the segmentation including preprocessing

post/sam3/visual_segment
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(자체 호스팅)와 함께 사용

SAM3는 자체 하드웨어에서도 실행할 수 있으며, 다음으로 프로세스 내에서 로드하거나 inference 패키지를 사용하거나 GPU 컨테이너에서 제공할 수 있습니다.

Docker에서 실행

서버는 동일한 /sam3/concept_segment/sam3/visual_segment 위에 문서화된 엔드포인트를 다음에서 노출합니다 http://localhost:9001.

Python에서 모델 로드

가중치는 처음 사용할 때 자동으로 다운로드됩니다.

Python의 대화형 분할

Sam3ForInteractiveImageSegmentation 는 휴먼 인 더 루프 마스크 보정을 위해 SAM2 스타일의 포인트 및 상자 인터페이스를 구현합니다:

Workflows에서 사용

다음에서 두 개의 SAM3 이미지 블록을 사용할 수 있습니다 Workflows:

  • SAM 3 는 개념 분할을 실행합니다. 원하는 클래스를 다음에 입력하세요 class_names (예: ["person", "vehicle"]) 그러면 블록은 다른 단계에서 사용할 수 있는 인스턴스 분할 예측을 출력합니다.

  • SAM 3 Interactive 는 프롬프트 기반 시각 분할을 실행합니다. 레이블이 지정된 포인트(종류 labeled_points)를 제공하세요. 예: [{"x": 320, "y": 240, "positive": true}], 그리고 선택적으로 다른 모델의 탐지를 다음에 연결하세요 boxes 필드. 각 상자는 별도의 프롬프트가 되며, 해당 클래스 이름이 예측된 마스크로 전달됩니다.

동영상 추적

다음 SAM3 Video Tracker 블록(roboflow_core/sam3_video@v1)은 SAM3의 스트리밍 개념 추적기를 프레임별로 실행합니다. 다음에서 텍스트로 개념을 제공하면 class_names, 모델이 모든 프레임에서 융합된 탐지와 추적을 실행합니다. 개념과 일치하는 객체는 안정적인 tracker_id를 유지하며, 탐지기 시드 추적과 달리 스트림 중간에 장면에 들어오는 객체도 재프롬프트나 업스트림 탐지 모델 없이 자동으로 포착됩니다. 각 마스크는 일치한 개념을 클래스 이름으로, 모델의 탐지 점수를 신뢰도로 포함합니다(다음으로 필터링 threshold, 기본값 0.5).

  • 상태 유지형이며 로컬 전용입니다. 추적 세션 하나가 각 video_metadata.video_identifier별로 유지됩니다. 이 블록에는 WORKFLOWS_STEP_EXECUTION_MODE=local, GPU 및 영구적인 WebRTC 세션이 필요합니다.

  • 프롬프트 스케줄링이 없습니다. 개념 프롬프트는 세션당 한 번 등록되며, 스트림이 재시작되거나 class_names 변경될 때만 세션이 다시 시드됩니다. 탐지기 기반(상자 프롬프트) 동영상 추적에는 다음의 SAM2 Video Tracker 블록을 사용하세요 SAM2 페이지, 여기서는 다음도 허용합니다 sam3trackervideo 를 다음으로 model_id.

  • 모델. model_id 는 기본값으로 sam3video, 프레임별 스트리밍 인터페이스를 노출하는 SAM3 비디오의 HuggingFace transformers 포트입니다. 네이티브 sam3 패키지의 비디오 예측기는 전체 동영상을 미리 필요로 하므로 라이브 스트림에 사용할 수 없습니다.

SAM3-3D(베타)

SAM3-3D는 2D 이미지와 마스크를 메시 및 가우시안 스플랫 같은 3D 에셋으로 변환합니다.

종속성을 설치하세요(Python 3.10 권장):

또는 3D 지원 GPU 컨테이너를 빌드하고 실행하세요:

입력. RGB 이미지와 mask_input, 객체 영역을 정의합니다. 마스크는 이진 배열((H, W) 또는 (N, H, W)), COCO 플랫 다각형, 포인트 쌍 다각형, RLE 딕셔너리 또는 sv.Detections SAM2 또는 다른 분할 모델의 객체로 허용됩니다.

출력. mesh_glb (결합된 장면 메시, GLB), gaussian_ply (결합된 가우시안 스플랫, PLY), objects (객체별 mesh_glb, gaussian_ply, 및 metadata 회전, 이동 및 스케일 포함), 그리고 time.

설정 SPARSE_ATTN_BACKENDATTN_BACKEND 을 다음으로 설정 flash_attn 파이프라인의 속도를 높입니다. Workflows에서는 SAM3-3D가 로컬 실행과 원격 실행을 지원하며, 이를 통해 sam3_3d_infer() 클라이언트 메서드 또는 /sam3_3d/infer 엔드포인트.

또한 참조

  • SAM2 - 점과 박스 프롬프트 기반 세분화, 그리고 탐지기 시드 비디오 추적.

  • Segment Anything(SAM) - 원래의 단일 객체 모델.

마지막 업데이트

도움이 되었나요?