Instructions to use darask0/anima-distill-loras with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use darask0/anima-distill-loras with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("circlestone-labs/Anima", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("darask0/anima-distill-loras") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
Upload dmdx/README.md with huggingface_hub
Browse files- dmdx/README.md +134 -0
dmdx/README.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: circlestone-labs/Anima
|
| 4 |
+
tags:
|
| 5 |
+
- lora
|
| 6 |
+
- distillation
|
| 7 |
+
- adversarial-distribution-matching
|
| 8 |
+
- dmdx
|
| 9 |
+
- adm
|
| 10 |
+
- anime
|
| 11 |
+
- text-to-image
|
| 12 |
+
library_name: diffusers
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# Anima v1.0 — DMDX (ADM) Distillation LoRA
|
| 16 |
+
|
| 17 |
+
論文 [arxiv 2507.18569v1](https://arxiv.org/html/2507.18569v1) (ByteDance Seed Vision)
|
| 18 |
+
の **ADM (Adversarial Distribution Matching)** を Anima v1.0 base に移植した蒸留 LoRA。
|
| 19 |
+
|
| 20 |
+
DMD2 の逆 KL gradient trick を **学習可能 discriminator による hinge GAN (TVD 最小化)** に置換した手法。
|
| 21 |
+
|
| 22 |
+
## ⚠ 重要な所見
|
| 23 |
+
|
| 24 |
+
本実装は **warm-start (Civitai Anima Turbo) からほぼ移動しなかった**:
|
| 25 |
+
- 5000 outer 訓練後の生成出力は warm-start Turbo とほぼ視覚的に同等
|
| 26 |
+
- GAN dynamics は健全 (D vs G 振動、mean collapse なし)
|
| 27 |
+
- ただし student LoRA の重みは保守的に推移、独自の蒸留方向を獲得できず
|
| 28 |
+
|
| 29 |
+
**結論**: 本 LoRA は実質的に "Anima Turbo + 軽い ADM 訓練" の状態。Civitai Turbo を直接使うのと品質に有意差なし。研究目的・記録のため配布。
|
| 30 |
+
|
| 31 |
+
詳細な技術解説は [docs/dmdx.md](https://huggingface.co/darask0/rapid-anima/blob/main/docs/dmdx.md)、warm-start dominance に至った推測原因は本ドキュメント末尾の「改善方向」参照。
|
| 32 |
+
|
| 33 |
+
## Files
|
| 34 |
+
|
| 35 |
+
| File | Format | Use |
|
| 36 |
+
|---|---|---|
|
| 37 |
+
| `dmdx_final_peft.safetensors` | PEFT (diffusers) | `peft` library / 自前推論スクリプト |
|
| 38 |
+
| `dmdx_final_comfy.safetensors` | ComfyUI LoRA | ComfyUI で直接ロード |
|
| 39 |
+
|
| 40 |
+
両者は同一の重み。
|
| 41 |
+
|
| 42 |
+
## Usage (ComfyUI)
|
| 43 |
+
|
| 44 |
+
1. `dmdx_final_comfy.safetensors` を `ComfyUI/models/loras/` に配置
|
| 45 |
+
2. Anima v1.0 base workflow に `LoraLoaderModelOnly` を挿入、`strength_model: 1.0`
|
| 46 |
+
3. `ModelSamplingAuraFlow` で `sigma_shift: 3.0`
|
| 47 |
+
4. KSampler:
|
| 48 |
+
- **steps: 4**
|
| 49 |
+
- **cfg: 1.0**
|
| 50 |
+
- sampler: **`er_sde`**
|
| 51 |
+
- scheduler: **`simple`**
|
| 52 |
+
|
| 53 |
+
## Training Details
|
| 54 |
+
|
| 55 |
+
| 項目 | 値 |
|
| 56 |
+
|---|---|
|
| 57 |
+
| Base model | `anima-base-v1.0.safetensors` (circlestone-labs/Anima) |
|
| 58 |
+
| Method | DMDX ADM-only (arxiv 2507.18569v1 移植、ADP 省略) |
|
| 59 |
+
| Discriminator | LADD-style (teacher MiniTrainDIT frozen + spectral norm heads、5 hook) |
|
| 60 |
+
| Student LoRA | wide (AdaLN + attn + MLP の全 Linear、980 keys、rank 32) |
|
| 61 |
+
| Total outer | 5000 (1 outer = 2 disc + 1 generator) |
|
| 62 |
+
| n_critic_per_gen | 2 (hinge GAN は 1:1〜2:1 が一般的) |
|
| 63 |
+
| n_student_steps | 4 (deploy target に一致) |
|
| 64 |
+
| dt_ratio (Δt) | 1/64 (paper default) |
|
| 65 |
+
| Time schedule | **cubic high-noise bias** (`t = 1 - u**3`、u~U(0,1)) |
|
| 66 |
+
| Teacher CFG | 4.5 (Anima 公式推奨) |
|
| 67 |
+
| Student CFG | 1.0 (CFG embedded) |
|
| 68 |
+
| recon_weight | 0.0 (pure ADM、Smooth-L1 anchor なし) |
|
| 69 |
+
| LR (gen / disc) | 5e-6 / 1e-5 |
|
| 70 |
+
| Warm-start | **Civitai Anima Turbo** (968/1016 keys match、x/t embedder skip) |
|
| 71 |
+
| Hardware | NVIDIA B200 |
|
| 72 |
+
| Training time | ~4.3h (3.59s/outer、並列 DMD2 と同時実行) |
|
| 73 |
+
| Cost | ~$27 (Modal) |
|
| 74 |
+
|
| 75 |
+
### GAN dynamics (loss 推移)
|
| 76 |
+
|
| 77 |
+
```
|
| 78 |
+
outer 0: l_d_real=0.72 l_d_fake=1.30 l_g_adv=-0.29 (初期)
|
| 79 |
+
outer 500: 0.82 0.98 -0.15 (G slightly winning)
|
| 80 |
+
outer 1500: 0.31 0.90 +0.08 (D dominant、l_g_adv +0.5 ピーク)
|
| 81 |
+
outer 2500: 0.95 0.57 +0.47 (D dominance peak)
|
| 82 |
+
outer 3500: 1.31 0.53 -0.46 (G recovers!)
|
| 83 |
+
outer 4500: 1.12 0.52 +0.25 (mild D-favor)
|
| 84 |
+
outer 5000: similar to 4500
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
典型的な GAN 振動。`l_d_total` は 1.21-2.02 範囲で healthy equilibrium、divergence なし。
|
| 88 |
+
|
| 89 |
+
### Implementation files
|
| 90 |
+
|
| 91 |
+
- `scripts/distill/dmdx_loss.py` — ADM loss、cubic time sampling、teacher Δt evolution
|
| 92 |
+
- `scripts/distill/train_dmdx.py` — 訓練ループ (DMD2 風 outer / inner 構造)
|
| 93 |
+
- `modal_app.py::train_dmdx_distill` — Modal entry
|
| 94 |
+
|
| 95 |
+
ソースは [darask0/rapid-anima](https://huggingface.co/darask0/rapid-anima) / [github.com/daraskme/rapid-anima](https://github.com/daraskme/rapid-anima) 参照。
|
| 96 |
+
|
| 97 |
+
## サンプル比較 (4-step / CFG=1.0 / er_sde + simple)
|
| 98 |
+
|
| 99 |
+
同 prompt (Touhou Flandre + Remilia)、同 seed=42、Anima v1.0 base。
|
| 100 |
+
|
| 101 |
+
| Civitai Anima Turbo (warm-start) | DMDX final (5000 outer) |
|
| 102 |
+
|---|---|
|
| 103 |
+
|  |  |
|
| 104 |
+
|
| 105 |
+
→ **視覚的に同一**。DMDX 訓練の影響は微小、warm-start anchor が支配。
|
| 106 |
+
|
| 107 |
+
## 推測される改善方向 (将来検討)
|
| 108 |
+
|
| 109 |
+
1. **cold-start** — warm-start を外して DMDX 単独で蒸留 (リスク: 不安定化、ただし独自性は出る)
|
| 110 |
+
2. **lr_gen 引き上げ** (5e-6 → 2e-5) — G の更新を加速
|
| 111 |
+
3. **recon_weight=0.5** — LADD 流 Smooth-L1 anchor で teacher x0 に近づける軌道制御
|
| 112 |
+
4. **lower n_critic** (2 → 1) — D の優勢を抑え G に更新機会
|
| 113 |
+
5. **論文の ADP 移植** — SAM ベース pixel-space discriminator 追加 (実装重い、+$300-500、本 repo では省略)
|
| 114 |
+
|
| 115 |
+
## License
|
| 116 |
+
|
| 117 |
+
Apache-2.0
|
| 118 |
+
|
| 119 |
+
Base model (Anima v1.0) のライセンスも適用:
|
| 120 |
+
[circlestone-labs/Anima](https://huggingface.co/circlestone-labs/Anima)
|
| 121 |
+
- CircleStone Labs Non-Commercial License
|
| 122 |
+
- NVIDIA Open Model License (Derivative Model 条項)
|
| 123 |
+
- **非商用利用のみ**
|
| 124 |
+
|
| 125 |
+
## Citation
|
| 126 |
+
|
| 127 |
+
```bibtex
|
| 128 |
+
@article{lu2025adversarial,
|
| 129 |
+
title={Adversarial Distribution Matching for Diffusion Distillation Towards Efficient Image and Video Synthesis},
|
| 130 |
+
author={Lu, Yanzuo and Ren, Yuxi and Xia, Xin and others},
|
| 131 |
+
journal={arXiv preprint arXiv:2507.18569},
|
| 132 |
+
year={2025}
|
| 133 |
+
}
|
| 134 |
+
```
|