Moondream 3 Preview SVG Segment (Image / Video)
Moondream 3 Preview's SVG segmentation, converted into real masks
- model
- image
- points
- detections
- segments
- segments_json
- native_svg_paths
- combined_masks
- black_white_masks
- cutouts
- overlays
- bounding_boxes
- bounding_boxes_with_metadata
- performance_json
This is the node that made people pay attention to Moondream 3 Preview. The model has a segment skill that returns geometry as native SVG paths - smooth vector shapes, not chunky box masks - and most wrappers just hand you that SVG string and call it a day. This node does the extra work: it keeps the SVG geometry and converts it into antialiased MASKs, black-and-white previews, foreground cutouts, overlays, polygons, the pack's VLM_DETECTIONS records, and core Comfy bounding boxes. You get the fancy native format and the ordinary Comfy types you can actually composite with.
The one gotcha up front: use the moondream3-preview model, not the 3.1 default. The final 3.1 model card doesn't ship the segment skill, so the Loader's model_or_adapter is where you make that choice. Set it to moondream3-preview and accept the license; everything else flows from there.
Mechanics: feed it a model handle, an image (or video batch), and an object description ("foreground object" by default - be specific: "the person", "the car", "the vase on the table"). For video it uses the same frame_stride / parallel_requests / fps machinery as the detect and point nodes, with a default parallel_requests of 2 since segmentation is heavier per frame. svg_supersample (default 4) controls how smoothly the SVG path is rasterized into a mask - higher values give cleaner edges at some cost. And there's an extra input worth knowing: spatial_refs_json takes normalized [x,y] points and/or [x1,y1,x2,y2] boxes that guide the segmentation - a "segment around this region" steering input that the points and detections optional sockets can also provide.
Outputs, in order: segments (VLM_DETECTIONS with per-object polygons), segments_json, native_svg_paths (the original SVG geometry, preserved), combined_masks (one antialiased MASK), black_white_masks (ready-to-preview images), cutouts (the foreground extracted), overlays (masks drawn on the source), bounding_boxes, bounding_boxes_with_metadata, and performance_json. That's everything you need for inpainting, background replacement, or feeding a segmentation-based workflow without any SVG-to-mask glue of your own.
Installing it
Standard pack install (ComfyUI Manager → "ComfyUI VLM nodes", or clone + requirements.txt), then the isolated Moondream runtime:
runtime="ComfyUI/models/LLavacheckpoints/moondream31-runtime"
uv venv "$runtime/.venv" --python 3.12
uv pip install --python "$runtime/.venv/bin/python" \
-r ComfyUI/custom_nodes/ComfyUI_VLM_nodes/requirements-moondream31.txt
Accept the license on the loader and pick moondream3-preview in model_or_adapter. NVIDIA Ampere-or-newer or Apple Silicon for local Photon.
Common issues
- Empty mask or weird result → you're almost certainly on the wrong model. Switch the loader to
moondream3-preview. - Jagged edges → raise
svg_supersample(up to 8). The tradeoff is speed, not quality. - Segments the wrong object → use
spatial_refs_json(or thepoints/detectionssockets) to steer it, and make theobjectdescription specific. - Video is slow → drop
parallel_requeststo 1 if you're VRAM-constrained, or raiseframe_stride- segmentation per frame is the expensive path, so only segment the frames you actually need.
The cutout output alone justifies this node for compositing work - being able to grab a vector-edged foreground mask out of a free, local model is a trick most packs make you buy a SAM or cloud API for.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MOONDREAM31_MODEL | — | |
| image | IMAGE | — | |
| object | STRING | foreground object | — |
| fps | FLOAT | 30.0000.001–1000 | — |
| frame_stride | INT | 11–100000 | — |
| parallel_requests | INT | 21–32 | — |
| svg_supersample | INT | 41–8 | Higher values produce smoother mask edges. |
| unload_after | BOOLEAN | false | — |
| spatial_refs_jsonopt | STRING | [] | Normalized [x,y] points and/or [x1,y1,x2,y2] boxes. |
| pointsopt | VLM_POINTS | — | |
| detectionsopt | VLM_DETECTIONS | — |
Outputs (10)
| Name | Type | Description |
|---|---|---|
| segments | VLM_DETECTIONS | — |
| segments_json | STRING | — |
| native_svg_paths | STRING | — |
| combined_masks | MASK | — |
| black_white_masks | IMAGE | — |
| cutouts | IMAGE | — |
| overlays | IMAGE | — |
| bounding_boxes | BOUNDING_BOX | — |
| bounding_boxes_with_metadata | BOUNDING_BOXES | — |
| performance_json | STRING | — |