Nodes/Duanyll Nodepack/HuggingFace Dual CLIP Loader
ComfyUI Node

HuggingFace Dual CLIP Loader

Load CLIP Straight From Your Hugging Face Cache

By Duanyll·Created about a year ago·Updated 4 months ago· 2
HuggingFace Dual CLIP Loader
    • CLIP
    repo_id_1black-forest-labs/FLUX.1-dev
    repo_id_2black-forest-labs/FLUX.1-dev
    typeflux
    subfolder_1text_encoder
    subfolder_2text_encoder_2
    filename_1
    filename_2

    ComfyUI's built-in DualCLIPLoader only looks in models/text_encoders (or models/clip). Fine, except the moment you've pulled a model with the huggingface_hub CLI, the files are already sitting in ~/.cache/huggingface/hub - and you're stuck copying gigabytes into ComfyUI's folders. This node is the answer to that exact chore: it reads a dual text encoder straight out of your Hugging Face cache (or any local path) and hands you a working CLIP object.

    It's the loader you reach for with Flux-family models, which need two encoders (CLIP-L plus the big T5-XXL), and it's a small but real quality-of-life win in any workflow that swaps text encoders often.

    How it works

    Despite the "Downloads a model from Hugging Face" description, this node does not download anything. It resolves the HF cache layout (models--owner--repo snapshot dirs) and loads what's already there - it even says so in its own error message, telling you to run hf download <repo> first if the repo isn't cached. That's a feature: it works offline and never makes a surprise network call mid-workflow.

    From there it auto-detects the checkpoint file in the subfolder you point at (preferring a .index.json for sharded checkpoints, then .safetensors, .sft, .bin, .pt), merges shards if the checkpoint is split, and feeds both encoders into Comfy's load_text_encoder_state_dicts. You get back one CLIP that plugs straight into CLIPTextEncode and the model loader - exactly like the core DualCLIPLoader, minus the folder-juggling.

    Inputs and outputs that matter

    The two you'll actually touch:

    • repo_id_1 / repo_id_2 - a Hugging Face repo ID (black-forest-labs/FLUX.1-dev is the default), an absolute path like /models/flux, or a relative path like ./models/... from the ComfyUI root. Both must resolve; empty repo IDs raise a clear error.
    • type - pick flux for FLUX.1 (the default) and sdxl/sd3/hidream/hunyuan_* etc. for the others. This sets which CLIPType Comfy uses to merge the encoders, so it's not decorative.

    Defaults for the optional subfolder_1/subfolder_2 (text_encoder and text_encoder_2) match the official FLUX.1 repo layout, so for the stock case you literally hit default, default, default. The filename_1/filename_2 fields are blank by default for auto-detect - fill them in when a folder holds several candidates and the node refuses to guess.

    Output is a single CLIP (one wire), and that's it.

    Installing it

    It ships in Duanyll Nodepack, so either route works:

    # Via ComfyUI Manager: search "Duanyll Nodepack", install, restart
    cd ComfyUI/custom_nodes
    git clone https://github.com/Duanyll/duanyll_nodepack
    # restart ComfyUI
    

    The pack's requirements.txt pulls in huggingface-hub and safetensors for this loader family - Manager handles it, a manual clone needs pip install -r requirements.txt if anything's missing.

    Where people get burned

    The one that trips everyone: the node won't fetch the repo for you. If black-forest-labs/FLUX.1-dev isn't in your HF cache, you get a FileNotFoundError telling you exactly that. Fix it once, before you queue the workflow:

    hf download black-forest-labs/FLUX.1-dev
    

    Also watch for the ambiguity error: if a subfolder contains more than one .safetensors and you left filename blank, it refuses to pick. Name the file explicitly and move on. Both are the node being honest, not broken.

    Categoryduanyll/loaders

    Inputs (7)

    NameTypeDefaultDescription
    repo_id_1STRINGblack-forest-labs/FLUX.1-devThe Hugging Face repo ID, an absolute path (/path/to/model), or a relative path (./models/...) from the ComfyUI root.
    repo_id_2STRINGblack-forest-labs/FLUX.1-devThe Hugging Face repo ID, an absolute path (/path/to/model), or a relative path (./models/...) from the ComfyUI root.
    typeCOMBOflux12 options: sdxl, sd3, flux, hunyuan_video, hidream, hunyuan_image, +6
    subfolder_1optSTRINGtext_encoderThe subfolder where the model is located. Applies to both Hugging Face repos and local paths.
    subfolder_2optSTRINGtext_encoder_2The subfolder where the model is located. Applies to both Hugging Face repos and local paths.
    filename_1optSTRINGThe checkpoint file to load. If not specified, will auto-detect. For sharded checkpoints, use the index file (e.g., 'model.index.json').
    filename_2optSTRINGThe checkpoint file to load. If not specified, will auto-detect. For sharded checkpoints, use the index file (e.g., 'model.index.json').

    Outputs (1)

    NameTypeDescription
    CLIPCLIP