2025-08-18 01:33:17 +03:00
2025-08-18 01:33:17 +03:00
2025-08-18 01:33:17 +03:00
2025-08-18 01:33:17 +03:00
2025-08-18 01:33:17 +03:00
2025-08-18 01:33:17 +03:00
2025-08-18 01:33:17 +03:00
2025-08-18 01:33:17 +03:00
2025-08-18 01:33:17 +03:00

Tag Frequency Weighter for ComfyUI

preview

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

  1. Reads tag frequencies from danbooru_tags_post_count.csv
  2. Calculates averages and caches them in tag_stats_cache.json (recomputable via toggle)
  3. 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

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:

  1. Generate danbooru_tags_post_count.csv using the script
  2. Place it next to nodes.py in the node directory

Installation

  1. Drop this folder into ComfyUI's custom_nodes/ directory
  2. Restart ComfyUI

License

MIT

S
Description
No description provided
Readme MIT
6.6 MiB
Languages
Python 100%