BD Flame Fit
Fit a real FLAME head model to your landmarks instead of warping a neutral mesh
- landmarks_batch
- face_fit
- status
If you've ever tried to build a 3D face from a 2D image, you know the two paths: deform a generic neutral mesh to roughly match the landmarks, or fit a morphable model. BD_FlameFit is firmly the second kind. It fits the FLAME head model - the standard parametric face model used across research and game pipelines - to a batch of MediaPipe face landmarks, and emits a BD_FACE_FIT that's a drop-in alternative to the pack's BD_FaceFit.
Why bother? FLAME's shape and expression basis only spans real face shapes, so a fit gives you a subject-accurate head - not a warped balloon. And it's a full head: face, scalp, and neck, which matters when you're building a character mesh rather than a face patch.
How it works
Per view in your landmarks batch, the node runs an Adam optimization that fits FLAME's shape coefficients, expression coefficients, and pose, plus a weak-perspective camera, to the 105 MediaPipe landmarks using the official mediapipe_landmark_embedding. So each input view gets its own optimized head pose and expression, driven by the landmark data you collected with BD_FaceLandmarks.
Two files have to exist or it errors immediately:
flame2023_facewrap.npz- the converted FLAME model. There's a conversion script in the pack'stools/convert_flame.pythat produces it.mediapipe_landmark_embedding.npz- the official landmark embedding.
Both default to /tmp/ComfyUI/models/flame/ but you can point at your own via flame_npz_path and embedding_npz_path. This is the main setup hurdle - the node does the fitting, but you have to convert and place the model first.
The inputs that matter
- landmarks_batch - required; the output of
BD_FaceLandmarks. - shape_coeffs (default 100, up to 300) - how many FLAME shape basis components to fit. More = finer identity, slower, more overfit risk. Start at 100.
- expr_coeffs (default 50) - expression components. Lower if expressions come out exaggerated.
- iterations (default 300, up to 2000) - Adam steps per view. Bump toward 1000+ for a clean fit on a difficult or high-res reference; drop to ~100 for a quick preview pass.
Output is face_fit (the BD_FACE_FIT struct) plus a status string.
The honest workflow note
This is a FaceWrap-pipeline node, and the FaceWrap stuff is aimed at a specific job: turning a 2D character into a UV-ready, animation-friendly head, with MediaPipe landmarks driving SAM3-guided masks. If that's your goal, the fit quality here is genuinely better than the warp approach. If you just want a 3D face and don't need animation-ready topology, a simpler image-to-3D path (say, TRELLIS2) is less fuss - FLAME is a rig-ready head you'll drive with blendshapes, not a display mesh.
Install
Part of the BrainDead pack:
cd ComfyUI/custom_nodes
git clone https://github.com/BizaNator/ComfyUI-BrainDead
cd ComfyUI-BrainDead
pip install -r requirements.txt
Or search "BrainDead" in ComfyUI Manager and restart. Then run the conversion script to produce flame2023_facewrap.npz before wiring the node - that's the step people get stuck on, and the error message tells you exactly which file is missing.
Troubleshooting
- "ERROR: FLAME model not found" - you haven't run
tools/convert_flame.py, or the npz isn't at the default path. Setflame_npz_pathexplicitly. - Faces look generic / samey - raise
shape_coeffsanditerations. - Expressions are wild - lower
expr_coeffs. - Slow - drop
iterationsfor previews, keep quality for the final pass.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| landmarks_batch | BD_LANDMARKS_BATCH | Output of BD_FaceLandmarks. | |
| flame_npz_pathopt | STRING | Path to flame2023_facewrap.npz. Empty = /tmp/ComfyUI/models/flame/flame2023_facewrap.npz | |
| embedding_npz_pathopt | STRING | Path to mediapipe_landmark_embedding.npz. Empty = /tmp/ComfyUI/models/flame/mediapipe_landmark_embedding.npz | |
| shape_coeffsopt | INT | 10010–300 | Number of FLAME shape basis components to fit. More = finer identity, slower, more overfit risk. |
| expr_coeffsopt | INT | 500–100 | Number of FLAME expression components to fit. |
| iterationsopt | INT | 30050–2000 | Adam iterations per view. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| face_fit | BD_FACE_FIT | — |
| status | STRING | — |