Files
playreel/backend/tests/playreel/test_i2v.py
T
2026-09-07 15:25:03 +09:00

45 lines
1.6 KiB
Python

"""⑨ i2v 수동 확인용 — 되돌릴 수 없는 지점이다.
사용: uv run python -m tests.playreel.test_i2v <goods_id>
업스케일 포스터와 ⑤에서 확정한 프롬프트를 쓴다.
detect를 안 거쳐 regions가 없으므로 제목 훼손 게이트는 돌지 않는다.
결과는 nol_<goods_id>/clip.mp4 와 i2v.json.
"""
import asyncio
import json
import sys
from pathlib import Path
from services.i2v import animate
TEST_RESULT_DIR = Path(__file__).parent.parent / "test_result" / "playreel"
async def main() -> None:
goods_id = sys.argv[1]
product_dir = TEST_RESULT_DIR / f"nol_{goods_id}"
poster_path = product_dir / "upscaled.png"
prompt_path = product_dir / "i2v_prompt.txt"
for required in (poster_path, prompt_path):
if not required.exists():
raise SystemExit(f"{required} 없음 — 앞 단계를 먼저 돌릴 것")
result = await animate(prompt_path.read_text(encoding="utf-8").strip(), poster_path)
clip_path = product_dir / "clip.mp4"
summary_path = product_dir / "i2v.json"
clip_path.write_bytes(result.clip)
summary_path.write_text(json.dumps(
{"model": result.model, "credits": result.credits,
"title_gate": result.title_gate.model_dump()},
ensure_ascii=False, indent=2), encoding="utf-8")
print(f"{result.model} · {result.credits}크레딧 · {len(result.clip) / 1e6:.1f}MB")
if result.title_gate.skip:
print(f"제목 게이트: {result.title_gate.skip}")
print(f"\n{clip_path}\n{summary_path}")
if __name__ == "__main__":
asyncio.run(main())