Nodes/ComfyUI Gender Tag Filter/Gender Tag Filter πŸ³οΈβ€πŸŒˆ
ComfyUI Node

Gender Tag Filter πŸ³οΈβ€πŸŒˆ

Your prompt expander keeps adding breasts. This node stops it.

By senjinthedragonΒ·Created 6 months agoΒ·Updated 5 months agoΒ· 0
Gender Tag Filter πŸ³οΈβ€πŸŒˆ
  • spacy_nlp
  • filtered_tags
β—„textβ–Ί
β—„modestrip_female_tagsβ–Ί
β—„filter_anatomytrueβ–Ί
β—„replace_anatomyfalseβ–Ί
β—„filter_presentationfalseβ–Ί
β—„swap_clothingtrueβ–Ί
β—„use_underscorestrueβ–Ί
β—„rewrite_referencestrueβ–Ί
β—„map_neopronounstrueβ–Ί
β—„handle_negationstrueβ–Ί

If you generate male or all-male scenes with a tag prompt, you know the drill: you type 1boy, muscular, ... and the output still shows up with breasts. The blame usually lands on the prompt expander in the middle of your chain. Tools like TIPO are trained on giant tag datasets that skew hard toward female anatomy, so when you hand them a male scene they quietly feminise it - adding anatomy tags you never asked for. Telling the image model to fix it in the negative prompt doesn't really work either, because breasts is a token that grabs the model's attention even when it appears negated. The tag simply shouldn't be there at all.

Gender Tag Filter is the node that takes it out before CLIP ever sees it. It sits between your prompt expander and your CLIPTextEncodeSDXL, eats a tag string, and strips or rewrites every gendered token that doesn't match your scene. It's the flagship of the comfyui-gender-tag-filter pack, and it's the most thorough thing of its kind I've found: the author ships 145 female anatomy tags, 118 male anatomy tags, 152 female presentation tags, and 112 clothing-swap pairs in one shared data file.

How it works

Drop it in and the defaults already do the sensible thing. mode defaults to strip_female_tags; switch to strip_male_tags for the mirror image, format_only if you just want tag formatting with zero filtering, or off for a passthrough. The anatomy list is the star here - it doesn't just match exact tags, it scans compound tags for root words, so huge_breasts, breast_grab, and hanging_breasts all get caught even though nobody individually listed them.

The inputs you'll actually touch, in rough order of importance:

  • filter_anatomy (on by default) - the core removal pass.
  • replace_anatomy (off by default) - swaps instead of deletes: large_breasts β†’ muscular_chest, 1girl β†’ 1boy, yuri β†’ yaoi, cameltoe β†’ bulge. Turning this on is usually the difference between "clean" and "actively useful."
  • filter_presentation (off by default) - handles clothing, accessories, and makeup. Keep it off unless you want a crossdressing character; that's the one switch that stops the node from "helpfully" deleting a skirt.
  • swap_clothing (on when presentation is on) - skirt β†’ trousers, bikini β†’ swim_trunks, bra β†’ removed (no clean equivalent).
  • use_underscores (on) - outputs big_breasts for Danbooru/e621-style models. Some fine-tunes want spaces; flip it.
  • map_neopronouns and rewrite_references (both on) - shi/hir β†’ binary equivalents, woman β†’ man, vixen β†’ fox, doe β†’ buck.

Two things are worth knowing about how it parses. It's fully A1111/Forge emphasis-aware: (tag:1.3), ((tag)), and [tag] are parsed, filtered, and re-wrapped with their original weights intact. And it passes LoRA, hypernetwork, and BREAK syntax through untouched, so nothing breaks. One honest caveat: if your tag string has natural-language fragments mixed in (TIPO does this), this node detects them and passes them through for the NL filter to handle - it's not the node for rewriting prose.

Wiring it up

Both inputs and outputs are plain STRING, so it chains with no adapters:

TIPO β†’ DanbooruTagSnakeCaseFixer β†’ StringConcatenate β†’ [Dedupe Tags]
     β†’ [Gender Tag Filter] β†’ [Gender NL Filter] β†’ CLIPTextEncodeSDXL

The single output, filtered_tags, feeds either the NL filter or straight into your CLIP encode. Wire a SpaCy Model Loader into the optional spacy_nlp input if you want spaCy-backed detection of those NL fragments; leave it disconnected and it uses a stop-word heuristic fallback that's fine for most tag lists.

Installing and gotchas

Install the whole pack via ComfyUI Manager (search "Gender Tag Filter") or:

cd ComfyUI/custom_nodes
git clone https://github.com/senjinthedragon/comfyui-gender-tag-filter

Then restart ComfyUI - the node lives under utils/tags. spaCy is optional but recommended; the real trap is Python 3.13/3.14, which spaCy can't build on, so it'll silently run in reduced mode. If a tag still slips through, the blocklists in gender_shared.py are plain Python sets - extend them and restart. That's the whole maintenance story, and it's a good one.

Categoryutils/tags

Inputs (11)

NameTypeDefaultDescription
textSTRINGTag string to filter. NL fragments are detected and preserved automatically.
modeCOMBOstrip_female_tags'strip_female_tags' -> remove female anatomy/presentation tags 'strip_male_tags' -> remove male anatomy/presentation tags 'format_only' -> no filtering; apply use_underscores only 'off' -> pass through completely unchanged
filter_anatomyBOOLEANtrueRemove explicit anatomical tags for the unwanted gender. Also scans compound tags for anatomy root words, so huge_breasts, breast_grab, hanging_breasts etc. are all caught even if not individually listed.
replace_anatomyBOOLEANfalseReplace removed anatomy tags with gender-appropriate counterparts instead of just deleting them. e.g. large_breasts -> muscular_chest, breasts -> pecs 1girl -> 1boy, yuri -> yaoi, cameltoe -> bulge Has no effect when filter_anatomy is off.
filter_presentationBOOLEANfalseRemove gendered clothing, accessory, and makeup tags. Disable for crossdressing characters.
swap_clothingBOOLEANtrueWhen filter_presentation is on, replace clothing tags with gender-appropriate equivalents instead of just removing. e.g. skirt -> trousers, bikini -> swim_trunks, evening_gown -> tuxedo, bra -> removed (no equivalent) Has no effect when filter_presentation is off.
use_underscoresBOOLEANtrueOutput word separator style. On -> big_breasts (Danbooru/e621, most SDXL models) Off -> big breasts (some fine-tuned models) Input tags are always accepted in either style. Natural language fragments bypass this setting entirely.
rewrite_referencesBOOLEANtrueSwap standalone gendered noun tags. woman -> man, girl -> boy, vixen -> fox, doe -> buck etc. Covers the same word set as the NL Filter's rewrite_references for consistent behaviour across both nodes.
map_neopronounsBOOLEANtrueMap neopronoun tags to binary equivalents that image models are likely to recognise from their training data. Covers: shi/hir (Chakat/furry), they/them, xe/xem, ze/zir, ey/em (Spivak), fae/faer, ve/ver, per. When off, neopronoun tags pass through unchanged.
handle_negationsBOOLEANtrueProtect tags that appear in a negated context from removal. e.g. in a mixed prompt, 'no breasts' will leave the tag untouched rather than removing it. Uses a 4-token proximity heuristic.
spacy_nlpoptSPACY_NLPConnect a SpaCy Model Loader node to enable spaCy-backed NL fragment detection. Leave disconnected to use the stop-word heuristic fallback instead.

Outputs (1)

NameTypeDescription
filtered_tagsSTRINGβ€”