Nodes/comfyui_facetools/Gender Face Filter
ComfyUI Node

Gender Face Filter

Split a batch of faces by a classifier, with the author's own caveat

By dchatel·Created 2 years ago·Updated 11 months ago· 183
Gender Face Filter
  • faces
  • filtered
  • rest
gender

Some nodes exist to give you control over a batch. Gender Face Filter is one of them: feed it the FACE list from DetectFaces, pick man or woman, and it splits the batch into two outputs - filtered (the faces the classifier put in your chosen bucket) and rest (everyone else). If you're batch-processing group shots and only want to detail the faces matching a category, that's the whole job, and it's a clean fit in the detect-crop-warp pipeline: DetectFaces → GenderFaceFilter → send filtered to CropFaces, ignore or separately handle rest.

How it works

Under the hood it's not doing anything clever. Each face is cropped and resized to 224x224, then run through a Hugging Face image-classification pipeline using the dima806/man_woman_face_image_detection model - a lightweight CNN trained for exactly this one binary. The model downloads automatically on first run and caches. Each face gets a per-class score; the argmax decides the bucket.

Two things you should know before relying on it, and both come from the source:

  • It needs a CUDA GPU. The pipeline is constructed with device=0 hardcoded. No GPU, no node - it fails rather than falling back to CPU.
  • It's a first-run surprise. The first time you execute it, ComfyUI will hang for a bit downloading the model from Hugging Face. That's normal; it's cached afterward.

The author's own warning

The README says it outright: this node "needs more work, as InsightFace gender classifier isn't very accurate." That line predates the current model (the code has since moved to the dima806 classifier, and there was a 2024-05 update to the node), but the spirit stands - a single binary gender label from a small CNN is not a precise instrument. Profile pictures, heavy makeup, unusual angles, and ambiguous subjects will get misbucketed, and there's no confidence threshold input to make it stricter. It's a batch-sorting convenience, not a demographic analysis tool. If a misclassified face messes up your output, this node is the prime suspect.

The inputs that matter

There's exactly one decision to make: the gender enum (man or woman). The faces input is your FACE list from DetectFaces. Outputs are filtered and rest, both FACE types, so either can be piped straight into CropFaces - and because rest is kept separate rather than dropped, you can send both branches down different paths instead of losing the non-matching faces entirely.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/dchatel/comfyui_facetools

or ComfyUI Manager → search facetools → restart. Needs transformers (and a working PyTorch/CUDA install) in your ComfyUI environment; the pack has no requirements.txt, so install it manually if a ModuleNotFoundError appears. No model files to place by hand - the classifier comes from Hugging Face on first run.

Worth it? For the niche of "automatically route faces by gender into separate refine passes," it's the only node in this pack that does it. Just don't expect the classifier to be the smart part of your workflow - it's the convenient part, and it's happy to be wrong.

Categoryfacetools

Inputs (2)

NameTypeDefaultDescription
facesFACE
genderCOMBO2 options: man, woman

Outputs (2)

NameTypeDescription
filteredFACE
restFACE