Nodes/ComfyUI-PepeUtils/Anime PromptGen
ComfyUI Node

Anime PromptGen

A tiny GPT-2 that writes your danbooru prompts for you

By Pepehoschi·Created 5 months ago·Updated 12 days ago· 0
Anime PromptGen
    • prompts
    • first_prompt
    prompt1girl, genshin
    model_id_or_pathFredZhang7/anime-anything-promptgen-v2
    tokenizer_id_or_pathdistilgpt2
    gguf_modelnone
    gguf_file_path
    max_length76
    num_return_sequences10
    do_sampletrue
    repetition_penalty1.20
    temperature0.70
    top_k4
    early_stoppingtrue
    seed-1
    dtypefloat32
    deviceauto
    local_files_onlyfalse
    strip_input_promptfalse

    The hardest part of an anime workflow is often the blank page. You want a girl in a school uniform on a rainy street and all you can type is "1girl, genshin." Anime PromptGen is a text node that fixes that: you give it a seed phrase and it rolls you a batch of finished, danbooru-style prompts from a small GPT-2 that was fine-tuned to talk in tags.

    If you came from the A1111 world, this is the same trick as the old "Magic Prompt" / promptgen extensions - a language model that autocompletes booru tags - now living inside ComfyUI as a utils/text node. It doesn't generate an image, call an API, or need a key. It just writes text, and you wire that text into your CLIP Text Encode. Treat it as a scratchpad, not an oracle: the output is usually 80% usable and worth a minute of editing before you hit Queue.

    How it works

    Under the hood it wraps the Hugging Face text-generation pipeline. By default it pulls FredZhang7/anime-anything-promptgen-v2, a small GPT-2 fine-tuned on Danbooru-style tags, with a distilgpt2 tokenizer. The model downloads from Hugging Face on first run, gets cached, and the pipeline is loaded once and reused (the source caches it, so your fifth generation doesn't reload the weights).

    Two ways to feed it a model. The boring way: leave model_id_or_path alone and let it grab the default from HF. The interesting way: pick a compatible local .gguf from the gguf_model dropdown or paste an absolute path into gguf_file_path. The node registers the gguf, llm_gguf, and LLM/GGUF folders under your ComfyUI/models dir, so anything you drop there shows up in the dropdown. One honest caveat: Transformers dequantizes GGUF files back into PyTorch weights, so your VRAM/RAM usage tracks the dtype you chose, not the small file size the quant promised.

    The inputs that matter

    • prompt - your seed. Multi-line, defaults to 1girl, genshin. The model expands from here, so lead with the subject and a franchise/style if you have one.
    • num_return_sequences (default 10) - how many prompt variants you want per run. More is more chances, but more token budget too.
    • temperature (0.7), top_k (4), repetition_penalty (1.2) - the sampling dials. Crank temperature for wilder, more novel output; raise repetition penalty if it starts chanting one tag.
    • seed - -1 for random; set a value to reproduce a batch.
    • dtype (float32/float16/bfloat16) and device (auto/cpu/cuda) - you can run this entirely on CPU without pain; it's a small GPT-2-class model.
    • local_files_only - force no network. More on that below.
    • gguf_model / gguf_file_path - the local GGUF path.

    The outputs are prompts (all sequences, newline-joined, comma-cleaned) and first_prompt (the first one). Wire first_prompt into a CLIP Text Encode when you only want one; dump prompts into a Show Text node to browse the batch.

    Installing it

    AnimePromptGen ships in Pepehoschi/ComfyUI-PepeUtils (GPL-3.0). Install via ComfyUI Manager (search "ComfyUI-PepeUtils") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Pepehoschi/ComfyUI-PepeUtils
    

    Then restart ComfyUI. The pack itself only needs torch/numpy/Pillow, which ComfyUI already has - but this node additionally needs transformers, and gguf if you load .gguf files:

    pip install transformers gguf
    

    Where people get burned

    The first run downloads the model from Hugging Face, so expect a wait and an internet connection. If you're seeing requests to mirrors like hf-mirror.com, another custom node changed your HF hub settings; flip on local_files_only or point tokenizer_id_or_path at a local tokenizer folder. And with a local GGUF, the tokenizer won't always be in the file - put tokenizer.json (or the vocab files) next to the GGUF, or set tokenizer_id_or_path yourself, or the node errors out with a "could not load a tokenizer locally" message.

    The output will sometimes be glorious and sometimes tag soup. That's the nature of a GPT-2 trained to guess the next booru tag. Generate ten, pick one, edit - it's a prompt writer, not a prompt finisher.

    Categoryutils/text

    Inputs (17)

    NameTypeDefaultDescription
    promptSTRING1girl, genshin
    model_id_or_pathSTRINGFredZhang7/anime-anything-promptgen-v2
    tokenizer_id_or_pathSTRINGdistilgpt2
    gguf_modelCOMBOnone1 options: none
    gguf_file_pathSTRING
    max_lengthINT761–4096
    num_return_sequencesINT101–64
    do_sampleBOOLEANtrue
    repetition_penaltyFLOAT1.200.01–10
    temperatureFLOAT0.700.01–5
    top_kINT40–1000
    early_stoppingBOOLEANtrue
    seedoptINT-1-1–18446744073709550000
    dtypeoptCOMBOfloat323 options: float32, float16, bfloat16
    deviceoptCOMBOauto3 options: auto, cpu, cuda
    local_files_onlyoptBOOLEANfalse
    strip_input_promptoptBOOLEANfalse

    Outputs (2)

    NameTypeDescription
    promptsSTRING
    first_promptSTRING