DP Gender Age Detector
Reads gender and age off your input photo, so the prompt builder can match it
- image
- gender
- gender_confidence
- age
- age_confidence
- age_category
- debug_info
The face-swap workflow that this pack is built around has a wrinkle: the subject is the person in your photo, so the prompt has to describe them back - their gender, their rough age - before the styler can build a costume around them. That's this node's whole job. You feed it your input image and it looks at the face and tells you what it sees, using real Hugging Face classification models rather than any kind of guesswork.
It's the input half of the pipeline (its sibling DP_Dynamic_Random_Styler is the output half), and it's genuinely useful beyond this pack: any workflow where you want the prompt to adapt to the person in the image can use it.
How it works
The node converts your image tensor to PIL, then runs two Hugging Face classifiers from the transformers library - one for gender, one for age. You pick which from the dropdowns:
- gender_model:
rizvandwiki/gender-classification-2,prithivMLmods/Realistic-Gender-Classification,dima806/man_woman_face_image_detection, or Manual gender model - age_model:
nateraw/vit-age-classifier,dima806/faces_age_detection, or Manual age model
The "Manual" options let you type any HF model id into manual_gender_model / manual_age_model instead of picking from the list, which is handy when you've found a classifier you like better. First run downloads the models from the Hugging Face hub - that's a few hundred MB and needs internet, and it's the one thing that can trip people up on a fresh install. The models are cached per node instance and moved to GPU if you have one, so subsequent runs are fast.
The two other inputs that matter:
- confidence_threshold (default 0.7) - if the model's confidence for either prediction drops below this, the node returns
"uncertain"instead of a guess. Good for not feeding garbage into the rest of the graph. - age_format -
range(e.g. "20-29"),single_value(the midpoint, e.g. "25"), orcategory(the raw label). Pick the one that matches what you want downstream.
Outputs and the wiring trap
You get six outputs: gender, gender_confidence, age, age_confidence, age_category, and debug_info (a string logging exactly which models ran and their confidence scores - useful when results look wrong).
Here's the trap, and the README glosses over it: all of these come out as strings. The styler node takes a plain integer age and an enum gender_selection - so you can't wire age straight into the styler's age port; the types don't match. The realistic path is to read the detector's output and set the styler's age/gender yourself, or route the strings into your prompt as literal text (the age_category string slots nicely into a {age_category}-style template if you're hand-building prompts). Don't expect a magic 1:1 wire between these two nodes.
Install
Same pack as the rest: in ComfyUI Manager, search "ComfyUI DP Dynamic Random Styler", or:
cd ComfyUI/custom_nodes
git clone https://github.com/DesertPixelAi/comfyui-dp-them-styler
then restart. The requirements (transformers>=4.30, torch, Pillow, numpy) are the heavy lift here - if you hit a "transformers not available" error, it's the one dependency this pack actually can't live without. And a heads-up that applies to this whole pack: there's no meaningful community footprint behind it, so don't expect a lot of troubleshooting help online. If a model fails to load, the node returns "error" outputs and puts the real reason in debug_info - check that string before anything else.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| gender_model | COMBO | 4 options: rizvandwiki/gender-classification-2, prithivMLmods/Realistic-Gender-Classification, dima806/man_woman_face_image_detection, Manual gender model | |
| age_model | COMBO | 3 options: nateraw/vit-age-classifier, dima806/faces_age_detection, Manual age model | |
| confidence_threshold | FLOAT | 0.700–1 | — |
| age_format | COMBO | 3 options: range, single_value, category | |
| manual_gender_modelopt | STRING | — | |
| manual_age_modelopt | STRING | — |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| gender | STRING | — |
| gender_confidence | FLOAT | — |
| age | STRING | — |
| age_confidence | FLOAT | — |
| age_category | STRING | — |
| debug_info | STRING | — |