Nodes/ComfyUI_Pic2Story/Pic2Story_Loader
ComfyUI Node

Pic2Story_Loader

Load the story-captioning model once, reuse it across the graph

By smthemex·Created 2 years ago·Updated 2 years ago· 10
Pic2Story_Loader
    • model
    repo_idabhijit2111/Pic2Story
    inference_mode

    Pic2Story_Loader is the "model" half of the two-node captioning pattern in this pack. It loads the image-to-text model into memory and hands it to Pic2Story_Sampler, which actually does the captioning. If you're only describing one image, the all-in-one Pic2Story node is simpler - but the moment you want to describe a bunch of images with the same model, or keep the model resident while you fiddle with other parts of the graph, the Loader/Sampler split is the right shape.

    Under the hood it's a thin transformers wrapper. It calls from_pretrained on the repo you give it and returns the model plus its processor wrapped up in a custom PICMODEL type that only the matching Sampler understands.

    Here's the clever bit, and it's worth knowing because it trips people up. The node looks at the repo_id string to decide which model family to load. If the repo contains "Pic2Story", it loads the BLIP model - BlipForConditionalGeneration with a BlipProcessor, in float16 on GPU if you asked for gpu_float16, or full precision / CPU otherwise. If the repo is anything else, it switches to PaliGemma - PaliGemmaForConditionalGeneration in bfloat16. So the default abhijit2111/Pic2Story gives you the story-tuned BLIP, and pointing it at google/paligemma2-3b-pt-896 silently changes the whole backend.

    The inputs that matter

    There are only two, and both are set-and-forget:

    • repo_id - default abhijit2111/Pic2Story. The check "does the string contain Pic2Story" decides BLIP vs PaliGemma, so don't rename the repo id casually or you'll switch families without meaning to.
    • inference_mode - gpu_float16 (fast, light, your default on any CUDA card), gpu (fp32, uses noticeably more VRAM for no visible quality gain in captioning), cpu (works, slow).

    The output

    One output: model of type PICMODEL. It wires straight into the model input of Pic2Story_Sampler and nowhere else.

    The gotcha that will bite you

    The PaliGemma path loads with local_files_only=True. That means if you switch repo_id to the PaliGemma model, it will refuse to download anything - if the model isn't already in your Hugging Face cache, the load just fails. This is exactly what the DownloadModel node is for: run it once for google/paligemma2-3b-pt-896, let it cache, then point the Loader at it. The BLIP path doesn't have this restriction and will happily download on first load.

    How to install

    Same as the rest of the pack. Via ComfyUI Manager, search "Pic2Story" and install, then restart. Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/smthemex/ComfyUI_Pic2Story.git
    

    then restart ComfyUI. The pack ships no requirements.txt, so if transformers isn't already in your ComfyUI Python environment, install it (pip install transformers) before the nodes will import. First load downloads a multi-gigabyte checkpoint, so don't panic when the first queue run hangs on model loading.

    CategoryPic2Story

    Inputs (2)

    NameTypeDefaultDescription
    repo_idSTRINGabhijit2111/Pic2Story
    inference_modeCOMBO3 options: gpu_float16, gpu, cpu

    Outputs (1)

    NameTypeDescription
    modelPICMODEL