Nodes/VLM_nodes/Moondream 3 Preview SVG Segment (Image / Video)
ComfyUI Node Runs on cloud

Moondream 3 Preview SVG Segment (Image / Video)

Moondream 3 Preview's SVG segmentation, converted into real masks

By gokayfem·Created 3 years ago·Updated 9 days ago· 583
Moondream 3 Preview SVG Segment (Image / Video)
  • 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
objectforeground object
fps30.000
frame_stride1
parallel_requests2
svg_supersample4
unload_afterfalse
spatial_refs_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 the points/detections sockets) to steer it, and make the object description specific.
  • Video is slow → drop parallel_requests to 1 if you're VRAM-constrained, or raise frame_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.

CategoryVLM Nodes/Moondream 3

Inputs (11)

NameTypeDefaultDescription
modelMOONDREAM31_MODEL
imageIMAGE
objectSTRINGforeground object
fpsFLOAT30.0000.001–1000
frame_strideINT11–100000
parallel_requestsINT21–32
svg_supersampleINT41–8Higher values produce smoother mask edges.
unload_afterBOOLEANfalse
spatial_refs_jsonoptSTRING[]Normalized [x,y] points and/or [x1,y1,x2,y2] boxes.
pointsoptVLM_POINTS
detectionsoptVLM_DETECTIONS

Outputs (10)

NameTypeDescription
segmentsVLM_DETECTIONS
segments_jsonSTRING
native_svg_pathsSTRING
combined_masksMASK
black_white_masksIMAGE
cutoutsIMAGE
overlaysIMAGE
bounding_boxesBOUNDING_BOX
bounding_boxes_with_metadataBOUNDING_BOXES
performance_jsonSTRING