ComfyUI Node

Model Loader

Load any Hugging Face captioning model into ComfyUI

By mediocreatmybest·Created about a year ago·Updated 12 months ago· 3
Model Loader
    • model_pipeline
    model_name_or_pathSalesforce/blip-image-captioning-base
    taskimage-to-text
    device_modecuda
    use_bitsandbytesfalse
    quantization_type8bit
    trust_remote_codefalse
    use_fast_tokenizertrue

    Everything else in this pack needs a MODEL wire coming from somewhere, and this is the node that produces it. Under the hood it's a thin wrapper around Hugging Face's transformers.pipeline() call: you give it a model id and a task, it downloads (or reuses a cached copy of) that model and hands back a ready-to-run pipeline object. If you've used transformers in a Python script before, this node is that one function call with a ComfyUI face on it.

    What it actually loads

    Two required fields do the real work. model_name_or_path is a Hugging Face repo id - the default is Salesforce/blip-image-captioning-base, which is worth knowing before you assume it's a good default: the LoRA-training community's current verdict on BLIP is blunt, "pure trash," formulaic and inaccurate captions, deprecated for years. It'll load and it'll work, it's just not what you want if caption quality matters. Swap in something better - a BLIP2 or GIT variant from this pack's own Caption Model List node, or skip this node's generic path entirely and use the pack's dedicated Florence-2 Node, which is the actually-current recommendation.

    task has to match a real Hugging Face pipeline task string - image-to-text is the default and the one this pack's Caption Generator is shaped for. Typing this by hand invites typos; wire in the Task List node instead and pick from its dropdown.

    The optional knobs

    • device_mode - cuda, cpu, or auto. Leave it on cuda if you have a GPU; auto lets the library decide, which is handy if you're sharing a workflow with someone who might not have one.
    • use_bitsandbytes + quantization_type (4bit / 8bit, default 8bit) - the same quantize-to-save-VRAM idea you'll recognize from GGUF or NF4 on the image-generation side, applied here to the captioning model's language-model backbone. Off by default because the stock BLIP-base model is tiny and doesn't need it, but flip it on if you swap in one of the heavier BLIP2 variants (the 6.7B ones) and your card is tight. Expect the usual tradeoff: 8bit is close to lossless, 4bit trims more VRAM at the cost of some quality.
    • trust_remote_code - off by default, and worth understanding rather than just flipping on. Some Hugging Face model repos (Florence-2 is the standard example) ship custom Python alongside the weights, and loading them requires this flag because the library will actually execute that repo's code. Fine for well-known models from a source you trust; not something to toggle on reflexively for an arbitrary model id.
    • use_fast_tokenizer - on by default, uses the Rust-backed fast tokenizer implementation where the model supports one. Leave it alone unless a specific model complains.

    Output

    model_pipeline (MODEL) is the only output, and it goes exactly one of two places: straight into Caption Generator to actually run captions, or through Debug Pipeline Node first if you want to confirm what loaded before you commit a folder of images to it.

    Installing it

    Through ComfyUI Manager: search ComfyUI-Transformers-Pipeline, install, restart. By hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/mediocreatmybest/ComfyUI-Transformers-Pipeline
    

    then restart ComfyUI. The model itself downloads from Hugging Face the first time you run the node with a given model_name_or_path - budget for that on a cold start, especially with anything past BLIP-base.

    Common issues & troubleshooting

    Wrong task string, load fails or the wrong pipeline type comes back. Use the Task List node instead of typing task by hand - Hugging Face pipeline task names are exact strings, no fuzzy matching.

    Load succeeds but everything downstream is slow or falls back to CPU. Don't guess - wire the output through Debug Pipeline Node first and read what it reports before you send real work through it. device_mode: cuda requesting a GPU that isn't actually available is a common way to end up running on CPU without noticing.

    Out of memory on a bigger model. Turn on use_bitsandbytes before you go looking for a smaller model - 8bit is nearly free quality-wise and usually buys enough headroom.

    A model fails to load with a complaint about custom or remote code. That's trust_remote_code - the model's repo needs it and the node has it off by default. Only turn it on for models you actually trust, since it does run that repo's own Python.

    CategoryTransformers Pipeline

    Inputs (7)

    NameTypeDefaultDescription
    model_name_or_pathSTRINGSalesforce/blip-image-captioning-base
    taskSTRINGimage-to-text
    device_modeoptCOMBOcuda3 options: cuda, cpu, auto
    use_bitsandbytesoptBOOLEANfalse
    quantization_typeoptCOMBO8bit2 options: 4bit, 8bit
    trust_remote_codeoptBOOLEANfalse
    use_fast_tokenizeroptBOOLEANtrue

    Outputs (1)

    NameTypeDescription
    model_pipelineMODEL