| |
| """ |
| Phase 1 検証用: 学習済み LoRA を Anima にロードして、 |
| 意図的に「品質タグなしの短いプロンプト」で画像を生成する。 |
| |
| これらが既に良質に出れば、Phase 1 が成功している証拠。 |
| |
| 使い方: |
| python infer_test.py --lora /output/phase1/.../adapter_model.safetensors \ |
| --prompts ./eval_prompts.txt --out /output/phase1_samples |
| """ |
| import argparse |
| import sys |
| from pathlib import Path |
|
|
| |
| |
| |
|
|
| DEFAULT_PROMPTS = [ |
| "1girl, long hair, school uniform, standing in a classroom", |
| "a black cat sitting on a windowsill at sunset", |
| "1boy, samurai, holding katana, snowy forest", |
| "fantasy landscape with floating islands and a waterfall", |
| "1girl, twintails, smile, holding ice cream, summer", |
| ] |
|
|
|
|
| def main(): |
| ap = argparse.ArgumentParser() |
| ap.add_argument("--lora", required=True, type=Path) |
| ap.add_argument("--prompts", type=Path, default=None) |
| ap.add_argument("--out", required=True, type=Path) |
| ap.add_argument("--steps", type=int, default=30) |
| ap.add_argument("--cfg", type=float, default=4.5) |
| ap.add_argument("--seed", type=int, default=42) |
| args = ap.parse_args() |
|
|
| args.out.mkdir(parents=True, exist_ok=True) |
|
|
| if args.prompts and args.prompts.exists(): |
| prompts = [ |
| line.strip() |
| for line in args.prompts.read_text(encoding="utf-8").splitlines() |
| if line.strip() |
| ] |
| else: |
| prompts = DEFAULT_PROMPTS |
|
|
| |
| |
| |
| |
| |
| |
|
|
| print("=" * 60) |
| print("Phase 1 検証プロンプト (品質タグ意図的に省略):") |
| print("=" * 60) |
| for i, p in enumerate(prompts): |
| print(f" [{i:02d}] {p}") |
|
|
| print("\n[infer_test] このスクリプトはサンプル一覧と LoRA パスを表示するスケルトンです。") |
| print(f"[infer_test] LoRA: {args.lora}") |
| print(f"[infer_test] Output dir: {args.out}") |
| print( |
| "\n[infer_test] 実生成は次のいずれかで実行してください:\n" |
| " 1) ComfyUI ワークフローに anima-preview3-base + この LoRA を読み込み\n" |
| " (公式リポジトリ同梱の example.png ワークフローから派生させる)\n" |
| " 2) diffusion-pipe の最新サンプリングコード\n" |
| " 3) diffusers の Anima 対応版 (リリース次第)\n" |
| ) |
|
|
| |
| (args.out / "eval_prompts_used.txt").write_text( |
| "\n".join(prompts), encoding="utf-8" |
| ) |
|
|
|
|
| if __name__ == "__main__": |
| sys.exit(main()) |
|
|