Nodes/zhangp365/ComfyUI-utils-nodes/Deepface Analyze Face Attributes
ComfyUI Node

Deepface Analyze Face Attributes

Gender, age, race, and emotion detection in ComfyUI

By zhangp365·Created 2 years ago·Updated 5 months ago· 134
Deepface Analyze Face Attributes
  • image
  • gender
  • race
  • emotion
  • age
  • json_info
detector_backendyolov8
analyze_gendertrue
analyze_racetrue
analyze_emotiontrue
analyze_agetrue
standard_single_face_imagefalse

This node wraps deepface, a well-established open-source face-analysis library, into ComfyUI. Point it at an image and it hands back gender, race, emotion, and age as plain strings - genuinely useful as a routing signal for auto-prompting pipelines, dataset labeling, or feeding a downstream node like this pack's own ModifyTextGender. It's also the single heaviest-dependency node in the entire pack, and the author is upfront about that: it is not installed by default.

Read this before you install it

Straight from the README, twice, in almost identical wording: the face-detection dependency chain here needs TensorFlow 2.17, which is now outdated and can conflict with other packages, so it's deliberately excluded from automatic installation. If you want this node, you install its dependencies manually from the pack's requirements.txt - and if you don't want it, the same README warns you to make sure those requirements stay out of your environment, because installing them pulls in TensorFlow 2.17.x whether you use the node or not. Users who already had the old dependency installed before this changed aren't affected either way. If you hit ValueError: The layer sequential has never been called and thus has no defined input after installing, the fix is setting the environment variable TF_USE_LEGACY_KERAS=1 and restarting ComfyUI.

What it analyzes and how

  • image - required.
  • detector_backend - which face-detection algorithm finds the face before analysis runs: opencv, ssd, dlib, mtcnn, retinaface, mediapipe, yolov8 (the default), yunet, or fastmtcnn. These trade off speed against accuracy differently - opencv is fast and crude, retinaface/mtcnn/yolov8 are slower and more reliable, mediapipe and yunet sit in between. If detection is missing faces it should catch, trying a different backend before assuming your image is the problem is worth the two-second swap.
  • analyze_gender, analyze_race, analyze_emotion, analyze_age - each independently toggleable, all default true. Turn off whatever you don't need to save a little processing.
  • standard_single_face_image - if you already know your input is a clean, standard single-face crop, this skips the face-detection step entirely and analyzes attributes directly, which is both faster and avoids a detection miss on an image where detection shouldn't even be necessary.

The node analyzes only the largest face in the image, and processes one image at a time - not a batch. Outputs: gender, race, emotion, age (each a STRING), plus json_info bundling the full result for anything downstream that wants to parse more than the headline values.

Installing it

Base pack, via ComfyUI Manager (search "ComfyUI-utils-nodes") or:

cd ComfyUI/custom_nodes
git clone https://github.com/zhangp365/ComfyUI-utils-nodes

Then, deliberately, a second step for this node specifically: install the extra dependencies from the pack's requirements.txt by hand. Restart ComfyUI after.

What to expect on first run

The first time you actually use this node, deepface downloads its underlying models - budget some time for that on the first run, it's not instant. After that it's fast on subsequent calls. If you skipped the manual dependency install, the node either won't appear in the list or will error immediately on use - that's expected, not a bug, per the author's own default-off design.

Categoryutils/face

Inputs (7)

NameTypeDefaultDescription
imageIMAGE
detector_backendCOMBOyolov89 options: opencv, ssd, dlib, mtcnn, retinaface, mediapipe, +3
analyze_genderoptBOOLEANtrue
analyze_raceoptBOOLEANtrue
analyze_emotionoptBOOLEANtrue
analyze_ageoptBOOLEANtrue
standard_single_face_imageoptBOOLEANfalse

Outputs (5)

NameTypeDescription
genderSTRING
raceSTRING
emotionSTRING
ageSTRING
json_infoSTRING