Nodes/ComfyUI Impact Pack/HF Transformers Classifier Provider
ComfyUI Node Runs on cloud

HF Transformers Classifier Provider

Load a HuggingFace classifier for SEGS

By ltdrdata·Created 3 years ago·Updated 4 months ago· 3,242
HF Transformers Classifier Provider
    • TRANSFORMERS_CLASSIFIER
    preset_repo_id
    manual_repo_id
    device_mode

    This node loads an image-classification model from HuggingFace and hands it out as a TRANSFORMERS_CLASSIFIER for the rest of Impact Pack to use. On its own it does nothing visible - it's a loader. Its whole reason to exist is to feed the SEGS Classify node, which uses the classifier to sort detected regions by what's in them: this face is female, that one's over 50, keep these and drop those. If you're building a workflow that needs to decide something about a detected region rather than just detail it, this is where the brain gets loaded.

    The example models the pack ships in the dropdown are all gender/age classifiers, which tells you the intended use: detect faces, then automatically route or filter them by attribute. But manual_repo_id opens it up to any compatible HuggingFace image classifier.

    How it works

    You pick a HuggingFace repo, the node downloads and loads that transformers classification model, and outputs a TRANSFORMERS_CLASSIFIER object. That object plugs into SEGS Classify, which runs the classifier on each detected region's crop and produces label scores you can filter on. The model cache location follows the standard HF_HOME environment variable, so if you're managing where HuggingFace models land, that's the knob.

    The inputs and outputs that matter

    • preset_repo_id - a dropdown of built-in classifier repos (several gender classifiers like rizvandwiki/gender-classification-2, plus a couple of age/gender ones), ending in Manual repo id.
    • manual_repo_id - when the preset is set to Manual repo id, type any HuggingFace classifier repo here. This is how you go beyond the bundled gender/age models.
    • device_mode (AUTO / Prefer GPU / CPU) - where the classifier runs. AUTO is fine for most; force CPU if you're tight on VRAM and don't want the classifier competing with your diffusion model.

    The single output is TRANSFORMERS_CLASSIFIER, which goes straight into a SEGS Classify node.

    How to install it

    Part of the Impact Pack. ComfyUI Manager: search ComfyUI Impact Pack, Install, restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack comfyui-impact-pack
    cd comfyui-impact-pack
    pip install -r requirements.txt
    

    then restart. The classifier weights download from HuggingFace on first use, so the initial run needs a working connection; after that they're cached (under HF_HOME).

    Common issues & troubleshooting

    First run hangs or errors on download. The model is being pulled from HuggingFace. Give it time on the first execution, and make sure the environment can reach huggingface.co. If a repo is gated, you'll need to be authenticated for it.

    Out of memory when it loads alongside your checkpoint. Set device_mode to CPU. These classifiers are tiny compared to a diffusion model, and running them on CPU costs almost nothing in speed while freeing VRAM.

    The labels don't match what you expected. Different classifier repos emit different label sets - one model's "male/female" is another's "Man/Woman." Check the target repo's config.json for its actual labels before you write a filter expression in SEGS Classify, because the expression has to reference the exact label names the model outputs.

    This node alone doesn't filter anything. It only loads the classifier. The actual sorting happens in SEGS Classify, which consumes this output. Wire the two together.

    CategoryImpactPack/HuggingFace

    Inputs (3)

    NameTypeDefaultDescription
    preset_repo_idCOMBO8 options: rizvandwiki/gender-classification-2, NTQAI/pedestrian_gender_recognition, Leilab/gender_class, ProjectPersonal/GenderClassifier, crangana/trained-gender, cledoux42/GenderNew_v002, +2
    manual_repo_idSTRING
    device_modeCOMBO3 options: AUTO, Prefer GPU, CPU

    Outputs (1)

    NameTypeDescription
    TRANSFORMERS_CLASSIFIERTRANSFORMERS_CLASSIFIER