Concept-prompted open-vocabulary segmentation on an Image. Each noun phrase, or each class of example boxes drawn on one reference picture, is segmented and the sink resolves the projection: mask-plus-box pairs, masks, boxes, parallel arrays, a merged Mask, a UInt64 count, or a colourised label Image.
Typical backends
Segment a named concept and track the instances across frames.
Segment a concept and crop each instance out of the frame.
Caveats
- I/O contractThe output arm is fixed at deploy time and projects one decoded instance list. Arms carrying a mask per instance omit empty masks with their paired boxes or classes; box-only and count arms keep those detections. Parallel lists stay aligned, but counts can differ between arms. The union mask is empty when no pixels survive. The colour image paints each class with a repeating palette; later instances overwrite overlaps. Its signed 64-bit canvas stores class id plus one, so a painted class id above 9223372036854775806 fails that arm. Frame result lists have no worker-imposed cap, so crowded scenes can return many objects.
- Hard constraintOn frames,
prompt must be a non-empty phrase, or a comma-separated list of non-empty phrases, at startup; an empty value fails to start unless exemplars prompts the frames instead. An invalid runtime update is rejected and the previous prompt is kept.
- Hard constraintFrames can instead be searched with boxes drawn on a separate picture: bind one decodable image file at
reference and set exemplars records containing class_id, rectangle and positive. Rectangles use pixel corners on the upright reference picture. With examples set, prompt must be empty or whitespace-only and prompt_to_class_id empty. Startup refuses a missing picture, a slot holding other than one file, a reference without examples, non-finite or empty boxes, boxes outside the picture, or a class with no positive box or more than sixteen boxes. A live phrase update while examples prompt frames is logged and ignored.
- AccuracyAn example is a box, not the object's exact outline: the model reads everything inside the box, background included, so a loose box around an object that does not fill it describes the object less well. How many objects are found, and how many look-alikes come back, depends on how alike the objects on the frames are to the boxed ones; negative boxes tell the model which look-alikes are not the object, and raising
confidence_threshold drops weak matches. Found objects are scored and thresholded like phrase matches, with the class id of their boxes.
- State lifetimeThe picture at
reference is read once at start, with its EXIF orientation applied so its pixels are the upright picture the boxes were drawn on, and encoded once into each class's prompt; its features are then dropped. Changing the picture or the boxes needs a redeploy. Frames are used as they arrive, with no orientation applied.
- LatencyEach class of example boxes runs the detection and mask heads once per frame on the frame's one encoding, so latency grows with the number of classes, as it does with the number of phrases.
- LatencyMultiple comma-separated phrases in
prompt are segmented one after another, so latency grows with the number of phrases per frame.
- Parameter interaction
prompt_to_class_id supplies phrase class ids. Map keys must exactly match the trimmed phrases; duplicate keys fail startup. An empty map admits one phrase with class id zero. A startup prompt the map cannot cover stops the worker; an invalid runtime update is logged and ignored, keeping the last valid phrase list. The map is fixed at startup, so live changes can select only phrases it already covers, or one arbitrary phrase when it is empty.
- Compatibility
model must contain a local Transformers snapshot compatible with the Sam3Model and Sam3Processor classes: config.json, weights and processor/tokenizer assets. Label assist additionally needs complete compatible Sam3TrackerModel and Sam3TrackerProcessor assets in the same snapshot; missing or mismatched decoder keys fail startup there. Loading is offline; missing or unreadable assets can prevent startup. Weights use half precision on GPU and full precision on CPU. An unavailable CUDA device fails startup; there is no CPU fallback.
- Hard constraintFrame conversion, warm-up and inference faults propagate; a failed frame emits no result. The proposal arm's failed flag is always false on emitted results. Interactive inference exceptions return `inference_failed` and invalidate that session's features; the caller must prepare again. The failure string includes exception types and messages through every cause or context in its chain, each named once. Validation refusals return an error without partial labels. Telemetry exceptions return `telemetry_failed` and clear labels.
- I/O contractLabel assist uses the session request and result records in place of frames. Prepare encodes both concept and click features for one raw RGB picture; predict reuses them with a replacement prompt. Clicks, a box or a mask use two decoder passes: choose the best predicted-IoU candidate, then refine its logits into at most one non-empty mask. A mask alone also supplies its tight box and an interior click. Text and signed example boxes can combine on that same picture and return concept matches. They cannot mix with clicks or a box.
prompt, prompt_to_class_id, exemplars and reference do not prompt these requests.
- I/O contractInteractive callers supply canonical UUID identities, lowercase SHA-256 digests, increasing sequence numbers and unchanged picture/schema bindings per session. The worker checks the raw RGB raster digest; the supplied image-file digest and schema digest are binding values, not independently verified content. Revisions are echoed correlation values. EXIF orientation is binding metadata only: clicks, boxes and masks use the raw raster's pixels. A changed binding needs another session; cancel and close release features but keep ordering metadata until eviction or expiry. Once an existing session's sequence/binding checks pass, later failures still consume that sequence; the next request needs a newer one.
- Hard constraintInteractive pictures allow at most 32768 pixels on either side and 67108864 pixels total. Requests allow 128 clicks, one box, sixteen example boxes with at least one positive, one non-empty mask and 4096 UTF-8 text bytes; whitespace-only text is refused. Predict carries no image; prepare carries exactly one and no prompts; cancel/close carry neither. Class ids are 0–4095; sequence/revision values are 0–9007199254740991, schema versions 1–9007199254740991 and EXIF orientation 1–8. Coordinates must be finite and in bounds; boxes must have area.
- I/O contractInteractive masks use uncompressed column-major alternating background/foreground run lengths starting with background, with height/width matching the prepared picture. Input masks require foreground, at most 1048576 runs and at most 8 MiB serialized size; only the first run may be zero. Results reject more than 65536 candidate objects, more than 1048576 total mask runs or more than 8 MiB of serialized labels. Empty masks produce no label. New objects receive UUIDs; all labels take the request's class. Refining an existing object with text or examples needs its mask and selects the unique positive-overlap candidate; missing or tied overlap is an error. Returned boxes are x, y, width, height from mask extents.
- State lifetimeInteractive features and session metadata live only in this worker process.
cache_max_sessions bounds sessions and cache_max_bytes bounds resident feature tensor storage. Idle expiry uses session_ttl_seconds; a sweeper frees expired features, and requests also expire metadata. Admission evicts least recently used entries; a missing, closed, cancelled, failed or expired session requires preparation again. An oversized feature reservation is refused before encoding; an encoded result exceeding its reservation is refused too. Tenants never share entries.
- CostThe deployment declares 12 GB of shared GPU memory even when
device chooses CPU inference. cache_max_bytes excludes model weights, CPU images and temporary preprocessing/encoder/decoder allocations, so it is not a total memory limit. Large pictures, many phrases/classes and detailed masks add memory or compute cost and can exhaust resources. Label assist loads two decoders and retains both feature families.
- LatencyFrame startup loads weights, optionally encodes
reference, and runs a blank 1008×1008 warm-up before accepting frames. Interactive requests run synchronously under one worker-wide lock, so encoding or prediction queues every other session and the idle sweeper. There are no worker timeouts or retries; startup or inference failures need correction by the caller.
- State lifetimeEvery setting except
prompt is captured once at startup; prompt is re-read on each frame so it can be steered at runtime, while model, device, reference and exemplars need a redeploy to change.