Nodes/ComfyUI_Anytext/AnyText Sampler
ComfyUI Node

AnyText Sampler

The AnyText diffusion sampler (with attention scaling)

By zmwv823·Created 2 years ago·Updated about a year ago· 103
AnyText Sampler
  • model
  • positive
  • negative
  • latent
seed88888888
steps20
cfg9.0
strength1.00
attnx_scale1.00
eta0.0
keep_loadtrue
keep_devicetrue

This is the node that actually runs the diffusion for AnyText. The loader gets you a model, the encoder builds glyph-aware conditioning, and UL_AnyTextSampler turns that conditioning into a latent you can decode into a finished image with text baked in. If you're doing multilingual visual text on an SD 1.5 base, this is the sampler you end on.

It's not a normal KSampler. AnyText runs its own pipeline - the text hint feeds in as a control signal, so this sampler exposes a couple of knobs a stock KSampler doesn't have, and it wants a higher CFG than you're used to on SD 1.5.

How it works

AnyText is, under the hood, a diffusion model with an auxiliary latent module that carries the glyph and position information and a text-embedding module that encodes strokes. UL_AnyTextSampler takes the positive and negative conditioning from UL_AnyTextEncoder - which already has the glyph hint folded in - plus your AnyText_Model, and denoises against both the scene prompt and the text control. The strength knob is essentially how hard the text control pushes, exactly like a ControlNet weight. Out comes a LATENT.

The inputs and outputs that matter

  • model (AnyText_Model), positive and negative (CONDITIONING) - the three wires that must come from the AnyText loader and encoder. Don't try to feed this ordinary CLIP conditioning; it expects AnyText's glyph-aware format.
  • cfg (default 9) - noticeably higher than the 6–7 you'd use elsewhere on SD 1.5. AnyText leans on strong guidance to keep the letters crisp. Drop it and the text gets mushy; crank it too far and the background fries.
  • strength (default 1, range 0–2) - how strongly the text hint is enforced. Lower it if the text looks pasted-on and unnatural; raise it if the model is ignoring your words.
  • attnx_scale (default 1) - the attention-scale knob that this variant adds over the plainer UL_AnyText_Sampler. It scales the text-region attention; leave it at 1 unless you're chasing a specific artifact.
  • steps (20), seed, eta behave as you'd expect.

The single output is latent (LATENT) - send it to a VAE Decode (use the VAE the AnyText loader handed you) to get your image.

How to install it

ComfyUI Manager, search ComfyUI_Anytext, or:

cd ComfyUI/custom_nodes
git clone https://github.com/zmwv823/ComfyUI_Anytext

then restart. The sampler itself is light; the setup cost is the AnyText models. Grab either the full AnyText checkpoint (Sanster/AnyText, pytorch_model.fp16.safetensors, or the ModelScope anytext_v1.1.ckpt) or an SD 1.5 checkpoint plus the AnyText control model (control_sd15_anytext_v1_1.safetensors from the author's HuggingFace). You also need a base font in ComfyUI/models/fonts.

Common issues & troubleshooting

The UL_AnyTextSampler vs UL_AnyText_Sampler confusion. The pack ships two AnyText samplers. This one (UL_AnyTextSampler) has the extra attnx_scale input; the underscore-named UL_AnyText_Sampler is the plainer version without it. They're otherwise the same job - pick either, and if you don't care about attention scaling, it doesn't matter which.

Text comes out blurry or wrong. Almost always CFG too low or strength too low. AnyText wants that CFG 9. Also re-check the font_hint preview from the encoder - if the glyphs were wrong going in, no sampler setting saves them.

OOM on a small GPU. The AnyText pipeline plus SD 1.5 is not huge, but keep_model_loaded and keep_model_device hold weights resident between runs. Flip them off if you're tight on VRAM and juggling other models.

Set expectations. This is SD 1.5-era tech from 2023. It's genuinely good at CJK text and at editing text in existing images - that's the reason it still exists - but for plain English rendering, modern base models spell better with zero of this scaffolding.

CategoryUL Group/Image Generation

Inputs (11)

NameTypeDefaultDescription
modelAnyText_Model
positiveCONDITIONING
negativeCONDITIONING
seedINT888888880–18446744073709550000
stepsINT201–100
cfgFLOAT9.01–99
strengthFLOAT1.000–2
attnx_scaleFLOAT1.000–2
etaFLOAT0.00–1
keep_loadBOOLEANtrueWarning: do not delete model unless this node no longer needed, it will try release device_memory and ram. if checked and want to continue node generation, use ComfyUI-Manager `Free model and node cache` to reset node state or change parameter in Loader node to activate. 注意:仅在这个节点不再需要时删除模型,将尽量释放系统内存和设备专用内存。如果删除后想继续使用此节点,使用ComfyUI-Manager插件的`Free model and node cache`重置节点状态或者更换模型加载节点的参数来激活。
keep_deviceBOOLEANtrueKeep model in comfy_auto_unet_offload_device (HIGH_VRAM: device, Others: cpu) or device_memory after generation. 生图完成后,模型转移到comfy自动unet选择设备(HIGH_VRAM: device, 其他: cpu)或者保留在设备专用内存上。

Outputs (1)

NameTypeDescription
latentLATENT