Nodes/ComfyUI-GNM/GNM Identity Sampler
ComfyUI Node

GNM Identity Sampler

GNM Identity Sampler, demystified

By soylab-edu·Created 2 months ago·Updated 2 months ago· 10
GNM Identity Sampler
    • identity
    gender
    ethnicity
    strength1.00
    seed0

    Let's clear up the word "sampler" first, because it's a trap. This is not a diffusion sampler and has nothing to do with KSampler. GNMIdentitySampler samples a parameter vector - a set of numbers that describe a 3D head's shape - from Google's GNM semantic identity model. The output isn't an image; it's a recipe that GNMHeadRender turns into one.

    The inputs are three widgets and a seed:

    • gender - female | male.
    • ethnicity - middle_eastern | asian | white | black.
    • strength (default 1, 0–3) - how strongly the sampled face deviates from the average for that group. 0 gives the mean/template face; 1 is a typical sample; 3 is exaggerated.
    • seed - reproducibility.

    The output is a single identity (GNM_IDENTITY) vector, meant for the identity input on GNMHeadRender, where you'd normally pair it with an expression vector from GNMExpressionSampler for the full face.

    How it works is the interesting part. GNM's identity decoder is a small Keras MLP: it concatenates a random latent z with a one-hot encoding of gender plus ethnicity, pushes that through four dense ReLU layers, and outputs the identity vector. The original Google implementation needs TensorFlow; this pack reimplements the forward pass in pure numpy, reading the same bundled .h5 weights with h5py. The README is explicit that it's verified to produce output identical to tf.keras - same seed, same face - which is why the pack installs without the TF bloat.

    Where people get confused: the same gender and ethnicity with different seeds gives you different people within that demographic, and strength acts like a dial between "generic member of the group" and "distinctive face." Want subtle? Keep strength around 0.6–0.8. Want memorable, characterful faces? Let it ride at 1 and above.

    Install

    ComfyUI Manager is the easy path: Custom Nodes → search "ComfyUI-GNM" → Install, then restart. Or clone by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/soylab-edu/ComfyUI-GNM
    cd ComfyUI-GNM
    pip install -r requirements.txt
    

    The model data ships in vendor/ - no separate download, and no TensorFlow anywhere.

    Common issues

    If you hit an error mentioning h5py, the sampler dependencies aren't in your Python environment - pip install -r requirements.txt inside the pack folder fixes it. And note that if you're using the viewport nodes instead of the wire-together graph, they do identity sampling internally; you only need this standalone node when you're building the render path by hand and want to control who the face is separately from how it's posed.

    CategoryGNM

    Inputs (4)

    NameTypeDefaultDescription
    genderCOMBO2 options: female, male
    ethnicityCOMBO4 options: middle_eastern, asian, white, black
    strengthFLOAT1.000–3
    seedINT00–18446744073709550000

    Outputs (1)

    NameTypeDescription
    identityGNM_IDENTITY