playreel/backend/tests/poster_alive/test_detect.py

34 lines
1015 B
Python

"""detect 수동 확인용.
사용: uv run python -m tests.poster_alive.test_detect <포스터경로>
결과는 test_result/ 아래에 .detect.txt / .grid.jpg / .check.jpg 세 파일로 떨어진다.
"""
import asyncio
import sys
from pathlib import Path
from services.detect import detect
TEST_RESULT_DIR = Path(__file__).parent.parent / "test_result" / "poster_alive"
async def main() -> None:
poster_path = Path(sys.argv[1])
TEST_RESULT_DIR.mkdir(exist_ok=True)
output_base = TEST_RESULT_DIR / poster_path.stem
result = await detect(poster_path)
text_path = output_base.with_suffix(".detect.txt")
grid_path = output_base.with_suffix(".grid.jpg")
check_path = output_base.with_suffix(".check.jpg")
text_path.write_text(result.data.model_dump_json(indent=2), encoding="utf-8")
result.grid.save(grid_path, quality=90)
result.check.save(check_path, quality=90)
print(text_path, grid_path, check_path, sep="\n")
if __name__ == "__main__":
asyncio.run(main())