main
Tag Frequency Weighter for ComfyUI
A ComfyUI custom node that weights tags based on their frequency/rarity in danbooru
Features
- Automatically weights tags based on popularity/rarity
- Caches calculations for better performance
- Preserves existing weights in the input prompt
- Configurable weight ranges and pivot points
- Filter tags by count thresholds
How It Works
- Reads tag frequencies from
danbooru_tags_post_count.csv - Calculates averages and caches them in
tag_stats_cache.json(recomputable via toggle) - For each tag in the prompt:
- Maps rarity/popularity around a pivot to your chosen
[min_value, max_value]range - Popular tags → weighted toward
min_value - Rare tags → weighted toward
max_value - Tags that round to 1.00 remain unchanged
- Maps rarity/popularity around a pivot to your chosen
Inputs
| Parameter | Type | Description |
|---|---|---|
input_prompt |
string | Input tags (comma-separated, preserves existing weights) |
min_value |
float | Lower bound for output weights |
max_value |
float | Upper bound for output weights |
calculate_average |
bool | Recompute CSV stats and update cache |
preserve_underscores_in_output |
bool | Keep underscores in output tags |
pivot |
string | log10(avg) or x_avg - calculation method |
ignore_below_tag_count |
int | Leave tags below this count unchanged (0=off) |
ignore_above_tag_count |
int | Leave tags above this count unchanged (0=off) |
debug |
bool | Print per-tag counts during processing |
CSV Source
The dataset was created using script by bem13.
To rebuild the dataset:
- Generate
danbooru_tags_post_count.csvusing the script - Place it next to
nodes.pyin the node directory
Installation
- Drop this folder into ComfyUI's
custom_nodes/directory - Restart ComfyUI
License
MIT
Languages
Python
100%
