--- license: apache-2.0 base_model: circlestone-labs/Anima tags: - lora - distillation - phased-consistency-model - pcm - anime - text-to-image library_name: diffusers --- # Anima v1.0 — PCM 4-step Distillation LoRA ⚠️ **非推奨 / Not Recommended**: 本 LoRA は生成品質が低く、実用には Civitai Anima Turbo を推奨。 研究目的・失敗事例の参照用として公開。 Phased Consistency Model (PCM) 蒸留 LoRA for [Anima v1.0 base](https://huggingface.co/circlestone-labs/Anima)。 4-step / CFG=1.0 で生成可能だが、**視覚品質が公式 [Civitai Anima Turbo](https://civitai.com/models/2560840) や同 collection の DMDX に劣る**。 ## なぜ非推奨か - 5000 step 訓練を **数値的に完走** (loss 健全、divergence なし) したが、生成画像の品質が低い - 実用は **公式 Civitai Anima Turbo を直接使用** が確実 詳細な失敗分析は [docs/pcm.md](https://huggingface.co/darask0/rapid-anima/blob/main/docs/pcm.md) 参照。 ## Files | File | Format | Use | |---|---|---| | `pcm_final_peft.safetensors` | PEFT (diffusers) | 研究用 | | `pcm_final_comfy.safetensors` | ComfyUI LoRA | 研究用 | 両者は同一の重み、フォーマット変換のみの違い。 ## Usage (ComfyUI、研究用) 1. `pcm_final_comfy.safetensors` を `ComfyUI/models/loras/` に配置 2. Anima v1.0 base workflow に `LoraLoaderModelOnly` を挿入、`strength_model: 1.0` 3. KSampler 設定: - **steps: 4** - **cfg: 1.0** - sampler / scheduler: 下記サンプル比較を参照 ## Recommended Sampler (どちらも品質不足だが) | Sampler | Scheduler | 特徴 | |---|---|---| | `er_sde` | `simple` | やや softer、構図上半身寄り、生成 8.8s | | `res_multistep` | `beta` | anime style 強め、全身描画、生成 11.2s | 両者とも 4-step CFG=1.0 で動作するが、品質的に Civitai Turbo / DMDX より劣る。 ### サンプル比較 | step 3500 / er_sde + simple | step 4000 / res_multistep + beta | |---|---| | ![s3500](samples/sample_step3500_er_sde_simple.png) | ![s4000](samples/sample_step4000_res_multistep_beta.png) | 両者とも同一 prompt (`2girls, flandre scarlet, remilia scarlet, touhou, ...`)、seed 42。 ## Training Details | 項目 | 値 | |---|---| | Base model | `anima-base-v1.0.safetensors` (circlestone-labs/Anima) | | Method | PCM (Phased Consistency Model, G-U-N variant) | | LoRA target | AdaLN + attention + MLP の全 Linear (wide LoRA、980 keys) | | LoRA rank | 32 | | Total steps | 5000 | | Batch size / grad accum | 1 / 4 | | Resolution | 768 | | Euler N | 50 | | Phases K | 4 | | sigma_shift | 3.0 | | CFG-aug w range | [4.0, 5.0] | | Huber c | 1e-3 | | Learning rate | 5e-6 | | Loss | Pseudo-Huber | | Optimizer | AdamW (lr 5e-6, wd 0.01) | | Grad clip | 1.0 | | Warm-start | **無し** (cold-start) | | Hardware | NVIDIA B200 (1 GPU) | | Training time | ~3.4 hours | | Cost | ~$22 (Modal) | ### Dataset Anima v1.0 self-distillation cache (5000 caption × teacher x0 + crossattn embedding): - Teacher: Anima v1.0 base, 20-step CFG=4.5 with sigma_shift=3.0 - Caption pool: 10 prompts × 500 seeds, anime characters + scene - Precompute cost: ~$7-8 (B200, ~86 min) ## 失敗分析 (Lessons Learned) ### 数値上は成功した - loss 0.001-0.007 で安定収束 - mean collapse / NaN / OOM 全部なし - training pipeline は完璧に動作 ### しかし生成品質は低い 推測される原因: 1. **cold-start strategy が Anima 系では機能しない可能性** - 公式 Turbo は warm-start が事実上必須 - 5000 sample dataset は cold-start には不十分かも 2. **phase consistency loss だけでは style anchor が弱い** - DMD2 系の adversarial signal や LADD の Smooth-L1 recon があれば改善可能性 3. **CFG-augmentation embed が不完全** - w∈[4.0, 5.0] embed が teacher CFG=4.5 の効果を完全再現していない ### 改善方向 (将来検討) - warm-start (Civitai Turbo) を導入して semi-fine-tune に - データセット規模拡大 (5000 → 20000+) - adversarial loss (LADD style) との組合せ - 他手法 (DMD2、Hyper-SD) に切り替え ## Limitations - ❌ **生成品質が公式 Turbo / DMDX より劣る** — 主要な制約 - Base model 固定 (Anima v1.0 以外では style drift) - 4-step ハード制約 (2 step / 8 step では同等品質保証なし) - CFG=1.0 推奨 (CFG>1.0 は過剰) ## License Apache-2.0 Base model (Anima v1.0) のライセンスも併せて確認のこと: [circlestone-labs/Anima](https://huggingface.co/circlestone-labs/Anima) ## Citation PCM 元論文: ```bibtex @article{wang2024phased, title={Phased Consistency Model}, author={Wang, Fu-Yun and Huang, Zhaoyang and Bei, Bin and Shi, Xiaoyu and Liu, Xinyu and Tian, Yang and Yang, Yang and Li, Hongsheng}, journal={NeurIPS}, year={2024} } ``` 実装参考: [G-U-N/Phased-Consistency-Model](https://github.com/G-U-N/Phased-Consistency-Model)