Nodes/ComfyUI_Fill-Nodes/FL Word Frequency Graph
ComfyUI Node

FL Word Frequency Graph

Audit your LoRA caption dataset before you burn GPU hours on it

By filliptm·Created 3 years ago·Updated about 11 hours ago· 628
FL Word Frequency Graph
    • IMAGE
    directory_path
    title_nameWord Frequency Analysis
    max_words50
    min_word_length3
    image_width1920
    image_height1080
    color_schemeblue
    exclude_common_wordstrue

    Before you kick off a multi-hour LoRA training run, it's worth actually looking at your captions - not skimming a couple of files, but seeing what vocabulary the whole dataset is dominated by. If your trigger word barely shows up, or half your captions accidentally start with the same boilerplate phrase because you batch-generated them with a captioner and never varied the prompt, that's a training run you're about to waste. FL_WordFrequencyGraph does the boring-but-useful job of scanning every .txt file in a folder and turning it into a bar chart so the problem is visible instead of buried in a hundred text files.

    How it works

    Point it at a directory of caption files - this is the same folder layout kohya-ss, AI Toolkit, and OneTrainer all expect, image + matching .txt caption side by side - and it reads every .txt in there, tokenizes and counts words across the whole set, filters out stopwords if you want, and renders a horizontal bar graph: most-used words on one side, least-used on the other. Output is a dark-themed matplotlib chart, returned as an image tensor like any other ComfyUI image output, so you can preview it inline or save it alongside your dataset as documentation.

    The inputs and outputs that matter

    • directory_path (STRING) - point this at your captions folder. It only reads .txt files, so pointing it at your images folder instead just gives you an empty or near-empty graph rather than an error - worth double-checking if the output looks suspiciously blank.
    • exclude_common_words (BOOLEAN, default true) - filters English stopwords (the, a, and, of...) out of the count. Leave this on unless you specifically want to confirm how much filler language is in your captions; with it on you're looking at the actual meaningful vocabulary, which is what you want for a dataset check.
    • max_words (INT, default 50, range 10–200) - how many bars show up in the chart. 50 is plenty to spot a problem; push it higher only if you're doing a deep audit of a large, varied dataset.
    • min_word_length (INT, default 3, range 1–10) - drops very short tokens (stray single letters, artifacts from bad tokenizing) below this length.
    • color_scheme (enum: blue / green / red / purple / orange / rainbow) and image_width / image_height - purely cosmetic, doesn't change the data.
    • title_name (STRING, default "Word Frequency Analysis") - the chart title, useful if you're saving multiple audits and want to tell them apart later.

    One output: an IMAGE - the rendered graph.

    How to install it

    Via ComfyUI Manager: search ComfyUI_Fill-Nodes (or Fill-Nodes), install, restart. Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/filliptm/ComfyUI_Fill-Nodes
    

    The chart rendering leans on matplotlib, which comes along with most ComfyUI Python environments already (several other nodes in this same pack use it); no model downloads involved.

    Common issues & troubleshooting

    Graph looks empty or near-empty. Almost always means directory_path is pointing at the wrong folder - the images folder instead of the captions folder, or a path with no .txt files in it at all. This node has no fallback to read caption text out of image metadata; it wants plain .txt files sitting in the directory.

    Junk words dominating the top of the chart. If your captioning pipeline (an auto-captioner, a template, a boilerplate prefix) repeats the same non-descriptive phrase across every file, that phrase will crowd out the words that actually distinguish your images - which is exactly the failure mode this node is meant to catch. If you see that, go fix the captions (vary the phrasing, or trim the boilerplate) before you train, not after.

    Trigger word barely visible. If you're using a rare-token trigger word (the standard practice to avoid it colliding with real vocabulary the base model already knows), it won't show up prominently here by design - that's not a bug in the node, it's the point of using an unusual token. What you're actually checking is that it appears at all, roughly once per caption, not that it's the tallest bar.

    Stray non-caption .txt files skewing the count. Notes, config exports, or leftover metadata files sitting in the same folder as your captions will get counted too, since the node has no way to distinguish a real caption from any other text file. Keep the captions folder clean of anything else before running an audit.

    Category🏵️Fill Nodes/Captioning

    Inputs (8)

    NameTypeDefaultDescription
    directory_pathSTRING
    title_nameSTRINGWord Frequency Analysis
    max_wordsINT5010–200
    min_word_lengthINT31–10
    image_widthINT1920800–4096
    image_heightINT1080600–2160
    color_schemeCOMBOblue6 options: blue, green, red, purple, orange, rainbow
    exclude_common_wordsBOOLEANtrue

    Outputs (1)

    NameTypeDescription
    IMAGEIMAGE