SMP · SAM3 Class Router (legacy)
SAM3 class name in, regional prompt out
- structured
- prompt_fragment
This is the smallest node in the SMP suite and arguably the cleverest idea in it. The Structured Prompt Assembler hands you four regional prompt strings - face, body, outfit, location - bundled as STRUCTURED_PROMPTS. The SAM Class Router is how you spend them region by region: give it a SAM3 mask class name like upper_clothes, and it returns the matching prompt fragment.
Why that matters: a PersonDetailer workflow doesn't feed the whole scene sentence to a face inpaint - it feeds the region-specific one. When SAM3 segments a torso as upper_clothes, you want the upper-body garment fragment, not the full outfit paragraph. This node is the lookup table that makes that connection, and it does it without touching the Detailer's code. The pattern the brief describes is the canonical use: SAM3 emits upper_clothes → this node returns the upper-body fragment → straight into a PersonDetailer per-slot prompt input.
How it works
It looks up the class name in the structured bundle's prebuilt sam_class_lookup. If the bundle came in partial (no lookup attached), it re-derives the lookup on the fly from the raw dict inside the bundle. Unknown class names fall back to the fallback string (empty by default), so you get a clean empty slot instead of an error mid-graph.
The inputs that matter
structured- theSTRUCTURED_PROMPTSoutput from SMP · Structured Prompt Assembler.class_name- a SAM3 vocabulary term; default isupper_clothes.fallback(optional) - what to emit when the class isn't found.
Outputs
prompt_fragment- a single STRING, wired into a detailer slot's prompt input. One router per slot you want to populate.
Install
Nothing extra. Base pack install, no models, no pip beyond the venv's existing numpy and pydantic 2:
cd ComfyUI/custom_nodes
git clone https://github.com/ping1979ping/comfyui-FVMtools
Restart and you're done.
Where the class names come from
SAM3's vocabulary is broader than you might expect. The pack's own SAM3 selector exposes aux presets like upper_body, lower_body, clothing, hands, feet, and headless_body - all of which are SAM3-groundable concepts, and all of which map to fragments in the structured bundle. So the router's class name doesn't have to come from a fixed list; if your SAM3 masks are text-grounded, the class name is just the noun phrase you grounded them with. That's what makes the node a general bridge rather than a lookup table for three hardcoded labels.
Common issues
Empty fragment almost always means one of two things: you typo'd the class name, or the class genuinely isn't in the lookup. Check the Assembler's region_map output to see which classes actually exist for your outfit/location. And remember the vocabulary is SAM3's - face, upper_clothes, skirt, shoes, background - not free text. Type "torso" and you'll get the fallback, silently.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| structured | STRUCTURED_PROMPTS | — | |
| class_name | STRING | upper_clothes | — |
| fallbackopt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| prompt_fragment | STRING | — |