Nodes/comfyui-ageshift/πŸŽ‚ Age Detector Loader
ComfyUI Node

πŸŽ‚ Age Detector Loader

The Loader That Hauls in the Age-Detection Model (and Why You Wire It Once)

By aadebugerΒ·Created 3 months agoΒ·Updated 3 months agoΒ· 0
πŸŽ‚ Age Detector Loader
    • detector
    β—„model_idnateraw/vit-age-classifierβ–Ί
    β—„deviceautoβ–Ί
    β—„dtypefp32β–Ί
    β—„force_reloadfalseβ–Ί

    AgeDetectorLoader is the unglamorous half of the AgeShift detection pair. It loads a Hugging Face image-classification model, wraps it up in a AGE_DETECTOR bundle, and hands it to the AgeDetect node. You wire this once, forget it exists, and spend the rest of your session fighting with PuLID weights. That's the job, and it's fine.

    By default it pulls nateraw/vit-age-classifier, a ViT fine-tuned for age classification with nine bins running from "0-2" up to "more than 70". The first time you queue, ComfyUI downloads roughly 330MB from the Hugging Face Hub - it's not a model you keep in models/, it lives in your HF cache. No license gymnastics, no manual placement; the from_pretrained call just fetches it and goes.

    How it works

    Under the hood it uses the transformers library's AutoImageProcessor and AutoModelForImageClassification, which is why the pack's dependency list is so short - transformers, pillow, numpy, and nothing else. There's an in-process cache keyed on model_id|device|dtype, so re-queueing the same workflow doesn't re-download or re-instantiate the model every time. That matters: ViT loading takes a few seconds and nobody wants it on every run.

    The IS_CHANGED hook returns the exact input combination, which means ComfyUI only re-executes the loader when you actually change something. Leave it alone and it's a no-op on every queue after the first.

    The inputs that matter

    • model_id - the HF repo id. The default is the one you want; you can point it at any compatible image-classification model, but the midpoints table in the pack is tuned for the default's nine bins, so don't swap casually.
    • device - auto figures out CUDA vs CPU for you. On a machine with one GPU, just leave it.
    • dtype - fp32 default. One honest gotcha buried in the source: if device resolves to CPU, it force-uses fp32 no matter what you pick, because fp16/bf16 on CPU trips over. So don't chase faster CPU inference here.
    • force_reload - a cache-buster. Set it if you changed the model id and want to make sure you're not getting a stale bundle, or if a load got corrupted. Otherwise leave it off; on means reloading on every run.

    Its one output, detector, plugs into the detector input of AgeDetect. That's the entire pipeline on this side of the pack.

    Install

    It's the shared pack install, and it's light:

    cd ComfyUI/custom_nodes
    git clone https://github.com/aadebuger/ComfyUI-AgeShift.git
    cd ComfyUI-AgeShift
    uv pip install -r requirements.txt   # transformers, pillow, numpy
    

    Or just search "ComfyUI-AgeShift" in ComfyUI Manager and let it handle the clone. Restart ComfyUI and the four πŸŽ‚ nodes appear.

    Where people get burned

    The only real failure mode here is network. If the first run hangs, the model is downloading - watch the server log, and if you're behind a proxy or an HF-blocked network, set HF_HOME to a writable cache dir and give it a mirror. The model is ~330MB and it's a one-time cost. If a load ever looks wrong (garbage ages out of nowhere), flip force_reload once and let it rebuild the cache.

    This is also the point worth a second of honesty about the underlying model: nateraw/vit-age-classifier is decent but visibly biased - it tends to underestimate adult ages, and accuracy falls off on stylized or blurry inputs. That's a property of the classifier, not the loader, so don't blame this node when AgeDetect tells you a 40-year-old is 28. The pack is obscure and young, so there's no army of community reports behind it yet - but that model's reputation is real.

    CategoryπŸŽ‚ AgeShift

    Inputs (4)

    NameTypeDefaultDescription
    model_idSTRINGnateraw/vit-age-classifierβ€”
    deviceCOMBOauto5 options: auto, cuda, cuda:0, cuda:1, cpu
    dtypeCOMBOfp323 options: fp32, fp16, bf16
    force_reloadoptBOOLEANfalseβ€”

    Outputs (1)

    NameTypeDescription
    detectorAGE_DETECTORβ€”