Citron Anima LoRA Trainer

Train a custom anime LoRA on the ANIMA base model with Citron's local Gradio trainer (kohya sd-scripts), <6GB VRAM, character/style LoRAs.

How to install

How to install

  1. Setup differs for this server — follow the Installation part of the README below.
  2. Claude Code: claude mcp add <name> -- <command>.
  3. Claude Desktop / Cursor: add it under mcpServers in the MCP config file.
Claude Code — installs the whole folder, not just SKILL.md
npx degit artokun/comfyui-mcp/plugin/skills/anima-lora-trainer#main ~/.claude/skills/anima-lora-trainer

For one project only, change the path to .claude/skills/anima-lora-trainer. This skill also uses app.py, requirements.txt, CITRON_ANIMA_LORA_TRAINER-RUNPOD-V2.sh, 001.txt, 002.txt, accelerate_gpu.yaml — copying SKILL.md alone won't be enough. See the folder on GitHub.

This one runs on your machine and can reach your files. Read the README below before you connect it.

Not working?
  • Check which app you pasted it into — the steps above name the right one.
  • Some skills need the paid tier of Claude or ChatGPT.
Step-by-step guide with screenshots · Ask in the forum

Paste into Claude, ChatGPT or Cursor.

Show the full text168 lines
anima-lora-trainer/SKILL.md168 lines8.7 KBpushed 27d agoRawView on GitHub

Citron Anima LoRA Trainer

Overview

Citron's Anima LoRA Trainer (app.py, titled "Citron's Anima LoRA Trainer" in the UI) is a local Gradio UI for training LoRA adapters on the Anima diffusion model using kohya-ss/sd-scripts. It trains on ~6GB VRAM with the default settings, the same low-VRAM profile as Anima generation.

  • Created by Citron Legacy; UI repo: https://github.com/citronlegacy/citron-anima-lora-trainer-ui. The Aitrepreneur adaptive installers clone the fork https://github.com/aitrepreneur/citron-anima-lora-trainer-ui.
  • Training backend: kohya-ss/sd-scripts (https://github.com/kohya-ss/sd-scripts), launched via accelerate launch.
  • Trains LoRAs for Anima DiT (Cosmos-2B). Uses Anima's own components: DiT weights + Qwen3-0.6B text encoder + Qwen-Image VAE.
  • Output: a standard .safetensors LoRA usable directly in the anima-base ComfyUI workflow.

The network module is networks.lora_anima and the training script is sd-scripts/anima_train_network.py (an Anima-specific kohya script the installer expects). Confirm these exist after the installer's git clone of sd-scripts. app.py references them, but they are pulled from the upstream repo at install time.

Setup

Windows

Run CITRON_ANIMA_LORA_TRAINER-V2.bat. It:

  1. Ensures Git and Python 3.10 are present (via winget if missing).
  2. Detects the NVIDIA GPU/driver and picks a matching PyTorch CUDA wheel automatically:
    • Blackwell (RTX 50xx) → cu128, bf16
    • Modern (RTX 20/30/40, etc.) → cu128/cu126/cu118 by driver, bf16 (fp16 on Turing)
    • Pascal/Maxwell (GTX 10/9xx) → cu126/cu118, fp16
    • Kepler/older → unsupported
  3. Clones the UI repo, patches app.py defaults (base_modelanima-preview3-base, mixed_precision → detected value), writes app_configs/accelerate_gpu.yaml.
  4. Creates .venv, installs PyTorch, clones and installs sd-scripts, installs app requirements.txt.
  5. Downloads models into models/anima/{dit,text_encoder,vae}/ from https://huggingface.co/circlestone-labs/Anima/resolve/main/split_files/...:
    • dit/anima-base-v1.0.safetensors (~4GB)
    • text_encoder/qwen_3_06b_base.safetensors (~1.19GB)
    • vae/qwen_image_vae.safetensors (~254MB)
  6. Writes and launches run_anima_base_windows.bat.

RunPod / Linux

Run CITRON_ANIMA_LORA_TRAINER-RUNPOD-V2.sh. Same flow into /workspace/citron-anima-lora-trainer-ui; it patches server_name to 0.0.0.0. Expose HTTP port 7860 and open Connect → HTTP Service 7860 (or https://${RUNPOD_POD_ID}-7860.proxy.runpod.net).

Launch

app.py runs Gradio on 0.0.0.0:7860, so open http://127.0.0.1:7860. Re-launch later with run_anima_base_windows.bat (Win) or ./run_anima_base_runpod.sh (RunPod). The DiT base model auto-downloads on the first "Start Training" if not already present (uses wget).

Dataset preparation

A flat folder of images, each with a matching .txt caption of the same basename (image-side captioning, kohya style):

my_dataset/
  001.png      001.txt
  002.jpg      002.txt
  ...
  • Accepted images: .jpg .jpeg .png .webp .bmp .gif.
  • Captions are Danbooru-style tags / natural language (same prompt style as Anima generation). The trainer warns about any image missing a .txt.
  • caption_extension = .txt; shuffle_caption = false; caption_dropout_rate default 0.1 (set per dataset).

The UI tab "Training" takes Image Directory (the flat folder above) and Output Directory (where the LoRA is saved). "Configure Training" validates the dataset, prints a step estimate (steps_per_epoch = ceil(images × repeats / (batch × grad_accum)), total = spe × epochs), then writes two TOMLs into configs/.

Key training parameters (defaults from app.py)

Basic

Param Default Notes
project_name my_lora also the output_name of the LoRA
base_model anima-base-v1.0 dropdown: anima-preview, anima-preview2, anima-preview3-base, anima-base-v1.0 (installer patches default to anima-preview3-base)
network_dim 32 LoRA rank
network_alpha 32
learning_rate 1e-4
max_train_epochs 10
resolution 768 px; dataset bucketing 256–4096, step 64
repeats 10 per-image repeats
caption_dropout 0.1

Advanced

Param Default Notes
optimizer_type AdamW8bit choices: AdamW8bit, AdamW, Lion, SGD, Prodigy; optimizer_args = ["weight_decay=0.1", "betas=[0.9, 0.99]"]
lr_scheduler cosine_with_restarts + cosine, linear, constant, constant_with_warmup, polynomial
lr_scheduler_num_cycles 1
lr_warmup_steps 100
train_batch_size 1
gradient_accumulation_steps 1
max_grad_norm 1.0
save_every_n_epochs 1
save_last_n_epochs 4 keep last N checkpoints
mixed_precision bf16 installer overrides to fp16 on older GPUs
gradient_checkpointing true memory saver
seed 42
noise_offset 0.03
multires_noise_discount 0.3
timestep_sampling sigmoid + uniform, logit_normal
discrete_flow_shift 1.0 flow-matching shift
cache_latents true
cache_text_encoder_outputs true
vae_chunk_size 64
vae_disable_cache true
num_cpu_threads_per_process 1

Fixed in the generated training TOML (not exposed): network_module = networks.lora_anima, network_train_unet_only = true, qwen3_max_token_length = 512, t5_max_token_length = 512, save_model_as = safetensors, save_precision = bf16 (fp16 on older GPUs).

Generated config files

configs/<project>_training_<timestamp>.toml references the DiT (pretrained_model_name_or_path), qwen3 text encoder, and vae paths from models/anima/, plus all params above.

configs/<project>_dataset_<timestamp>.toml:

[general]
resolution = 768
enable_bucket = true
bucket_no_upscale = false
bucket_reso_steps = 64
min_bucket_reso = 256
max_bucket_reso = 4096

[[datasets]]
resolution = 768
[[datasets.subsets]]
num_repeats = 10
image_dir = "/path/to/my_dataset"
caption_extension = ".txt"
caption_dropout_rate = 0.1

The sd-scripts command

"Start Training" runs the following and streams logs live to the UI and to logs/<project>_<timestamp>.log:

accelerate launch \
  --config_file app_configs/accelerate_gpu.yaml \
  --num_cpu_threads_per_process 1 \
  --gpu_ids 0 \
  sd-scripts/anima_train_network.py \
  --config_file  configs/<project>_training_<timestamp>.toml \
  --dataset_config configs/<project>_dataset_<timestamp>.toml

accelerate_gpu.yaml pins use_cpu: false, mixed_precision: <bf16|fp16>, single process/machine. CUDA_VISIBLE_DEVICES is set to the selected GPU index.

Output & using the LoRA

  • The trained LoRA is saved to your Output Directory as <project_name>.safetensors, plus per-epoch checkpoints (the last save_last_n_epochs are kept).
  • Copy it into ComfyUI models/loras/ and load it in the anima-base workflow via LoraLoaderModelOnly (or rgthree Power Lora Loader):
    { "class_type": "LoraLoaderModelOnly",
      "inputs": { "model": ["<unet>", 0], "lora_name": "<project_name>.safetensors", "strength_model": 1.0 } }
    
  • Use the same prompt style you captioned with. Typical strength 0.7 to 1.0; stack with the turbo LoRA for fast 12-step generation.

VRAM & tips

  • Defaults train on ~6GB VRAM (network_dim 32, res 768, batch 1, gradient checkpointing + latent/TE caching).
  • On OOM, the trainer suggests network_dim=8 and/or resolution=512. Also keep batch 1 and use AdamW8bit.
  • A GTX 1060 6GB works but is slow; 3GB cards are not realistic. GPUs older than Pascal are unsupported.
  • Step count rule of thumb: images × repeats × epochs / (batch × grad_accum). The UI prints the exact estimate before you train.
  • Logs stream to the UI and logs/. Training config and last paths persist in config.json so you can re-run.

Unverified / verify before relying

  • sd-scripts/anima_train_network.py and networks.lora_anima come from the kohya fork pulled at install time. app.py expects them, but they are not in the local downloaded files here.
  • The exact LoRA output filename is <project_name>.safetensors per output_name; confirm in your Output Directory after a run.

Sources

1---
2name: anima-lora-trainer
3description: Train a custom anime LoRA on the ANIMA base model with Citron's local Gradio trainer (kohya sd-scripts), <6GB VRAM, character/style LoRAs; covers setup, dataset prep, training params, and using the result in the anima-base workflow
4globs:
5 - "**/*.py"
6 - "**/*.toml"
7 - "**/*.json"
8---
9 
10# Citron Anima LoRA Trainer
11 
12## Overview
13 
14Citron's Anima LoRA Trainer (`app.py`, titled "Citron's Anima LoRA Trainer" in the UI) is a local Gradio UI for training LoRA adapters on the Anima diffusion model using kohya-ss/sd-scripts. It trains on ~6GB VRAM with the default settings, the same low-VRAM profile as Anima generation.
15 
16- Created by Citron Legacy; UI repo: `https://github.com/citronlegacy/citron-anima-lora-trainer-ui`. The Aitrepreneur adaptive installers clone the fork `https://github.com/aitrepreneur/citron-anima-lora-trainer-ui`.
17- Training backend: `kohya-ss/sd-scripts` (`https://github.com/kohya-ss/sd-scripts`), launched via `accelerate launch`.
18- Trains LoRAs for Anima DiT (Cosmos-2B). Uses Anima's own components: DiT weights + Qwen3-0.6B text encoder + Qwen-Image VAE.
19- Output: a standard `.safetensors` LoRA usable directly in the anima-base ComfyUI workflow.
20 
21> The network module is `networks.lora_anima` and the training script is `sd-scripts/anima_train_network.py` (an Anima-specific kohya script the installer expects). Confirm these exist after the installer's `git clone` of sd-scripts. `app.py` references them, but they are pulled from the upstream repo at install time.
22 
23## Setup
24 
25### Windows
26Run `CITRON_ANIMA_LORA_TRAINER-V2.bat`. It:
271. Ensures Git and Python 3.10 are present (via winget if missing).
282. Detects the NVIDIA GPU/driver and picks a matching PyTorch CUDA wheel automatically:
29 - Blackwell (RTX 50xx) → cu128, bf16
30 - Modern (RTX 20/30/40, etc.) → cu128/cu126/cu118 by driver, bf16 (fp16 on Turing)
31 - Pascal/Maxwell (GTX 10/9xx) → cu126/cu118, fp16
32 - Kepler/older → unsupported
333. Clones the UI repo, patches `app.py` defaults (`base_model``anima-preview3-base`, `mixed_precision` → detected value), writes `app_configs/accelerate_gpu.yaml`.
344. Creates `.venv`, installs PyTorch, clones and installs `sd-scripts`, installs app `requirements.txt`.
355. Downloads models into `models/anima/{dit,text_encoder,vae}/` from `https://huggingface.co/circlestone-labs/Anima/resolve/main/split_files/...`:
36 - `dit/anima-base-v1.0.safetensors` (~4GB)
37 - `text_encoder/qwen_3_06b_base.safetensors` (~1.19GB)
38 - `vae/qwen_image_vae.safetensors` (~254MB)
396. Writes and launches `run_anima_base_windows.bat`.
40 
41### RunPod / Linux
42Run `CITRON_ANIMA_LORA_TRAINER-RUNPOD-V2.sh`. Same flow into `/workspace/citron-anima-lora-trainer-ui`; it patches `server_name` to `0.0.0.0`. Expose HTTP port 7860 and open `Connect → HTTP Service 7860` (or `https://${RUNPOD_POD_ID}-7860.proxy.runpod.net`).
43 
44### Launch
45`app.py` runs Gradio on `0.0.0.0:7860`, so open http://127.0.0.1:7860. Re-launch later with `run_anima_base_windows.bat` (Win) or `./run_anima_base_runpod.sh` (RunPod). The DiT base model auto-downloads on the first "Start Training" if not already present (uses `wget`).
46 
47## Dataset preparation
48 
49A flat folder of images, each with a matching `.txt` caption of the same basename (image-side captioning, kohya style):
50```
51my_dataset/
52 001.png 001.txt
53 002.jpg 002.txt
54 ...
55```
56- Accepted images: `.jpg .jpeg .png .webp .bmp .gif`.
57- Captions are Danbooru-style tags / natural language (same prompt style as Anima generation). The trainer warns about any image missing a `.txt`.
58- `caption_extension = .txt`; `shuffle_caption = false`; `caption_dropout_rate` default `0.1` (set per dataset).
59 
60The UI tab "Training" takes Image Directory (the flat folder above) and Output Directory (where the LoRA is saved). "Configure Training" validates the dataset, prints a step estimate (`steps_per_epoch = ceil(images × repeats / (batch × grad_accum))`, `total = spe × epochs`), then writes two TOMLs into `configs/`.
61 
62## Key training parameters (defaults from `app.py`)
63 
64### Basic
65| Param | Default | Notes |
66|-------|---------|-------|
67| project_name | `my_lora` | also the `output_name` of the LoRA |
68| base_model | `anima-base-v1.0` | dropdown: `anima-preview`, `anima-preview2`, `anima-preview3-base`, `anima-base-v1.0` (installer patches default to `anima-preview3-base`) |
69| network_dim | `32` | LoRA rank |
70| network_alpha | `32` | |
71| learning_rate | `1e-4` | |
72| max_train_epochs | `10` | |
73| resolution | `768` | px; dataset bucketing 256–4096, step 64 |
74| repeats | `10` | per-image repeats |
75| caption_dropout | `0.1` | |
76 
77### Advanced
78| Param | Default | Notes |
79|-------|---------|-------|
80| optimizer_type | `AdamW8bit` | choices: AdamW8bit, AdamW, Lion, SGD, Prodigy; `optimizer_args = ["weight_decay=0.1", "betas=[0.9, 0.99]"]` |
81| lr_scheduler | `cosine_with_restarts` | + cosine, linear, constant, constant_with_warmup, polynomial |
82| lr_scheduler_num_cycles | `1` | |
83| lr_warmup_steps | `100` | |
84| train_batch_size | `1` | |
85| gradient_accumulation_steps | `1` | |
86| max_grad_norm | `1.0` | |
87| save_every_n_epochs | `1` | |
88| save_last_n_epochs | `4` | keep last N checkpoints |
89| mixed_precision | `bf16` | installer overrides to fp16 on older GPUs |
90| gradient_checkpointing | `true` | memory saver |
91| seed | `42` | |
92| noise_offset | `0.03` | |
93| multires_noise_discount | `0.3` | |
94| timestep_sampling | `sigmoid` | + uniform, logit_normal |
95| discrete_flow_shift | `1.0` | flow-matching shift |
96| cache_latents | `true` | |
97| cache_text_encoder_outputs | `true` | |
98| vae_chunk_size | `64` | |
99| vae_disable_cache | `true` | |
100| num_cpu_threads_per_process | `1` | |
101 
102Fixed in the generated training TOML (not exposed): `network_module = networks.lora_anima`, `network_train_unet_only = true`, `qwen3_max_token_length = 512`, `t5_max_token_length = 512`, `save_model_as = safetensors`, `save_precision = bf16` (fp16 on older GPUs).
103 
104## Generated config files
105 
106`configs/<project>_training_<timestamp>.toml` references the DiT (`pretrained_model_name_or_path`), `qwen3` text encoder, and `vae` paths from `models/anima/`, plus all params above.
107 
108`configs/<project>_dataset_<timestamp>.toml`:
109```toml
110[general]
111resolution = 768
112enable_bucket = true
113bucket_no_upscale = false
114bucket_reso_steps = 64
115min_bucket_reso = 256
116max_bucket_reso = 4096
117 
118[[datasets]]
119resolution = 768
120[[datasets.subsets]]
121num_repeats = 10
122image_dir = "/path/to/my_dataset"
123caption_extension = ".txt"
124caption_dropout_rate = 0.1
125```
126 
127## The sd-scripts command
128 
129"Start Training" runs the following and streams logs live to the UI and to `logs/<project>_<timestamp>.log`:
130```bash
131accelerate launch \
132 --config_file app_configs/accelerate_gpu.yaml \
133 --num_cpu_threads_per_process 1 \
134 --gpu_ids 0 \
135 sd-scripts/anima_train_network.py \
136 --config_file configs/<project>_training_<timestamp>.toml \
137 --dataset_config configs/<project>_dataset_<timestamp>.toml
138```
139`accelerate_gpu.yaml` pins `use_cpu: false`, `mixed_precision: <bf16|fp16>`, single process/machine. `CUDA_VISIBLE_DEVICES` is set to the selected GPU index.
140 
141## Output & using the LoRA
142 
143- The trained LoRA is saved to your Output Directory as `<project_name>.safetensors`, plus per-epoch checkpoints (the last `save_last_n_epochs` are kept).
144- Copy it into ComfyUI `models/loras/` and load it in the anima-base workflow via `LoraLoaderModelOnly` (or rgthree `Power Lora Loader`):
145 ```json
146 { "class_type": "LoraLoaderModelOnly",
147 "inputs": { "model": ["<unet>", 0], "lora_name": "<project_name>.safetensors", "strength_model": 1.0 } }
148 ```
149- Use the same prompt style you captioned with. Typical strength 0.7 to 1.0; stack with the turbo LoRA for fast 12-step generation.
150 
151## VRAM & tips
152 
153- Defaults train on ~6GB VRAM (network_dim 32, res 768, batch 1, gradient checkpointing + latent/TE caching).
154- On OOM, the trainer suggests `network_dim=8` and/or `resolution=512`. Also keep batch 1 and use AdamW8bit.
155- A GTX 1060 6GB works but is slow; 3GB cards are not realistic. GPUs older than Pascal are unsupported.
156- Step count rule of thumb: `images × repeats × epochs / (batch × grad_accum)`. The UI prints the exact estimate before you train.
157- Logs stream to the UI and `logs/`. Training config and last paths persist in `config.json` so you can re-run.
158 
159## Unverified / verify before relying
160 
161- `sd-scripts/anima_train_network.py` and `networks.lora_anima` come from the kohya fork pulled at install time. `app.py` expects them, but they are not in the local downloaded files here.
162- The exact LoRA output filename is `<project_name>.safetensors` per `output_name`; confirm in your Output Directory after a run.
163 
164## Sources
165 
166- **Official:** https://github.com/citronlegacy/citron-anima-lora-trainer-ui and https://github.com/kohya-ss/sd-scripts
167- **Empirical:** installer/launch notes from the pack scripts; training defaults from the UI's app.py as observed.
168 

Discussion

Alternatives

Also in Illustration & art