Nodes/ComfyUI-AnimaFastTrain/AnimaFastTrain - Train Context Tokens
ComfyUI Node

AnimaFastTrain - Train Context Tokens

Train Anima reference tokens in memory, one image at a time

By quinteroac·Created 3 months ago·Updated 3 months ago· 27
AnimaFastTrain - Train Context Tokens
  • model
  • clip
  • vae
  • reference_image
  • reference_image_2
  • reference_image_3
  • context
  • info
training_promptmasterpiece, best quality, score_7, safe, same character, solo, clean white background, clean anime illustration
seed0
training_steps80
learning_rate0.020
training_image_size512
num_tokens16
init_std0.020
training_dtypebf16

Anima is the anime base everyone actually switched to, but it has the same old character-consistency tax every base has: you want the same face in a new pose, and the answer is usually "train a LoRA." That's ~1800 steps and a dataset even for a 2B model. This node is the shortcut: give it one reference image and it trains tiny per-block context tokens in memory - no safetensors, no cache, no file on disk - in about 80 steps. It's experimental, it has rough edges, and for a quick identity experiment it beats setting up a whole training run by a mile.

What it actually does

AnimaFastTrain - Train Context Tokens takes your Anima model, CLIP, VAE, and a reference image, and optimizes a small set of learnable tokens that get injected into the model's cross-attention during sampling. Think of it as a micro-LoRA that lives entirely in latent space: it encodes "this is what the character looks like" into 16 tokens per block, for Anima's 28 blocks, and it lasts exactly as long as your workflow session does.

The mechanism, from the source: your reference image gets VAE-encoded into latents, and the tokens are initialized with noise seeded from a hash of the image itself. Then a ComfyUI TrainGuider loop runs AdamW over the tokens, trying to make the denoiser reconstruct the reference latents - with the tokens injected at strength 1.0 during training. Runtime strength is your problem to set later on the patch node. It reuses ComfyUI's own training infrastructure, so it needs a reasonably current ComfyUI, but it needs zero extra Python packages and zero model downloads - the pack ships no weights.

The inputs that matter

Most of these have sane defaults; you'll touch maybe four of them:

  • model, clip, vae - your Anima checkpoint and its encoder/VAE, loaded normally.
  • reference_image - the thing you're teaching it. A face-dominant crop gives noticeably better identity, which is worth repeating because it's the single most common mistake.
  • training_prompt - describes the reference image. The default is Anima's recommended prefix (masterpiece, best quality, score_7, safe, same character, ...); it tells the model what it's looking at so the tokens learn "who" instead of "what."
  • training_steps (80) and learning_rate (0.02) - the training dials. Identity too weak? More steps or a slightly higher LR. Learning the pose instead of the face? The author admits the tokens learn pose and composition too, so back these off.
  • num_tokens (16) - capacity per block. More tokens, more detail, more VRAM.
  • seed - fixed by default, and worth keeping fixed so a training run is reproducible.

Optional reference_image_2 and reference_image_3 let you train on up to three references at once, batched together - handy when one image doesn't cover the character.

Outputs: context (ANIMA_REFERENCE_CONTEXT, which feeds the Patch Model node) and info (a STRING with the training summary - final loss, token norms - drop it on a text node to watch).

Install

ComfyUI Manager → Custom Nodes Manager → search ComfyUI-AnimaFastTrain, or:

cd ComfyUI/custom_nodes
git clone https://github.com/quinteroac/ComfyUI-AnimaFastTrain.git

Restart ComfyUI and you'll find the nodes under Anima/AnimaFastTrain. That's it - no extra pip packages, no separate model files. You still need the Anima checkpoint itself.

Where people get burned

VRAM. The whole model is loaded for training, and the author isn't sure anything under 12GB handles it (his words, in the r/comfyui release thread). Anima infers fine on 6GB; training is another story.

It isn't pure identity. The tokens learn the pose, the lighting, the whole composition - so the reference crop matters, and you trade a bit of fidelity for the convenience. This is a character-consistency experiment, not a LoRA replacement for production work. If you need the same character hundreds of times, train the real thing; this node is for iterating now.

It's memory-only. Close the workflow and the context is gone - there's no weight file to reuse, by design. The flip side is that nothing pollutes your disk or your LoRA folder.

CategoryAnima/AnimaFastTrain

Inputs (14)

NameTypeDefaultDescription
modelMODEL
clipCLIP
vaeVAE
reference_imageIMAGE
training_promptSTRINGmasterpiece, best quality, score_7, safe, same character, solo, clean white background, clean anime illustration
seedINT00–18446744073709550000
training_stepsINT801–10000
learning_rateFLOAT0.0200.000001–1
training_image_sizeINT5120–2048
num_tokensINT161–256
init_stdFLOAT0.0200–1
training_dtypeCOMBObf163 options: bf16, fp16, fp32
reference_image_2optIMAGE
reference_image_3optIMAGE

Outputs (2)

NameTypeDescription
contextANIMA_REFERENCE_CONTEXT
infoSTRING