Nodes/comfyui-anima-toolkit/TK Danbooru Tag Getter
ComfyUI Node

TK Danbooru Tag Getter

Sort a messy prompt into tag categories, then drop or weight them

By Ararararararaki·Created 3 months ago·Updated about 16 hours ago· 10
TK Danbooru Tag Getter
  • tag_bundle
  • Tag String
画师词false
背景词false
人物对象词false
角色特征词false
角色五官词false
角色部位词false
性征部位词false
服饰词false
动作词false
角色表情词false
镜头词false
未归类词false
regex_blacklist
tag_blacklist
natural_language
include_natural_languagetrue
filter_natural_languagetrue
画师词_weight1.00
背景词_weight1.00
人物对象词_weight1.00
角色特征词_weight1.00
角色五官词_weight1.00
角色部位词_weight1.00
性征部位词_weight1.00
服饰词_weight1.00
动作词_weight1.00
角色表情词_weight1.00
镜头词_weight1.00
未归类词_weight1.00

Prompts accumulate junk. You paste a character's trigger phrase, add a lighting node, some camera tags, a speech_bubble that slipped in from a booru post - and now you want to keep four of those things and bin the rest, without hand-editing the prompt every run.

TK Danbooru Tag Getter does that one job: it takes a prompt, recognises the tags inside it, sorts them into twelve categories, and gives you back only the categories you asked for. It's the text-sorting node of TK Toolkit (anima-toolkit by 时运tk), the toolkit built around the Anima base model, where a booru-tag vocabulary and natural language coexist in the same prompt.

How the classification works

The node builds a tag → category index at runtime. It looks first for a sibling custom node, ComfyUI-Danbooru-Tag-Sorter-Node, and reads its tags_database/danbooru_tags.xlsx plus defaults_config.json. If that pack isn't installed, it falls back to a CSV bundled inside TK Toolkit itself and applies a built-in heuristic mapping (subcategory keywords like 头发/眼睛 → 角色特征词, 胸部/性器官 → 性征部位词, and so on), with anything it can't place landing in 未归类词.

That first parse is genuinely heavy - the database is over 200,000 rows. The node reads the xlsx XML directly rather than spinning up a full workbook, then writes the index to data/tag_category_index.cache so the next ComfyUI start is instant. Delete that file if you ever suspect it's stale; it self-invalidates when the source database changes anyway.

The inputs that matter

Twelve BOOLEAN switches, one per category, all off by default: 画师词, 背景词, 人物对象词, 角色特征词, 角色五官词, 角色部位词, 性征部位词, 服饰词, 动作词, 角色表情词, 镜头词, 未归类词. Tick the ones you want in the output. Nothing ticked means nothing gets extracted from the classification pass.

Then the filtering:

  • natural_language - the prompt itself, shown in the UI as 统一 Prompt. It's a forced input socket, so wire it from a text node; it accepts a plain prompt or a Packer's ALL_TAGS.
  • include_natural_language - on by default. Sentences the classifier can't identify ride along after the tags instead of being thrown away.
  • filter_natural_language - apply the blacklists to those leftover sentences too.
  • regex_blacklist - case-insensitive regex, e.g. censor|watermark.
  • tag_blacklist - exact tag matches, comma or newline separated, case-insensitive. This is the one that kills speech_bubble cleanly.
  • tag_bundle - optional TAG_BUNDLE input, for older workflows that already had a structured category pack wired up. You don't need both inputs; the single-prompt mode is the intended path now.

Each of the twelve categories also has its own weight input, 0.05–2.0 in 0.05 steps, defaulting to 1.0 - and 1.0 means no parentheses at all. Set 角色表情词 to 0.8 and you get (smile:0.8); if the incoming tag already carried a weight, the two multiply. Old workflows that restored the new widgets as 0 get treated as neutral 1.0 rather than emitting the (tag:0) that downstream encoders choke on.

Output is a single STRING, Tag String. Feed it to a CLIP text encode, or into TK 文本合并 if you're assembling a bigger prompt.

Set the weights to 1.0 and leave them

Here's my take, and it's grounded in how Anima works rather than in taste. Anima is LLM-encoded - a Qwen3-0.6B text encoder - and prompt weighting is disabled in the encoder path on those models. (smile:0.8) is not a gentle nudge there; it's punctuation handed to the encoder inside an instruction. Deleting the parentheses entirely is usually the better move. What you're paying for with this node is the classification: route the 镜头词 out and into a camera node, or drop 服饰词 while you're testing an outfit LoRA. That part is real and useful. The weights are a carryover from the SDXL world and mostly theatre on Anima.

Install and the one real gotcha

cd ComfyUI/custom_nodes
git clone https://github.com/Ararararararaki/comfyui-anima-toolkit
# restart ComfyUI (Python node changes always need a restart)

Or search TK Toolkit in ComfyUI Manager. aiohttp and requests are the only hard dependencies.

The gotcha is that sibling pack. Install ComfyUI-Danbooru-Tag-Sorter-Node next to TK Toolkit and classification follows that pack's curated database. Skip it and you're on the bundled CSV plus heuristics - still functional, but expect a fatter 未归类词 bucket. If everything is landing there, that's your signal the index didn't load. Also note the node only ever filters its own output; it never mutates the upstream TAG_BUNDLE or prompt.

CategoryTK/text

Inputs (30)

NameTypeDefaultDescription
画师词BOOLEANfalse
背景词BOOLEANfalse
人物对象词BOOLEANfalse
角色特征词BOOLEANfalse
角色五官词BOOLEANfalse
角色部位词BOOLEANfalse
性征部位词BOOLEANfalse
服饰词BOOLEANfalse
动作词BOOLEANfalse
角色表情词BOOLEANfalse
镜头词BOOLEANfalse
未归类词BOOLEANfalse
tag_bundleoptTAG_BUNDLE
regex_blacklistoptSTRING
tag_blacklistoptSTRING
natural_languageoptSTRING统一输入:接入 Packer 的 ALL_TAGS 或普通 Prompt;已知 Danbooru Tag 会自动分类,未知段落可选择保留。
include_natural_languageoptBOOLEANtrue
filter_natural_languageoptBOOLEANtrue
画师词_weightoptFLOAT1.000.05–2画师词 Tag 权重;1.0 保持原样,范围 0.05–2.0
背景词_weightoptFLOAT1.000.05–2背景词 Tag 权重;1.0 保持原样,范围 0.05–2.0
人物对象词_weightoptFLOAT1.000.05–2人物对象词 Tag 权重;1.0 保持原样,范围 0.05–2.0
角色特征词_weightoptFLOAT1.000.05–2角色特征词 Tag 权重;1.0 保持原样,范围 0.05–2.0
角色五官词_weightoptFLOAT1.000.05–2角色五官词 Tag 权重;1.0 保持原样,范围 0.05–2.0
角色部位词_weightoptFLOAT1.000.05–2角色部位词 Tag 权重;1.0 保持原样,范围 0.05–2.0
性征部位词_weightoptFLOAT1.000.05–2性征部位词 Tag 权重;1.0 保持原样,范围 0.05–2.0
服饰词_weightoptFLOAT1.000.05–2服饰词 Tag 权重;1.0 保持原样,范围 0.05–2.0
动作词_weightoptFLOAT1.000.05–2动作词 Tag 权重;1.0 保持原样,范围 0.05–2.0
角色表情词_weightoptFLOAT1.000.05–2角色表情词 Tag 权重;1.0 保持原样,范围 0.05–2.0
镜头词_weightoptFLOAT1.000.05–2镜头词 Tag 权重;1.0 保持原样,范围 0.05–2.0
未归类词_weightoptFLOAT1.000.05–2未归类词 Tag 权重;1.0 保持原样,范围 0.05–2.0

Outputs (1)

NameTypeDescription
Tag StringSTRING