New: Earn 20% as an AgentAlley affiliate. Share your link and earn on every sale you refer. Join now New: Earn 20% as an affiliate. Join now

Train a character/identity LoRA locally on FLUX.1-dev

Train a Character LoRA (local, Flux.1-dev)

by artokun · MIT license · ★ 759 on GitHub · updated Sep 21

Train a Character LoRA (local, Flux.1-dev) cover

Train a character/identity LoRA locally on FLUX.1-dev via the comfyui-mcp train_* tools (GPU Docker + ostris ai-toolkit). Use when the user wants to train a LoRA of a person/character from their photos on the local GPU.

---
name: train-character-lora
description: Train a character/identity LoRA locally on FLUX.1-dev via the comfyui-mcp train_* tools (GPU Docker + ostris ai-toolkit). Use when the user wants to train a LoRA of a person/character from their photos on the local GPU. Covers dataset prep, launch, monitoring, and using the result in ComfyUI. For WAN/Z-Image training via the ai-toolkit UI see ai-toolkit-trainer.
globs:
  - "**/*.json"
---

# Train a Character LoRA (local, Flux.1-dev)

## Overview

The trainer runs ostris ai-toolkit's `run.py` inside a headless GPU Docker container,
driven through the three `train_*` MCP tools. You (the LLM) are the UI. Each takes
an `action`: `train_prepare_dataset` owns the datasets, `train_start` owns the jobs, and
`train_doctor` owns the trainer itself. You generate the dataset, launch the job, watch
progress, and the finished LoRA lands in ComfyUI `models/loras/` and the LoRA catalog
without further steps.

Overview

The trainer runs ostris ai-toolkit's run.py inside a headless GPU Docker container, driven through the three train_* MCP tools. You (the LLM) are the UI. Each takes an action: train_prepare_dataset owns the datasets, train_start owns the jobs, and train_doctor owns the trainer itself. You generate the dataset, launch the job, watch progress, and the finished LoRA lands in ComfyUI models/loras/ and the LoRA catalog without further steps.

Manual install (npx, ZIP)
Claude Codenpx skills add artokun/comfyui-mcp --skill train-character-lora -g -a claude-code
Claude Code (manual)mkdir -p ~/.claude/skills && curl -sL https://codeload.github.com/artokun/comfyui-mcp/tar.gz/1d5b12b1b499 \ | tar -xz -C ~/.claude/skills --strip-components=3 comfyui-mcp-1d5b12b1b499/plugin/skills/train-character-lora
Windows (PowerShell)New-Item -ItemType Directory -Force "$HOME\.claude\skills" | Out-Null; Invoke-WebRequest "https://m.agentalley.io/zip/00207f9aa3d19bfa6057/train-character-lora.zip" -OutFile "$env:TEMP\train-character-lora.zip"; Expand-Archive "$env:TEMP\train-character-lora.zip" -DestinationPath "$HOME\.claude\skills" -Force
Claude.ai / desktopDownload the ZIP and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md5.1 KB
Read the files here
artokun/1d5b12b1 file
SKILL.md
Show the full text95 lines

Train a Character LoRA (local, Flux.1-dev)

Overview

The trainer runs ostris ai-toolkit's run.py inside a headless GPU Docker container, driven through the three train_* MCP tools. You (the LLM) are the UI. Each takes an action: train_prepare_dataset owns the datasets, train_start owns the jobs, and train_doctor owns the trainer itself. You generate the dataset, launch the job, watch progress, and the finished LoRA lands in ComfyUI models/loras/ and the LoRA catalog without further steps.

  • Base model: FLUX.1-dev (the best proven character consistency; needs ~24GB VRAM with quantization, RTX 4090 class).
  • Phase-1 scope: character LoRAs only. Style/slider/edit and other bases come later.

The flow (tool sequence)

  1. train_doctor {action:"doctor"}. Preflight once per session. Checks docker daemon, --gpus all GPU passthrough, trainer image, HF_TOKEN. If image:false, run train_doctor {action:"build_image"} (one-time, several minutes, since it builds CUDA plus torch plus ai-toolkit). If hfTokenSet:false, warn the user: the first run downloads FLUX.1-dev (gated HF repo) and needs HF_TOKEN in the MCP server env.
  2. train_prepare_dataset {action:"prepare"}. Stage the images. See "Dataset" below.
  3. train_start {action:"start"}. Launch. Returns a job id at once; training runs detached.
  4. train_start {action:"status", id}. Poll progress (progress.step/totalSteps/loss, recent samples, log tail). Poll on a slow cadence (every few minutes). A 2000-step run is roughly an hour on a 4090. Don't block on it.
  5. Done. status:"completed" means the .safetensors was copied to models/loras/<name>.safetensors and upserted into the LoRA catalog (result has the paths and catalog id). Verify by loading it in a Flux workflow (LoraLoaderModelOnly, strength 1.0) with the trigger word in the prompt.

Dataset guidance

Call train_prepare_dataset {action:"prepare"} with name, items: [{path, caption?}, ...] and a defaultCaption.

  • 10 to 30 varied images of the subject: different angles, expressions, lighting, backgrounds, distances (close-up, half-body, full-body). Variety beats count.
  • Trigger word: pick something rare and stable (e.g. ohwx, zxc_person), NOT a real word. Use it as defaultCaption and pass it as trigger to train_start.
  • Captions: describe what changes between images (pose, setting, clothing, expression); the model learns the constant identity from the images themselves. Start each caption with the trigger word, e.g. ohwx person sitting in a cafe, laughing, natural light. Keep them short and factual. When in doubt, the trigger word alone (defaultCaption) is a workable baseline.
  • Images are copied and renamed img_00001.<ext> etc. Source files are never modified.

Params (sane defaults — override sparingly)

Param Default When to change
steps 2000 200 for a smoke test; 1500–3000 real runs. More ≠ better (overbake = plasticky).
lr 1e-4 5e-5 for a tighter/subtler identity.
rank 16 32 for very detailed characters.
resolution [512,768,1024] [512] if VRAM-constrained.
quantize true Keep true on 24GB.
saveEvery / sampleEvery 250 Lower (100) to watch early progress.

Monitoring & judgement

  • train_start {action:"status"}'s progress.samples are host paths. Look at them. (ai-toolkit prints no saved-sample lines, so they populate at finalize from the output dir; mid-run you can look directly in the job's output/<name>/samples/ folder.) Identity should be recognizable by ~1/3 of the run; if samples stay generic past halfway, the run will likely underfit. Cancel (train_start {action:"cancel", id}) and check captions and trigger.
  • Loss should trend down and stabilize (~0.1 to 0.3); wild spikes usually mean lr too high.
  • Checkpoints save every saveEvery steps under the job's output/ dir, so a cancelled run isn't a total loss.

Failure modes

  • no_docker / no_image from train_start {action:"start"}: run train_doctor {action:"doctor"}, follow its hints.
  • OOM / CUDA errors in the log tail: drop resolution to [512], keep quantize:true, batch stays 1.
  • handoff failed in job error: training itself finished; the LoRA is still under the job's output/<name>/ dir. Copy it into models/loras/ manually and upsert the catalog.
  • First run is slow before step 1. FLUX.1-dev download (~24GB) plus latent caching. As long as the log tail moves, it's fine. The HF cache persists across runs.

Sources

  • Official: none found.
  • Empirical: sampler values, wiring, and prompt notes from working graphs in packs/ and observed renders; not a vendor prompting guide.
1---
2name: train-character-lora
3description: Train a character/identity LoRA locally on FLUX.1-dev via the comfyui-mcp train_* tools (GPU Docker + ostris ai-toolkit). Use when the user wants to train a LoRA of a person/character from their photos on the local GPU. Covers dataset prep, launch, monitoring, and using the result in ComfyUI. For WAN/Z-Image training via the ai-toolkit UI see ai-toolkit-trainer.
4globs:
5 - "**/*.json"
6---
7 
8# Train a Character LoRA (local, Flux.1-dev)
9 
10## Overview
11 
12The trainer runs ostris ai-toolkit's `run.py` inside a headless GPU Docker container,
13driven through the three `train_*` MCP tools. You (the LLM) are the UI. Each takes
14an `action`: `train_prepare_dataset` owns the datasets, `train_start` owns the jobs, and
15`train_doctor` owns the trainer itself. You generate the dataset, launch the job, watch
16progress, and the finished LoRA lands in ComfyUI `models/loras/` and the LoRA catalog
17without further steps.
18 
19- Base model: FLUX.1-dev (the best proven character consistency; needs ~24GB VRAM with
20 quantization, RTX 4090 class).
21- Phase-1 scope: character LoRAs only. Style/slider/edit and other bases come later.
22 
23## The flow (tool sequence)
24 
251. `train_doctor {action:"doctor"}`. Preflight once per session. Checks docker daemon,
26 `--gpus all` GPU passthrough, trainer image, HF_TOKEN. If `image:false`, run
27 `train_doctor {action:"build_image"}` (one-time, several minutes, since it builds CUDA
28 plus torch plus ai-toolkit). If `hfTokenSet:false`, warn the user: the first run
29 downloads FLUX.1-dev (gated HF repo) and needs `HF_TOKEN` in the MCP server env.
302. `train_prepare_dataset {action:"prepare"}`. Stage the images. See "Dataset" below.
313. `train_start {action:"start"}`. Launch. Returns a job id at once; training runs
32 detached.
334. `train_start {action:"status", id}`. Poll progress (`progress.step/totalSteps/loss`,
34 recent `samples`, `log` tail). Poll on a slow cadence (every few minutes). A 2000-step
35 run is roughly an hour on a 4090. Don't block on it.
365. Done. `status:"completed"` means the `.safetensors` was copied to
37 `models/loras/<name>.safetensors` and upserted into the LoRA catalog (`result` has the
38 paths and catalog id). Verify by loading it in a Flux workflow (`LoraLoaderModelOnly`,
39 strength 1.0) with the trigger word in the prompt.
40 
41## Dataset guidance
42 
43Call `train_prepare_dataset {action:"prepare"}` with `name`, `items: [{path, caption?}, ...]`
44and a `defaultCaption`.
45 
46- 10 to 30 varied images of the subject: different angles, expressions, lighting,
47 backgrounds, distances (close-up, half-body, full-body). Variety beats count.
48- Trigger word: pick something rare and stable (e.g. `ohwx`, `zxc_person`), NOT a
49 real word. Use it as `defaultCaption` and pass it as `trigger` to `train_start`.
50- Captions: describe what changes between images (pose, setting, clothing,
51 expression); the model learns the constant identity from the images themselves. Start
52 each caption with the trigger word, e.g. `ohwx person sitting in a cafe, laughing, natural
53 light`. Keep them short and factual. When in doubt, the trigger word alone
54 (`defaultCaption`) is a workable baseline.
55- Images are copied and renamed `img_00001.<ext>` etc. Source files are never modified.
56 
57## Params (sane defaults — override sparingly)
58 
59| Param | Default | When to change |
60|-------|---------|----------------|
61| steps | 2000 | 200 for a smoke test; 1500–3000 real runs. More ≠ better (overbake = plasticky). |
62| lr | 1e-4 | 5e-5 for a tighter/subtler identity. |
63| rank | 16 | 32 for very detailed characters. |
64| resolution | [512,768,1024] | [512] if VRAM-constrained. |
65| quantize | true | Keep true on 24GB. |
66| saveEvery / sampleEvery | 250 | Lower (100) to watch early progress. |
67 
68## Monitoring & judgement
69 
70- `train_start {action:"status"}`'s `progress.samples` are host paths. Look at them.
71 (ai-toolkit prints no saved-sample lines, so they populate at finalize from the output
72 dir; mid-run you can look directly in the job's `output/<name>/samples/` folder.)
73 Identity should be recognizable by ~1/3 of the run; if samples stay generic past
74 halfway, the run will likely underfit. Cancel (`train_start {action:"cancel", id}`) and
75 check captions and trigger.
76- Loss should trend down and stabilize (~0.1 to 0.3); wild spikes usually mean lr too high.
77- Checkpoints save every `saveEvery` steps under the job's `output/` dir, so a cancelled
78 run isn't a total loss.
79 
80## Failure modes
81 
82- `no_docker` / `no_image` from `train_start {action:"start"}`: run
83 `train_doctor {action:"doctor"}`, follow its hints.
84- OOM / CUDA errors in the log tail: drop `resolution` to `[512]`, keep `quantize:true`,
85 batch stays 1.
86- `handoff failed` in job error: training itself finished; the LoRA is still under the
87 job's `output/<name>/` dir. Copy it into `models/loras/` manually and upsert the catalog.
88- First run is slow before step 1. FLUX.1-dev download (~24GB) plus latent caching. As
89 long as the log tail moves, it's fine. The HF cache persists across runs.
90 
91## Sources
92 
93- **Official:** none found.
94- **Empirical:** sampler values, wiring, and prompt notes from working graphs in `packs/` and observed renders; not a vendor prompting guide.
95 
View all files on GitHub →

Details

Updated
Sep 21, 2026
License
MIT
Stars on the repo
★ 759
Checked
Source
artokun/comfyui-mcp ↗
Creator
artokun · 44 listings
View creator

Similar skills

See all →
SkillMake Japanese TV-anime style videos with codeAnime celedenfunf/reelmimic · by edenfunfMake Japanese TV-anime style videos (MP4) with code — cel-shaded characters with tapered line art, big detailed eyes, hair clumps with a specular band, comedic anime reactions (sweat drop, anger vein, sparkle eyes, ≥< eyes, dot eyes, tears), painted skies with cumulus clouds, school/street/classroom/rooftop sets with time-of-day palettes, speed/focus lines, impact frames, dramatic zooms, smears, sakura petals and anime subtitles (CJK). Canvas 2D rendered frame by frame in headless Chrome, encoded with ffmpeg. Use when a reference video or brief calls for anime / 動畫 / 日系動畫 / アニメ / cel-shaded / slice-of-life / school romance / shōnen-style reactions, or when the video-clone router picks the anime-cel style. 2D only; characters are original (Hina, Ren) or new ones built on the same rig.★ 3.6k GitHub starsSkillDirect and produce a short film made entirely in codeLemo opuscarlemomo-ai/lemo-opuscar · by lemomo-aiDirect and produce a short film made entirely in code, in one of the styles of the Lemo-Opuscar library (e.g. Impasto Oil Painting 油画厚涂, Watercolor Brush 水彩笔刷, Ukiyo-e 浮世绘, Satellite Briefing 卫星简报, Exploded Teardown 产品拆解, Microscope Story 显微叙事). Use when the user asks for a video, film, short, promo, explainer or animation (视频、短片、动画、宣传片) in a named style, including data, science and product explainers built from real material such as satellite imagery, laser scans, CAD files or archive scans (数据解说、科普、产品拆解); when they want a film made about their own topic and haven't chosen a style (help them choose); or when they ask which film styles there are. Not for editing or converting existing video files.★ 3k GitHub starsSkillGenerate Ian-style Xiaohei illustrations for articles, postsdzhng/skills · by dzhngGenerate Ian-style Xiaohei illustrations for articles, posts, blogs, Notion documents, workflows, methods, processes, structures, states, metaphors, and opinions. Use when the user asks for weird, hand-drawn, Xiaohei, article, editorial, body illustrations, illustration ideas, shot lists, title removal, image edits, or image regeneration. By default, all image text and annotations are English, even when the source article is Chinese; only use another language when the user explicitly asks.★ 1.3k GitHub starsSkillCreating game art through Scenario MCP: spritesScenario game assetsscenario-labs/skills · by scenario-labsUse when creating game art through Scenario MCP: sprites, sprite sheets, icons, props, loot, tilesets and autotile terrain transitions, seamless tiles, isometric buildings, top-down maps, pixel art, UI buttons and panels, parallax background layers or depth planes for side-scrollers, and character or concept art; or when assets need transparent backgrounds, background removal, style-consistent variation batches, upscaling, pixel-grid cleanup, or PNG export for Unity, Godot, or Unreal.★ 854 GitHub starsSkillTrain custom LoRAs with ostris AI-ToolkitAI-Toolkit LoRA Trainer (WAN 2.2 & Z-Image)artokun/comfyui-mcp · by artokunTrain custom LoRAs with ostris AI-Toolkit. Covers WAN 2.2/2.1 (people, styles, video motion) and Z-Image (Turbo & Base, low-VRAM image LoRAs). Use when the user wants to train a WAN or Z-Image LoRA; covers local + RunPod setup, dataset prep, key params, and using the result in a ComfyUI workflow.★ 759 GitHub starsSkillAnime/illustration text-to-imageANIMA 1.0 (Anima Base Ultra) Text-to-Image Workflowsartokun/comfyui-mcp · by artokunAnime/illustration text-to-image (ANIMA 1.0, ~2B Cosmos DiT). Use for anime, manga, illustrated characters; accepts Danbooru tags + natural language; runs/trains on <6GB VRAM; includes anime inpainting via Anima-LLLite ControlNet★ 759 GitHub stars

More from artokun

SkillTrain custom LoRAs with ostris AI-ToolkitAI-Toolkit LoRA Trainer (WAN 2.2 & Z-Image)artokun/comfyui-mcp · by artokunTrain custom LoRAs with ostris AI-Toolkit. Covers WAN 2.2/2.1 (people, styles, video motion) and Z-Image (Turbo & Base, low-VRAM image LoRAs). Use when the user wants to train a WAN or Z-Image LoRA; covers local + RunPod setup, dataset prep, key params, and using the result in a ComfyUI workflow.★ 759 GitHub starsSkillAnime/illustration text-to-imageANIMA 1.0 (Anima Base Ultra) Text-to-Image Workflowsartokun/comfyui-mcp · by artokunAnime/illustration text-to-image (ANIMA 1.0, ~2B Cosmos DiT). Use for anime, manga, illustrated characters; accepts Danbooru tags + natural language; runs/trains on <6GB VRAM; includes anime inpainting via Anima-LLLite ControlNet★ 759 GitHub starsSkillAuthoring & Publishing ComfyUI Custom Nodesartokun/comfyui-mcp · by artokunAuthoring & publishing ComfyUI custom nodes to the Comfy Registry, covering node structure, pyproject.toml spec, comfy-cli publishing, and CI★ 759 GitHub starsSkillTrain a custom anime LoRA on the ANIMA base modelCitron Anima LoRA Trainerartokun/comfyui-mcp · by artokunTrain 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★ 759 GitHub starsSkillDiscover Civitai models with the BUILT-IN downloadmodelCivitai + comfyui-mcpartokun/comfyui-mcp · by artokunDiscover Civitai models with the BUILT-IN download_model action:"search_civitai" and install/generate them locally. Find a checkpoint/LoRA/embedding on Civitai, download it into ComfyUI, and use its trigger words. Optionally pair the official Civitai MCP for community features (images browsing, posting, collections).★ 759 GitHub starsSkillDiagnose and fix video/image color OBJECTIVELYColor Correction (measure, don't eyeball)artokun/comfyui-mcp · by artokunDiagnose and fix video/image color OBJECTIVELY with the get_image (action:"analyze_color") tool (scopes/stats such as black/white points, contrast, saturation, clipping, cast) instead of eyeballing a contact sheet. Covers the "washed out" signature, why reference color-match (mkl/ColorMatch/ColorMatchAdobe) CAN'T add contrast a flat source lacks, the levels/contrast-stretch fix (core AdjustContrast / CurveEditor), the measure→fix→re-measure loop, the side-by-side sandbox pattern, and where to place the fix in a render graph (after decode, before save). Use when a render looks washed out / flat / dull / over-saturated / color-cast, or when deciding between a color-match and a contrast/levels fix.★ 759 GitHub stars