> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ovalbee.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ovalbee.com/_mcp/server.

# Serve SAM3

> Loads SAM3 onto the GPU once and keeps answering segmentation requests until the deployment is stopped. It powers the Smart Tool in the labeling tool. Holds the GPU for its whole lifetime.

Runs on: gpu  Dockerfile

> **Note**
>
> First run can take longer while the worker pulls the configured Docker image.

## Overview

Segments objects with SAM3, a model that stays loaded in memory and answers over HTTP. Start it from the **Deployments** page or place it on the canvas as a [deploy node](/concepts/deployments#deploy-nodes-in-a-flow). It keeps running until you stop it.

A running deployment is what the **Smart Tool** in the labeling tool calls. Draw a box around an object, add a few clicks on it or next to it, and a mask comes back. Every running SAM3 deployment in the workspace shows up in the Smart Tool model list.

The same deployment also answers your own code. Send a box and clicks for one object, or send text prompts such as `person` and get every matching object on a batch of images.

SAM3 is Meta's model, and its code and weights are used under the [SAM License](https://github.com/facebookresearch/sam3/blob/11dec2936de97f2857c1f76b66d982d5a001155d/LICENSE).

## Prerequisites

| Requirement                 | What you need                                                                                                                                                                                                                                                                                                                                 |
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **GPU worker**              | A worker with a free GPU. SAM3 does not run on a CPU.                                                                                                                                                                                                                                                                                         |
| **Images in the workspace** | The images to segment, already uploaded. Calls name images by asset id.                                                                                                                                                                                                                                                                       |
| **Model**                   | SAM3 copied from the catalog, or SAM3 weights of your own. The catalog's weights are OvalBee's copy of the authors' checkpoint, which comes with the text of the [SAM License](https://github.com/facebookresearch/sam3/blob/11dec2936de97f2857c1f76b66d982d5a001155d/LICENSE) it is distributed under, so no Hugging Face account is needed. |
| **API token** (optional)    | A personal token created under **Settings → Developer**, for calls from your own code. The labeling tool needs none.                                                                                                                                                                                                                          |

## How it works

Fetches the model's weights - the catalog's from OvalBee's copy, checked against a pinned SHA-256 - and loads them onto the GPU once at startup.

Reports itself as not ready until the weights are in memory, then starts accepting calls.

Downloads the image a call names and encodes it once, so every later click on that image skips both the download and the encoding.

Turns the box and the clicks into one object mask. A new click on the same box refines the previous mask instead of starting over.

Answers with the mask, or with an empty mask when the model is not confident enough.

## FAQ

#### How do I use it from the labeling tool?

Start the deployment and wait until it shows as running. Open a labeling queue, pick the **Smart Tool**, and choose the deployment in the model list if the workspace runs more than one. A deployment that is stopped or still starting doesn't appear in the list.

#### How do I call the endpoint from my own code?

Open the deployment on the **Deployments** page. It shows the base URL and a ready-made command for each route. Calls go through OvalBee, which checks your API token and forwards them to the container.

#### Which routes does the deployment answer?

`/segment` segments one object on a workspace image from a box and clicks, and `/smart_segmentation` is the same call under another name. `/segment/upload` does the same for an image you upload with the call instead of naming an asset. `/predict` finds every object that matches your text prompts on a list of images. `/encode_image` downloads an image ahead of the first click, `DELETE /images` drops an image from memory, and `/info` reports which weights are loaded.

#### What goes into a segment request?

An image asset id, plus a box, clicks, or both. Box corners are inclusive and clicks are in image pixels. Positive clicks mark the object and negative clicks mark what isn't part of it. A request with neither a box nor a click is rejected.

#### Why did I get an empty mask?

Either the best mask scored below `confidence_threshold`, or a click lies outside the box. The second case is common when you shrink the box after clicking. Neither is an error, so the response still reports success.

#### How does a mask come back?

As a Supervisely bitmap: the top-left corner of the mask in image pixels, and the mask itself as a base64 string of a compressed PNG. The response also carries the model's score for that mask.

#### What does a single click do?

One click is ambiguous: it may mean a shoulder, a person, or a whole crowd. The model proposes several masks and returns the one it scores highest. Each further click on the same box refines that mask. Going back to one click starts a new object.

#### What does crop_output_to_bbox change?

The model always sees the whole image and treats the box as a hint. When the setting is on, the mask is trimmed to the box, so nothing outside the box you drew comes back. Turn it off to keep parts of the object that spill past the box.

#### What goes into a predict request?

Up to 128 image asset ids and one or more text prompts. Each image comes back with a Supervisely annotation that holds one class per prompt and one mask per matching object, plus the number of objects found.

#### Can I use my own SAM3 checkpoint?

Yes. Pick a SAM3 model version from the registry in **Model**. With the safe-weights policy on, only safetensors weights load; a `.pt` checkpoint has to be converted first.

#### Why can I not pick a CPU machine for it?

SAM3 runs on a GPU only, so the deploy dialog offers only machine classes whose device type is `gpu`. Should it be placed on any other class anyway, the deployment stops at startup with a message saying so, instead of loading halfway and failing later.

## Inputs

**`Model`** `model` — required

SAM3 weights the deployment loads and keeps in memory: SAM3 from the catalog, OvalBee's copy of its authors' weights, or weights of your own. With the safe-weights policy on, only safetensors load. Key: `MODEL`.

---

**`Config`** `yaml` — required

YAML defaults for every request. A request may override `confidence_threshold` and `crop_output_to_bbox` per call. Key: `CONFIG`.

---

## Outputs

**`Deployment`** `deployment`

The running SAM3 deployment, set once it answers requests. Wire it into Evaluate interactive instance segmentation to measure it on your own data. Key: `DEPLOYMENT`.

---

## Runtime

The deployment runs in its own container on a GPU worker. A catalog model's weights are downloaded from OvalBee's copy when the deployment starts, through the workspace's model cache when the worker has one. It holds the GPU from the moment it starts until you stop it, idle or not, so stop a deployment you're done with.

## JSON config

Machine-readable node interface for automation and advanced usage.

#### Show JSON

```json
{
  "name": "Serve SAM3",
  "description": "Loads SAM3 onto the GPU once and keeps answering segmentation requests until the deployment is stopped. It powers the Smart Tool in the labeling tool. Holds the GPU for its whole lifetime.\n",
  "category": "Models",
  "namespace": "ovalbee",
  "templateKey": "models/sam3/serve_sam3",
  "version": "v1",
  "inputs": [
    {
      "key": "MODEL",
      "label": "Model",
      "type": "model",
      "description": "SAM3 weights the deployment loads and keeps in memory: SAM3 from the catalog, OvalBee's copy of its authors' weights, or weights of your own. With the safe-weights policy on, only safetensors load.\n",
      "required": true,
      "default": null,
      "visibleWhen": null,
      "options": {
        "framework": "sam3",
        "task_type": "instance_segmentation"
      }
    },
    {
      "key": "CONFIG",
      "label": "Config",
      "type": "yaml",
      "description": "YAML defaults for every request. A request may override `confidence_threshold` and `crop_output_to_bbox` per call.\n",
      "required": true,
      "default": "confidence_threshold: 0.5\ncrop_output_to_bbox: true\nimage_cache_size: 8\n",
      "visibleWhen": null
    }
  ],
  "outputs": [
    {
      "key": "DEPLOYMENT",
      "label": "Deployment",
      "type": "deployment",
      "description": "The running SAM3 deployment, set once it answers requests. Wire it into Evaluate interactive instance segmentation to measure it on your own data.\n",
      "artifact": false,
      "badge": false,
      "badgeOpens": null,
      "hidden": false
    }
  ],
  "runtime": {
    "type": "docker",
    "devices": [
      "gpu"
    ],
    "dockerImage": "ovalbee/node-sam3:0.0.17"
  }
}
```

## References

#### Sources and related pages

* [Serve YOLO](/node-library/nodes/models-yolo-serve-yolo)
* [SAM3 repository](https://github.com/facebookresearch/sam3)
* [SAM License](https://github.com/facebookresearch/sam3/blob/11dec2936de97f2857c1f76b66d982d5a001155d/LICENSE)