Nodes/ComfyUI_RS_NAI_API_Request/NAI Character Asset Load
ComfyUI Node

NAI Character Asset Load

The Refresh button is the whole tutorial

By raspie10032·Created 2 years ago·Updated 20 days ago· 10
NAI Character Asset Load
    • image
    • prompt
    • negative_prompt
    ◄asset_file▾►

    This is the other half of the pack's character asset pair. Save wrote a PNG with your character's image and its original prompt text baked into the metadata; Load reads them back out. Three outputs, two of which are strings, and one button you will click a lot.

    What you get out of it

    • image - the PNG, decoded like any other IMAGE. Normally you send this to the pack's Reference Inset node, or to whatever the reference node wants.
    • prompt - the original character description, verbatim.
    • negative_prompt - the original character negative, verbatim.

    "Verbatim" is the important word. The loader adds nothing, rewrites nothing, and doesn't re-tag anything. The point of the asset is that the wording that worked last month still works today, character names included.

    The single input is asset_file, a dropdown listing the .png files sitting directly in ComfyUI/input/rs_nai_assets/. Files in subfolders aren't listed - the node resolves and checks each path against that one directory on purpose, so a stray ../ in a filename can't walk out of it.

    Why the list goes stale (and the button)

    Since this is an API-wrapper pack (external-api-nodes.md), it's worth knowing that the two really useful nodes in that pack behave like any other node: the combo list is built when the node's input definition is requested, not every time the graph runs. Save an asset, look at the dropdown, and it won't be there. That's not a cache bug, it's the definition being older than your file.

    So: hit Refresh assets on the node. The frontend re-fetches the node's object_info, rewrites the dropdown values, and updates the button label - No assets yet. Save one, then refresh. when the folder is empty, the refresh label otherwise. Same dance after you copy an asset in from another install.

    The one piece of cleverness in the code is IS_CHANGED: the loader hashes the selected file's contents, so replacing a PNG with a different file of the same name invalidates the cache and the graph actually re-runs. Without that you'd get a stale image and wonder why your edit did nothing.

    Wiring the strings into a prompt

    Here's the bit that trips people up. prompt is a STRING output, and the target is usually a multiline text widget on some other node - which you cannot drag a wire onto by default.

    Right-click the destination node and choose Convert widget to input. Now that text box is a socket, and the wire connects. This is the standard ComfyUI mechanic for turning any widget into something a graph can feed (comfyui-node-plumbing.md), and in this pack you'll use it at least once, because the natural wiring is:

    NAI Character Asset Load ── image ─────────→ NAI Reference Inset (or your image path)
                              ── prompt ────────→ a character slot in NAI Character Prompt Select
                              ── negative_prompt → that slot's negative input
    

    Or, if you're using the inset workflow, prompt goes to the inset generator's base prompt and you type your scene description alongside it. Resist the urge to save the scene description in the asset - the asset is the character block, and it'll follow you into every future scene you drop it in.

    Install

    Ships with the rest of the pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/raspie10032/ComfyUI_RS_NAI_API_Request.git
    cd ComfyUI_RS_NAI_API_Request
    python -m pip install -r requirements.txt
    

    ComfyUI Manager: search ComfyUI_RS_NAI_API_Request, Install, restart. The requirements.txt is the full pack stack (requests, Pillow, numpy, python-dotenv, torch, segment-anything) - heavy for a file reader, but it installs once. No NovelAI token needed here, and no Anlas are touched: loading is local file I/O.

    Where people get burned

    A normal PNG is not an asset. Point this at any old image and you get Missing or unsupported character asset metadata. Use NAI Character Asset Save to create the asset. That's the intended answer, not a broken install - the file has to come from the Save node first.

    A missing file gives a different error - Asset not found: … - usually because you deleted or moved the PNG between refreshing and executing. Refresh and re-pick.

    Sharing the PNG shares the prompts. The asset stores your positive and negative text in plain PNG metadata. Anything that scrubs metadata (gallery sites, "optimise" tools, some chat apps) will break the asset silently; the loader will refuse it afterwards with the metadata error above. Ship assets as files, or as archives, and check what you're handing over.

    Deleted node widgets are in old workflows. If you're loading a workflow from before the pack's 2.5.0 release, the asset nodes may not exist yet - update the pack and refresh the browser page, since the frontend pieces (the Refresh button included) load from the pack's web/ directory.

    CategoryRS_NovelAI_API/Characters

    Inputs (1)

    NameTypeDefaultDescription
    asset_fileCOMBOSelect a saved asset PNG. Use Refresh assets to update this list after saving or importing.

    Outputs (3)

    NameTypeDescription
    imageIMAGE—
    promptSTRING—
    negative_promptSTRING—