테스트 파일 정리 및 일부 함수 재구조화, playreel analyze까지
This commit is contained in:
1 parent
5c84733a8b
commit
53f308eac2
35 files changed
+1019
-49
No files matched your search
@@ -0,0 +1,40 @@
|
||||
"""narration 수동 확인용.
|
||||
|
||||
사용: uv run python -m tests.poster_alive.test_narration <포스터경로>
|
||||
같은 포스터의 test_result/<이름>.detect.txt 가 있으면 재사용하고, 없으면 detect부터 돌린다.
|
||||
결과는 test_result/<이름>.narration.txt 로 떨어진다.
|
||||
"""
|
||||
import asyncio
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from models.detect import Regions
|
||||
from services.detect import detect
|
||||
from services.narration import generate_narration
|
||||
|
||||
TEST_RESULT_DIR = Path(__file__).parent.parent / "test_result" / "poster_alive"
|
||||
|
||||
|
||||
async def load_regions(poster_path: Path, detect_path: Path) -> Regions:
|
||||
if detect_path.exists():
|
||||
return Regions.model_validate_json(detect_path.read_text(encoding="utf-8"))
|
||||
result = await detect(poster_path)
|
||||
detect_path.write_text(result.data.model_dump_json(indent=2), encoding="utf-8")
|
||||
return result.data
|
||||
|
||||
|
||||
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
|
||||
|
||||
regions = await load_regions(poster_path, output_base.with_suffix(".detect.txt"))
|
||||
answer = await generate_narration(poster_path, regions)
|
||||
|
||||
narration_path = output_base.with_suffix(".narration.txt")
|
||||
narration_path.write_text(answer.model_dump_json(indent=2), encoding="utf-8")
|
||||
print(narration_path)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in new issue
Block a user