SAM MultiLayer
Click-to-segment your character into rig-ready layers
- image
- SAM_PROMPT
This is the front door of Avatar Graph, avatech.ai's pack for turning a single character illustration into a rigged, interactive avatar without opening Blender by hand. Everything else in the pack - the mesh building, the shape keys, the Shape Flow runtime - starts from what this node produces: a set of segmented regions cut out of your source image, ready to become individual mesh layers (an eye, a mouth, a body outline).
What it's doing under the hood
This wraps Meta's Segment Anything Model - the same SAM the README's own node table describes as an "integrative SAM node allowing you to directly select and create multiple image segment output." In practice, you feed it your character image and then click on it in the node's preview: each click (or box) is a segmentation prompt, and SAM turns it into a mask for that region. Do this once for each eye, once for the mouth, and so on, and you end up with the multiple discrete layers this pack's later nodes need to build separate, independently riggable meshes.
The checkpoint it loads, sam_vit_h_4b8939.pth, is Meta's original ViT-H SAM weights - the largest and slowest of the SAM family, but also the highest quality, and notably not one of the newer, faster variants (FastSAM, SAM 2/3) that have mostly displaced it elsewhere in the ecosystem since. This pack predates those, so ViT-H is what you get, and at roughly 2.4GB it's the single heaviest download in the whole install - plan for it, especially on a slower connection.
Inputs and outputs
image- the character portrait you're segmenting. The README's own advice: use an image at least 768x768 with the mouth open and facial features clearly visible, since the whole rigging pipeline downstream depends on being able to cleanly separate eyes and mouth.ckpt- the SAM checkpoint to load; the schema only listssam_vit_h_4b8939.pth, so there's nothing to choose here beyond confirming the weight file is present.embedding_id(default"embedding") - a name for the cached image embedding. SAM's image encoder is the slow part of the whole process; caching it under this ID means adding more click-prompts to the same image later doesn't force a full re-encode each time.image_prompts_json(default"[]") - the actual click/box prompts, serialized as JSON. In normal use you don't hand-type this; it's built by clicking directly on the node's image preview in the ComfyUI graph, and the pack's frontend fills this field in for you.
Output is a single SAM_PROMPT, which feeds forward into this pack's mesh-building nodes to actually cut each segmented region into its own mesh layer.
Installing it
ComfyUI Manager: search avatar-graph-comfyui. By hand:
cd ComfyUI/custom_nodes
git clone https://github.com/avatechai/avatar-graph-comfyui
cd avatar-graph-comfyui && python -m pip install -r requirements.txt
This node doesn't need bpy the way the pack's mesh-manipulation nodes do, but the pack as a whole is still pinned to Python 3.10.x because of it, so you're still building this in a dedicated 3.10 environment (a conda env on Mac/Linux, or the README's prebuilt Windows Python 3.10 ComfyUI zip) rather than your regular ComfyUI setup. If the sam_vit_h_4b8939.pth checkpoint isn't already present, ComfyUI Manager should offer to fetch it for you; if it doesn't, grab Meta's original ViT-H SAM weights and place them in your SAM models folder manually.
Troubleshooting
The most common friction here isn't the node, it's the input image - low resolution or a closed mouth makes clean segmentation of the mouth region genuinely difficult, which is exactly why the README calls out 768x768-plus with an open mouth as the baseline for good results. If image_prompts_json is empty or malformed, the node has nothing to segment and produces nothing useful downstream - that field should always be populated by clicking in the UI rather than left at its "[]" default. And budget the wait on first run: loading and encoding through ViT-H is noticeably slower than the lighter segmentation models most people are used to.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| ckpt | COMBO | 1 options: sam_vit_h_4b8939.pth | |
| embedding_id | STRING | embedding | — |
| image_prompts_json | STRING | [] | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| SAM_PROMPT | SAM_PROMPT | — |