> 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 ClickSEG

> Loads a ClickSEG model once and keeps answering click-to-segment requests until the deployment is stopped. It powers the Smart Tool in the labeling tool. Holds its worker for its whole lifetime.

Runs on: gpu, cpu  Dockerfile

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

## Overview

Segments objects from clicks with ClickSEG, 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. Click on an object, add a few more clicks to correct what comes back, and a mask is returned each time. Every running ClickSEG deployment in the workspace shows up in the Smart Tool model list.

ClickSEG models are small - the lightest is 7.5 MB - so this is the deployment to reach for when a GPU is scarce or a click has to come back instantly. The trade-off is that it segments only what you click on, with no box-only and no text prompting.

## Prerequisites

| Requirement                 | What you need                                                                                                                                 |
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| **A worker**                | A GPU keeps a click well under a second. ClickSEG also answers on a CPU, unlike the SAM deployments.                                          |
| **Images in the workspace** | The images to segment, already uploaded. Calls name images by asset id.                                                                       |
| **Model**                   | One of the ten pretrained ClickSEG models copied from the catalog, or weights of your own whose version names one of those ten architectures. |
| **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 - a catalog model's from the ClickSEG authors, checked against a pinned SHA-256 - and loads them onto the device once at startup, under the predictor their architecture belongs to.

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

Downloads the image a call names and keeps it, so every later click on that image skips the download.

Crops the image to the box, if a call sends one, and moves the clicks into that crop.

Runs the model over the whole click list at once and keeps the pixels whose probability clears the threshold.

Answers with the mask, or with an empty mask when no pixel clears the threshold.

## 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 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. `/encode_image` downloads an image ahead of the first click, `DELETE /images` drops an image from memory, and `/info` reports which weights are loaded and under which predictor.

#### How is this different from the SAM deployments?

Two things. ClickSEG needs at least one click - it has no box-only mode and no text prompting, where SAM segments from a box alone. And the box means something different: SAM looks at the whole image and treats the box as a hint, while ClickSEG only ever sees the crop, so drawing a box changes what the model is looking at. In exchange ClickSEG is far smaller and runs on a CPU.

#### Which pretrained model should I pick?

The catalog lists ten, in three families. **FocalClick** is the most accurate, and its SegFormerB0-S1 is the one to try if clicks feel slow, but its four SegFormer models are licensed for non-commercial use only (research or evaluation). **Baseline** MobileNetV2 and PPLCNet are the smallest, for a CPU deployment or a crowded GPU. **CDNet** ResNet34 is the oldest of the three. Within a family, the checkpoint marked "combined" saw the widest mix of training data and usually generalises best, but that mix includes [ThinObject-5K](https://github.com/liewjunhao/thin-object-selection), which is CC BY-NC 4.0, so the combined models are non-commercial too. The mix also includes [ADE20K](https://ade20k.csail.mit.edu/terms/) and [YouTube-VOS](https://youtube-vos.org/dataset/term/), whose terms restrict their data to research; all three are quoted in [`DATASET_TERMS.md`](https://github.com/oval-bee/ovalbee/blob/main/nodes/templates/models/clickseg/serve_clickseg/v1/DATASET_TERMS.md), and it is your responsibility to determine whether you have permission to use a model for your use case. The image does not carry the six non-commercial models: a deployment downloads one from the ClickSEG authors the first time it loads it and logs its terms. Copy the one you want into your workspace from the model catalog, then select it in **Model**.

#### What goes into a segment request?

An image asset id and at least one click, optionally with a box. Positive clicks mark the object and negative clicks mark what isn't part of it. Clicks are in image pixels, and box corners are inclusive. A request with no clicks is rejected.

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

Either no pixel's probability cleared `probability_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 `score` beside it is the mean probability the model gave the pixels it kept, since ClickSEG reports no quality figure of its own.

#### Does each new click refine the last mask?

In effect, yes, but nothing is stored between calls. The Smart Tool resends the full click list every time, and the model reads all of them at once, so the mask that comes back accounts for every click you have placed. That also means a call is reproducible: the same clicks always give the same mask.

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

Yes, when its model version names which of the ten catalog architectures it was trained with, such as `resnet34_1`: a checkpoint does not say which of ClickSEG's three predictors drives it, and running it under the wrong one returns nonsense rather than failing, so a version that names none is refused. The network is built from that name, never from what the file says about itself. With the safe-weights policy on, only safetensors weights load; a `.pth` has to be converted first.

#### What do the settings in Config change?

`probability_threshold` is the only one a request may override, and it decides which pixels of the probability map end up in the mask. `inference_resolution`, `focus_crop_r`, `target_crop_r` and `refine_mode` are built into the model when it loads and are fixed for the life of the deployment. `image_cache_size` is how many downloaded images stay in memory.

## Inputs

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

ClickSEG weights the deployment loads and keeps in memory: one of the ten pretrained models from the catalog, downloaded from the ClickSEG authors when the deployment starts, or weights of your own for one of those ten architectures - the version has to name which, since a checkpoint does not say which of ClickSEG's three predictors drives it. Six are non-commercial - the four FocalClick SegFormer models and the two Baseline models trained on the combined dataset. With the safe-weights policy on, only safetensors load. Key: `MODEL`.

---

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

YAML defaults for every request. A request may override `probability_threshold` per call. Key: `CONFIG`.

---

## Outputs

**`Deployment`** `deployment`

The running ClickSEG 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. A catalog model's weights are downloaded from the ClickSEG authors when the deployment starts, through the workspace's model cache when the worker has one. It holds its worker 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 ClickSEG",
  "description": "Loads a ClickSEG model once and keeps answering click-to-segment requests until the deployment is stopped. It powers the Smart Tool in the labeling tool. Holds its worker for its whole lifetime.\n",
  "category": "Models",
  "namespace": "ovalbee",
  "templateKey": "models/clickseg/serve_clickseg",
  "version": "v1",
  "inputs": [
    {
      "key": "MODEL",
      "label": "Model",
      "type": "model",
      "description": "ClickSEG weights the deployment loads and keeps in memory: one of the ten pretrained models from the catalog, downloaded from the ClickSEG authors when the deployment starts, or weights of your own for one of those ten architectures - the version has to name which, since a checkpoint does not say which of ClickSEG's three predictors drives it. Six are non-commercial - the four FocalClick SegFormer models and the two Baseline models trained on the combined dataset. With the safe-weights policy on, only safetensors load.\n",
      "required": true,
      "default": null,
      "visibleWhen": null,
      "options": {
        "framework": "clickseg",
        "task_type": "instance_segmentation"
      }
    },
    {
      "key": "CONFIG",
      "label": "Config",
      "type": "yaml",
      "description": "YAML defaults for every request. A request may override `probability_threshold` per call.\n",
      "required": true,
      "default": "probability_threshold: 0.5\ninference_resolution: 384\nfocus_crop_r: 1.4\ntarget_crop_r: 1.4\nrefine_mode: true\nimage_cache_size: 8\n",
      "visibleWhen": null
    }
  ],
  "outputs": [
    {
      "key": "DEPLOYMENT",
      "label": "Deployment",
      "type": "deployment",
      "description": "The running ClickSEG 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",
      "cpu"
    ],
    "dockerImage": "ovalbee/node-clickseg:0.0.11"
  }
}
```