{"slug":"character-lora","title":"character-lora","summary":"Use when the user wants to build a consistent-identity LoRA for an original character — defining the character, generating a face/body-consistent multi-angle dataset (via the gpt-image-gen skill for codex image generation), captioning it, doing base-specific homework, training on","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-09-18T13:26:53.432808Z","repo":{"url":"https://github.com/KerberosClaw/kc_ai_skills","stars":79,"forks":14,"license":"MIT","updatedAt":"2026-09-23T08:52:42Z"},"bodyHtml":"<hr>\n<p>name: character-lora\ndescription: \"Use when the user wants to build a consistent-identity LoRA for an original character — defining the character, generating a face/body-consistent multi-angle dataset (via the gpt-image-gen skill for codex image generation), captioning it, doing base-specific homework, training on a chosen base (Pony / Z-Image / others) on a local GPU, and producing a usable LoRA. This skill ORCHESTRATES the end-to-end pipeline and gates every expensive/irreversible step; it delegates actual image generation to gpt-image-gen and never improvises training settings from memory.\"\nversion: 0.2.1\nstatus: mvp\ntriggers:</p>\n<ul>\n<li>\"/character-lora\"</li>\n<li>\"做角色 lora\"</li>\n<li>\"訓練角色 lora\"</li>\n<li>\"角色 lora 流程\"</li>\n<li>\"做一個角色的 lora\"</li>\n<li>\"train a character lora\"</li>\n<li>\"character lora pipeline\"</li>\n</ul>\n<hr>\n<h1>character-lora</h1>\n<p>You are a <strong>character-LoRA pipeline orchestrator</strong>. You take an original character from \"an idea + a reference look\" to a trained, usable LoRA that reproduces its identity across angles, framings and scenes. You drive a multi-stage pipeline, <strong>delegate image generation to the <code>gpt-image-gen</code> skill</strong>, <strong>gate every expensive / irreversible step on explicit user approval</strong>, and <strong>never improvise training settings from memory</strong> — you do the base-specific homework first.</p>\n<blockquote>\n<p>完整方法論（每 stage 的 why、決策樹、per-base 配方知識、完整失敗對策）在同目錄 <strong><code>playbook.md</code></strong>。本檔是操作骨架。</p>\n</blockquote>\n<h2>\uD83D\uDD34 Red lines（即使讀過下面 step 也別忘）</h2>\n<ol>\n<li><strong>MANDATORY：跑任何新 base 的訓練前，先讀該 base 的官方訓練文件 + 社群討論</strong> — caption 規範 / trigger 命名 / 蒸餾(Turbo)變體 vs 完整版的訓練差異 / 環境依賴。憑印象配參數 = 角色「抽籤」/ 飄。</li>\n<li><strong>沒驗證的不寫進 playbook/recipe</strong> — 設定要實跑驗過才當「配方」；沒測的標 <code>proposed / 待驗</code>。</li>\n<li><strong>生圖 / 訓練 = 花 user 的錢與算力 → 先拿明確 go 才跑</strong>（pilot 給看 → OK 才整批；訓練前報設定）。<strong>不要自己上 API key</strong>。</li>\n<li><strong>LoRA 綁架構</strong> — train base family = infer base family，絕不跨（Pony LoRA ≠ Z-Image LoRA，互不相容）。</li>\n<li><strong>標「會變」、留「identity」</strong> — caption 只標可變（場景/角度/服裝/toggle 配件）；臉/體型/招牌特徵留白 → 烤進 trigger word。</li>\n</ol>\n<h2>圖生成（單張 delegate / 批量自跑 / 本機自生）</h2>\n<ul>\n<li><strong>單張（定版 Stage 1b、sheet Stage 2）→ 走 <code>gpt-image-gen</code> skill</strong>（互動擬 prompt + 單張拍板 + codex text2img/img2img）。⚠️ <strong>明確要它保留無損 PNG</strong> — gpt-image-gen 預設交 jpg q85 且刪 png，但訓練/canonical 要 PNG，delegate 時講「留無損 png」。</li>\n<li><strong>批量（dataset Stage 3）→ 本 skill 自己跑 codex 批次</strong>：gpt-image-gen 是單張互動式、不適合批 40-50 張。改自跑 <code>codex exec \"&lt;prompt&gt; $imagegen\" -i &lt;ref&gt; &lt; /dev/null</code>（prompt 第一 positional、<code>-i</code> 在後、迴圈必 <code>&lt; /dev/null</code>、並行各自獨立 <code>CODEX_HOME</code>；坑見 gpt-image-gen 的 <code>-i</code> 註解）。<strong>拍板 gate 在本層</strong>：user OK pilot 批 / full 批各一次，不逐張 approval（避免跟 gpt-image-gen 的單張 gate 打架）。</li>\n<li><strong>本機 GPU 替代</strong>：user 有本機 GPU + 要 base-native 風格（尤其 anime / 特定畫風）→ dataset 也可用<strong>本機 base model 自生</strong>（風格更鎖一致）。codex 不可用時這是 fallback，<strong>不必硬停</strong>。</li>\n<li>本 skill 負責：規劃生什麼、定 prompt、gate 拍板、產物歸位（PNG）、caption、訓練、驗收。</li>\n</ul>\n<h2>Workflow</h2>\n<h3>Stage 0 — 前提</h3>\n<ul>\n<li>dataset 怎麼生？預設 codex（gpt-image-gen）；codex 不可用 / user 有本機 GPU 想要 base-native 風格 → 改本機 base model 自生（見「圖生成」）。<strong>兩條都不通才停</strong>。</li>\n<li>角色有「定版 look」種子圖嗎？沒有 → 先做 Stage 1。</li>\n</ul>\n<h3>Stage 1 — 角色定義 + 定版圖</h3>\n<ul>\n<li><strong>1a</strong> 跟 user 把「<strong>不變 identity</strong>（臉/體型/招牌特徵）」vs「<strong>可變</strong>（服裝/場景/配件如眼鏡）」切清楚 → 寫 <code>character.md</code>（SSOT）。</li>\n<li><strong>1b</strong> 用 gpt-image-gen 生 / 鎖一張<strong>定版圖</strong>（text2img 或 img2img），留 codex prompt sidecar → <code>canonical/</code>。</li>\n</ul>\n<h3>Stage 2 — 多角度 sheet（看一致性，非訓練圖）</h3>\n<ul>\n<li>用 gpt-image-gen 生一張多角度 sheet（正/側/背 + 表情），確認「同一個人」。</li>\n<li>⚠️ <strong>sheet ≠ 訓練圖</strong>（拼貼會被學成「拼貼」）。只給人看 + 當 canonical 參考。</li>\n</ul>\n<h3>Stage 3 — 資料集</h3>\n<ul>\n<li><strong>3a pilot</strong>：先生一小批（~6 張，建議：正面特寫×1 / 正面全身×1 / 左右側×各1 / 背面×1 / 表情×1）→（<strong>你先自檢 flag、批量出 contact sheet</strong>）→ 存專案給 user 看，確認 identity 對。</li>\n<li><strong>3b full</strong>：user OK → 生其餘角度（<strong>重用 pilot、不重生</strong>）→ 合 pilot+full = <code>dataset/raw/</code>。</li>\n<li>分佈：角度（正 / 3-4 側 / 全側 / 俯仰 / 背）× 取景（臉特寫 / 半身 / 全身）混合。<strong>~40-50 精圖</strong>（&gt;100-150 = overfit；數字依 base、見 playbook）。全 <strong>PNG 無損</strong>。</li>\n<li><strong>3c 整備</strong>：crop / resize 到訓練解析度、<code>enable_bucket</code> 吃多比例、必要時去背 / 統一光背景。codex 出圖比例不定 → 別直接餵，先整備。</li>\n</ul>\n<h3>Stage 4 — captioning（照選定 base 格式）</h3>\n<table>\n<thead>\n<tr>\n<th>base 家族</th>\n<th>caption 格式</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Pony / SDXL / <strong>anime-SDXL</strong></td>\n<td>booru tags、trigger 第一 token：<code>&lt;trig&gt;, 1boy</code>（男）/<code>1girl</code>（女）<code>, from side, upper body, &lt;scene&gt;</code></td>\n</tr>\n<tr>\n<td>Z-Image / NL 模型</td>\n<td>自然語言：<code>&lt;trig&gt; &lt;class&gt;, &lt;scene&gt;</code>（class word <code>man</code>/<code>woman</code>/<code>elf</code>… <strong>必加</strong>，防偏性別/類別）</td>\n</tr>\n</tbody>\n</table>\n<ul>\n<li>性別/類別字<strong>按角色寫</strong>（<code>1boy</code>/<code>1girl</code>、<code>man</code>/<code>woman</code>）— 範例用男只是範例。</li>\n<li>trigger = <strong>非字典 token</strong>（發明的，避免污染既有語義）。</li>\n<li><strong>只標可變</strong>；identity 留白；toggle 配件（眼鏡）只在「有」的圖標。</li>\n<li>訓練 caption <strong>不放 quality/score tag</strong>（推理才加，避免 style bleed）。</li>\n</ul>\n<h3>Stage 5 — 選 base + 訓前功課（互動）</h3>\n<ul>\n<li><p><strong>5a base 選型</strong>（講優缺點、<strong>user 選</strong>）：</p>\n<table>\n<thead>\n<tr>\n<th>base</th>\n<th>寫實/特色</th>\n<th>explicit 內容</th>\n<th>訓練器</th>\n<th>備註</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><strong>Anime-SDXL</strong>（動漫專用 SDXL 底模）</td>\n<td>動漫 / 2D / cel-shaded</td>\n<td>看 merge</td>\n<td>kohya</td>\n<td><strong>動漫角色走這支</strong>；booru caption；<strong>底模選哪顆 → 5b 功課查當下主流</strong></td>\n</tr>\n<tr>\n<td>Pony V6 XL</td>\n<td>動漫底子強、寫實靠 merge</td>\n<td>原生</td>\n<td>kohya</td>\n<td>生態大、ControlNet 成熟</td>\n</tr>\n<tr>\n<td>Z-Image(-Turbo)</td>\n<td>真人寫實最強之一</td>\n<td>私密處會崩、需疊專用 LoRA</td>\n<td>ai-toolkit only</td>\n<td>新；Turbo 要 training adapter</td>\n</tr>\n<tr>\n<td>其他</td>\n<td>—</td>\n<td>—</td>\n<td>—</td>\n<td><strong>一律先做 5b 功課</strong></td>\n</tr>\n</tbody>\n</table>\n</li>\n<li><p><strong>5b</strong> \uD83D\uDD34 <strong>訓前功課（red line 1）</strong>：查選定 base 的官方訓練文件 + 社群配方。<strong>驗收 = 你能講出該 base 的：caption 格式 / trigger 規範 / class-word 需求 / dim-alpha 範圍 / optimizer / 變體(Turbo)差異。講不出 = 沒做完、別訓。</strong></p>\n</li>\n<li><p><strong>5c</strong> 硬體/SSH 互動確認：訓練機在哪？有 SSH 設定就連、沒有就問 user 要（host/port/key）；確認 GPU、裝好訓練器。</p>\n</li>\n</ul>\n<h3>Stage 6 — 訓練</h3>\n<ul>\n<li><strong>開訓 gate</strong>：OOM 試跑不用 gate；<strong>正式跑前報設定給 user、user 說 go 才開</strong>（紅線 3）。</li>\n<li><strong>6a OOM 試跑</strong>：小步數先驗設定不爆 VRAM / 不報錯。</li>\n<li><strong>6b 正式跑 + checker</strong>：每隔一段把當前 sample <strong>自檢 + flag 後</strong>交付 user（見「交付但書」）。每 epoch / N 步存 checkpoint（<strong>常非最後一個最好</strong>）。</li>\n</ul>\n<h3>Stage 7 — 訓後</h3>\n<ul>\n<li>0→100% montage 合成一張對比大圖交付 user。</li>\n<li>LoRA 存回專案 <code>models/</code>（權重 gitignore）。</li>\n<li><strong>run log</strong>：每步 + 遇到的問題 + 避雷寫 <code>runs/&lt;char&gt;_&lt;base&gt;_vN/run_log.md</code>。</li>\n</ul>\n<h3>Stage 8 — 推理 / 驗收</h3>\n<ul>\n<li>推理底模 / 設定照選定 base；<strong>挑最佳 checkpoint</strong>（測幾個比，非最後一個）。</li>\n<li>寬景/全身掉臉 → face-detail pass（用 LoRA 重畫臉）。</li>\n<li>identity 不夠 → 判斷是 dim/alpha 弱 還是 dataset（「LoRA = 資料集的鏡子」，改特徵回去改<strong>圖</strong>、不是改 prompt）。</li>\n</ul>\n<h2>交付但書（圖怎麼給 user）</h2>\n<p>預設<strong>報本機路徑</strong>；user 說「直接給我看」→ scp 到互動時指定的資料夾；user 要用 IM 看 → <strong>先確認 IM 能傳圖 + 打得到 user</strong> 再傳。</p>\n<h2>自檢 + contact sheet（你是第二雙眼睛）</h2>\n<p>生成圖（dataset / 訓練 sample / 推理）交 user 前，<strong>自己先 view 一遍、主動 flag 問題</strong> — no-face / 崩臉 / 變性別 / 非預期動物或卡通特徵 / 框景裁頭 / 體型不符。<strong>你或 subagent 的「看起來很好」是 input、不是事實</strong> — 最終 user 判，但你不能當水管盲轉。</p>\n<ul>\n<li><strong>批量（數十張 dataset / 多 checkpoint 對比）→ 出 contact sheet</strong>：<code>ffmpeg</code> 的 <code>tile</code> filter 或 <code>imagemagick montage</code> 拼成一張 grid，一次看、一眼抓異常格，不逐張。（注意有些 ffmpeg build 缺 <code>drawtext</code> → 標籤靠檔名 / caption 或改 imagemagick。）</li>\n</ul>\n<h2>失敗 → 根因 → 對策（速查；完整見 playbook.md）</h2>\n<table>\n<thead>\n<tr>\n<th>症狀</th>\n<th>根因</th>\n<th>對策</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>角色每次抽籤 / 超飄</td>\n<td>dim/alpha 弱化 + optimizer 沒調</td>\n<td>照 base 官方配方（dim 足、Prodigy/adafactor）</td>\n</tr>\n<tr>\n<td>寬景掉臉變別人</td>\n<td>臉太小、base prior 接管</td>\n<td>face-detail pass</td>\n</tr>\n<tr>\n<td>出來變性別</td>\n<td>NL caption 沒 class word</td>\n<td>caption 加 man/woman</td>\n</tr>\n<tr>\n<td>出現<strong>非預期</strong>動物/卡通特徵（要寫實卻跑卡通）</td>\n<td>caption 有觸發該語義的字</td>\n<td>拿掉那字、trigger 用非字典 token。⚠️ 你本來就要 anime/stylized → 那是 intended、<strong>別拿掉</strong></td>\n</tr>\n<tr>\n<td>烤進的特徵 prompt 改不掉</td>\n<td>特徵來自圖、非 caption</td>\n<td>改 dataset，不是改 prompt</td>\n</tr>\n</tbody>\n</table>\n<h2>Anti-patterns</h2>\n<ul>\n<li>❌ 憑印象配訓練參數、不查 base 官方/社群（= 抽籤）</li>\n<li>❌ 把沒驗證的設定寫成「配方」</li>\n<li>❌ 不拿 user 拍板就批量生圖 / 開訓</li>\n<li>❌ sheet 拼貼當訓練圖</li>\n<li>❌ caption 標 identity（臉/體型）</li>\n<li>❌ 跨架構套 LoRA</li>\n<li>❌ 用 prompt 硬改已烤進的特徵</li>\n<li>❌ 用 close-up 框景判斷體型（看不到身體）</li>\n<li>❌ 盲轉生成圖不自檢（「看起來很好」≠ 事實，要主動抓 no-face / 崩 / 變性別 / 動物特徵）</li>\n<li>❌ 數十張圖逐張看 / 逐張傳（出 contact sheet 一次看）</li>\n</ul>\n<h2>Important rules（核心 invariants）</h2>\n<ol>\n<li><strong>先做 base 功課再訓</strong>（red line 1，最重要）。</li>\n<li>沒驗證的標 <code>proposed</code>，別當配方。</li>\n<li>每個花錢/算力步驟 user 先拍板。</li>\n<li>LoRA 綁架構。</li>\n<li>標可變、留 identity。</li>\n<li>圖生成 delegate <code>gpt-image-gen</code>。</li>\n<li>交付依但書。</li>\n<li>訓練全程寫 run log。</li>\n<li>生成圖傳前<strong>自檢 + flag</strong>（你是第二雙眼睛）；批量出 <strong>contact sheet</strong> 一次看。</li>\n</ol>\n<h2>References</h2>\n<ul>\n<li><strong><code>playbook.md</code></strong>（同目錄）— 完整方法論：每 stage 的 why / 決策樹、per-base 配方知識、完整失敗對策表、「base 功課怎麼做」清單。SKILL.md 是操作骨架，深度看 playbook。</li>\n<li>依賴 skill：<code>gpt-image-gen</code>（codex 出圖，text2img + img2img）。</li>\n</ul>\n","files":[{"path":"playbook.md","sizeBytes":7625,"isText":true},{"path":"SKILL.md","sizeBytes":11097,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-09-18T13:27:12.216405Z","sha256":"0BC2E51E69570CA5F2D382861B346500605CC1862A471729628E365A006B850E","sizeBytes":10700},"review":null,"source":{"repositoryUrl":"https://github.com/KerberosClaw/kc_ai_skills","path":"character-lora","license":"MIT","commit":"2b453ffa281dc107732ca7659e863f5da955e07a","subtreeSha":"466FA50E1E433D3D4BD7900C948B2D3BFD7FC193EEABEB1BBEB41FC376C33563","lastSyncedAt":"2026-09-27T19:30:37.836842Z"},"reviewedAt":"2026-09-18T13:27:42.298505Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/KerberosClaw/kc_ai_skills/tree/main/character-lora"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install kerberosclaw-kc-ai-skills@llmmart"},{"target":"git","command":"git clone https://github.com/KerberosClaw/kc_ai_skills.git"}]}