Nodes/ComfyUI_photomakerV2_native/PhotoMaker Encode V2
ComfyUI Node

PhotoMaker Encode V2

The trigger word has to be in the first 77 tokens — or PhotoMaker V2 silently does nothing

By zhangp365·Created 2 years ago·Updated 9 months ago· 13
PhotoMaker Encode V2
  • photomakerv2
  • image
  • clip
  • merged conditioning
  • text only conditioning
textphotograph of photomaker

PhotoMakerEncodeV2 is the node that actually makes a face appear in your image. Give it your reference photos, your CLIP model, and a prompt containing the magic word photomaker, and it returns the conditioning that drives the whole generation. It's also the node where nearly every PhotoMaker V2 workflow dies - usually because the trigger word is missing, in the wrong place, or the face detector found no face. Worth understanding, because when it fails it fails quietly.

How it works: stacking faces into the prompt

PhotoMaker's trick is different from IP-Adapter (decoupled cross-attention) or InstantID/PuLID (ControlNet-style adapters). Instead, it replaces tokens in your prompt with identity embeddings. The Encode node finds the photomaker token in your text and duplicates it once per reference image, per token slot - with num_tokens = 2, two reference images means the token becomes four. Then it runs each reference through InsightFace's ArcFace detector to get a 512-dim identity embedding, runs the images through CLIP vision, and a QFormer fuses those into per-image identity tokens. The fuse module overwrites the duplicated photomaker class tokens in your encoded prompt with those embeddings. Result: the word "photomaker" in your prompt is literally a placeholder where the face gets stamped in.

That's why the example workflows are SDXL (V2 was trained for SDXL), and why the README is emphatic that the trigger word here is photomaker, not img - the original repo's token is different.

The inputs that matter

Four required inputs, and only one of them has a trick to it:

  • photomakerv2 - the PHOTOMAKERV2 output from PhotoMakerLoaderV2. Wire it or nothing happens.
  • image - one or more reference images. Multiple images in a batch means one face per image, so more references = more identity slots. This is the "stacking" feature.
  • clip - the CLIP from your CheckpointLoaderSimple. SDXL checkpoint, remember.
  • text - your prompt, multiline, and it must contain the word photomaker somewhere (default is photograph of photomaker). This is the one beginners botch.

Outputs:

  • merged conditioning - your prompt with the face injected. This is your positive conditioning.
  • text only conditioning - the same prompt with no identity. Used in two-stage workflows: the author's workflow_style.json runs a KSamplerAdvanced pass with text-only first, then refines with the merged one - denoise the composition, then lock the face in. For a simple one-pass setup, feed merged to KSampler positive and ignore the second output.

Where people get burned

  • No photomaker in the prompt. If the token is missing, index = -1, the identity branch is skipped entirely, and the "merged" output is identical to text-only. Your workflow runs, nothing crashes, and you get a face-free image. The most silent failure in the pack.
  • Token too late in the prompt. The code logs a warning with an alarm for good reason: "It's will failure when index >= 77." The token has to land inside the first 77 tokens of the sequence. Put it early - near the start, not buried in a long style preamble.
  • No face detected. InsightFace raises ValueError: No face detected in input image pool if a reference photo doesn't contain a detectable face. Blurry, tiny, or heavily angled faces get rejected - crop to the face.
  • CUDA only. The face detector is hardcoded to CUDAExecutionProvider with no CPU fallback. On an AMD or Apple Silicon machine the Encode node won't even initialize its detector.

Install, in one breath

git clone https://github.com/zhangp365/ComfyUI_photomakerV2_native into custom_nodes (or search the pack title in ComfyUI Manager), then pip install -r requirements.txt - which is insightface==0.7.3, the usual dependency pain point. Download photomaker-v2.bin from TencentARC's PhotoMaker-V2 repo into ComfyUI/models/photomaker, use an SDXL base like realvisxlV40_v40Bakedvae, restart, and the InsightFace models fetch themselves on first run.

One fair warning: V2 is an SDXL-era tool, and the community's verdict by now is that PuLID beats it on photorealistic likeness while V2 shines more at prompt-following and style. It's a fun, historically important face-consistency setup - just know what you're signing up for, and put that trigger word in the first 77 tokens.

Categoryphotomakerv2

Inputs (4)

NameTypeDefaultDescription
photomakerv2PHOTOMAKERV2
imageIMAGE
clipCLIP
textSTRINGphotograph of photomaker

Outputs (2)

NameTypeDescription
merged conditioningCONDITIONING
text only conditioningCONDITIONING