ComfyUI Node
BFS H3 Regional Reference Attention
Routes each reference picture to its own person inside the attention, without masks: the guide's colored face contours seed each person, the model's own features follow them through the video, and a soft bias makes person j read Picture j (color order) and the background read no picture. Works with H3 video and H3 Image face swap. Recommended: routing soft, strength 4, background 4, bias_layers 'from route layer'. Not compatible with Model Sparse Attention (sol-attn) or other block-sparse / block-replacing attention nodes: they skip this node (a warning is logged). SageAttention and plain SDPA work.
BFS H3 Regional Reference Attention
- model
- positive
- guide
- subject_map
- MODEL
◄isolationpeople►
◄outside_subjectsno picture►
◄dilate1►
◄route_layer12►
◄margin0.05►
◄routingsoft►
◄strength4.0►
◄sharpness0.050►
◄background4.0►
◄trackingpropagate►
◄bias_layersfrom route layer►
◄radius3►
◄bias_start0►
◄bias_end0►
CategoryBFS/MiniMax H3
Inputs (18)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| positive | CONDITIONING | The conditioning with the pictures (to find each picture's vision tokens in the text). | |
| isolation | COMBO | people | pictures only: each person reads only its picture; people still see each other. people: each person is an island: reads its picture, the guide, the background and the text, never another person; the background and unpicked people read only the guide, the background and the text; a person's guide tokens read only that person's picture. people + text: the text rows inside the DiT also stop reading pictures and people. |
| outside_subjects | COMBO | no picture | What the background and unpicked people may read. 'no picture' = no identity can land outside the picked subjects. |
| dilate | INT | 10–8 | Grow every subject by N tokens (32 px each). |
| guideopt | IMAGE | Attention tracking (no masks): the marked guide (Video Segment Picker `hybrid` output in 'Multi Face Swap — Sparse Face Contour' mode). The contours seed each person; the model's own attention finds that person in every frame. | |
| subject_mapopt | IMAGE | Mask mode instead: BFS Video Segment Picker `subject_map` (each subject's mask in its color). | |
| route_layeropt | INT | 121–49 | Attention tracking: DiT layer whose queries/keys find the people (mid layers are the most semantic). |
| marginopt | FLOAT | 0.050–0.5 | Attention tracking, hard routing: how clearly a token must match a person over the background and the other people. |
| routingopt | COMBO | soft | Attention tracking. soft: nothing is blocked, the attention is only biased: a token pays more attention to the picture of the person it looks like (the model's own affinity) and less to the others. hard: blocked. |
| strengthopt | FLOAT | 4.00–20 | Soft routing: logit bias (4 = about 55x more attention to the right picture than to a wrong one). |
| sharpnessopt | FLOAT | 0.0500.005–1 | Soft routing: temperature of the person affinity (lower = closer to all-or-nothing). |
| backgroundopt | FLOAT | 4.00–20 | Soft routing: logit push away from every picture for tokens that are no tracked person (0 = neutral). |
| trackingopt | COMBO | propagate | propagate: each person is followed frame to frame from the marked frames. propagate + match: what the frame-to-frame step cannot reach (fast motion, camera cuts) is matched to the most similar marked tokens of the whole clip. |
| bias_layersopt | COMBO | from route layer | Which DiT layers get the bias: all, or only the tracking layer and the ones after it (what an attention-trained LoRA saw). |
| radiusopt | INT | 31–12 | Attention tracking: how far (in 32 px tokens) a person may move between two latent frames (4 video frames). |
| bias_startopt | INT | 00–49 | First block that gets the bias (0 = as bias_layers says). The tracking still runs at route_layer. 24 keeps the quality of the full range in tests (the face identity is decided from about block 24) and runs about 30% faster. |
| bias_endopt | INT | 00–49 | Last block that gets the bias (0 = the last block). Fewer biased blocks keep more of the fast attention backend. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |