Anime PromptGen
A tiny GPT-2 that writes your danbooru prompts for you
- prompts
- first_prompt
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 to1girl, 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--1for random; set a value to reproduce a batch.dtype(float32/float16/bfloat16) anddevice(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.
Inputs (17)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | 1girl, genshin | — |
| model_id_or_path | STRING | FredZhang7/anime-anything-promptgen-v2 | — |
| tokenizer_id_or_path | STRING | distilgpt2 | — |
| gguf_model | COMBO | none | 1 options: none |
| gguf_file_path | STRING | — | |
| max_length | INT | 761–4096 | — |
| num_return_sequences | INT | 101–64 | — |
| do_sample | BOOLEAN | true | — |
| repetition_penalty | FLOAT | 1.200.01–10 | — |
| temperature | FLOAT | 0.700.01–5 | — |
| top_k | INT | 40–1000 | — |
| early_stopping | BOOLEAN | true | — |
| seedopt | INT | -1-1–18446744073709550000 | — |
| dtypeopt | COMBO | float32 | 3 options: float32, float16, bfloat16 |
| deviceopt | COMBO | auto | 3 options: auto, cpu, cuda |
| local_files_onlyopt | BOOLEAN | false | — |
| strip_input_promptopt | BOOLEAN | false | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| prompts | STRING | — |
| first_prompt | STRING | — |