Nodes/ComfyUI-TagClassifier/LLM Tag Classifier
ComfyUI Node

LLM Tag Classifier

Let DeepSeek sort your Danbooru tags into seven buckets

By Wenaka2004·Created 2 years ago·Updated 2 years ago· 24
LLM Tag Classifier
    • IS_NSFW
    • 角色头部以上服饰特征
    • 角色动作及表情
    • 角色上半身服饰特征
    • 角色下半身服饰特征
    • 其他
    • NSFW
    text
    api_key

    You know the feeling: your prompt is a wall of forty Danbooru tags - character identity mixed with clothing mixed with pose mixed with whatever's in the background - and you'd love to keep the character the same while swapping everything else. LLM Tag Classifier is the pack's one trick: paste that flat tag pile into text, and it asks DeepSeek's cloud API to split the tags into seven semantic buckets. Character features in one output, action and expression in another, upper and lower clothing in their own, "everything else" in another, and all the NSFW tags kept cleanly separate. It's a small, weirdly specific idea, and if you do a lot of tag-based anime prompting it's genuinely handy.

    The name on the node is a small lie that works in your favor: despite being an "LLM classifier," nothing runs on your machine. There's no model download, no VRAM cost, no GPU hit. The LLMProcessingNode takes your tag string, bundles it with a canned prompt, and calls https://api.deepseek.com/v1/chat/completions with the deepseek-chat model. What makes it smarter than a regex is the prompt.json that ships with the pack: a Chinese system prompt instructing the model to act as a "danbooru tag 分词器" (tokenizer), plus a handful of few-shot examples - including explicit NSFW ones - showing exactly how a pile of tags should be split. DeepSeek replies with a JSON object inside a markdown fenced block; the node regexes out the JSON, parses it, and hands you seven strings. Your tags do leave the machine and go to a third party, and the model is a paid API, so this is a "cheap cloud call per run" node, not a "free local forever" node.

    Two inputs, that's it. text is your multiline tag string, and api_key is your DeepSeek key pasted straight into the widget. Then the outputs - all strings, all labeled in Chinese, which is the first thing that'll throw you:

    • IS_NSFW - literally the string "True" or "False".
    • 角色头部以上服饰特征 - the character's head-and-above identity features (name, hair, eyes, ears). This is the bucket you keep if you want to re-generate the same character.
    • 角色动作及表情 - pose and expression.
    • 角色上半身服饰特征 and 角色下半身服饰特征 - clothing, split top and bottom.
    • 其他 - background, quality tags, anything not obviously the character.
    • NSFW - sex tags, deliberately kept separate so you can merge them with another character's identity block and keep the pose working.

    Wire whichever bucket you care about into your checkpoint's positive prompt (or feed the buckets to a text-concat node to reassemble them in whatever order you like). The thinking behind it matches the character-consistency playbook: isolate what makes the character that character, then recombine it with different scenes.

    Installing it

    ComfyUI Manager, search "ComfyUI-TagClassifier" and hit install, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Wenaka2004/ComfyUI-TagClassifier
    

    Then restart ComfyUI. No extra Python dependencies - the code just uses requests and torch, both already present. The only real setup is getting a DeepSeek API key from platform.deepseek.com and putting a couple of dollars on it. The API is famously cheap, but it's still a prepaid account, and the key goes into the node's api_key field as plaintext - which means it's stored in your workflow JSON. Don't share that workflow. Seriously. Anyone with the file has a live key attached to your wallet.

    Where people get burned

    • It's Windows-leaning out of the box. The node loads prompt.json from the working directory, with a fallback path written with Windows backslashes (custom_nodes\ComfyUI-TagClassifier\prompt.json). On Windows that resolves fine. On Linux or macOS both lookups can miss, and you get a FileNotFoundError the moment you run it. If that happens, copy prompt.json into the directory ComfyUI starts from (or launch ComfyUI from the pack folder) and it'll work.
    • It's a network call. Every run is a round trip to DeepSeek. The node is effectively stateless - prompt.json's examples are baked in, so a given input tends to give a similar split, but don't expect deterministic, instant results.
    • NSFW is the point. The whole prompt is tuned around the NSFW case, including the rule that NSFW and 角色动作及表情 must never both be populated. If your tags are SFW, the IS_NSFW output just reads "False" and the NSFW bucket comes back empty.

    Is it essential? No. You could get most of the way there by hand or with a generic LLM API node. But as a one-commit pack from a small author, it's a thoughtful little utility for anime-prompt reorganizing - and honestly, the exact thing a lot of us were already doing with copy-paste and a text editor. This just puts it in the graph.

    CategoryLLM Tag Classifier

    Inputs (2)

    NameTypeDefaultDescription
    textSTRING
    api_keySTRING

    Outputs (7)

    NameTypeDescription
    IS_NSFWSTRING
    角色头部以上服饰特征STRING
    角色动作及表情STRING
    角色上半身服饰特征STRING
    角色下半身服饰特征STRING
    其他STRING
    NSFWSTRING