테스트 파일 정리 및 일부 함수 재구조화, playreel analyze까지

This commit is contained in:
jaehwang committed 2026-09-07 14:27:59 +09:00
1 parent 5c84733a8b
commit 53f308eac2
35 files changed
+1019 -49

No files matched your search

+2 -19
View File
@@ -12,7 +12,7 @@ from answers.detect_answer import DetectAnswer, GridBox
from models.detect import Box, DetectResult, Focal, Regions
from settings import settings
from utils.common_llm import StructuredLLM
from utils.image import to_data_uri
from utils.image import to_data_uri, vlm_grid_overlay
from utils.prompt import load_prompt
Image.MAX_IMAGE_PIXELS = None
@@ -27,23 +27,6 @@ DETECT_PROMPT = load_prompt("detect")
detect_llm = StructuredLLM("gpt-4o", settings.chatgpt_api_key)
def grid_overlay(poster: Image.Image) -> Image.Image:
overlay = poster.convert("RGB").copy()
width, height = overlay.size
draw = ImageDraw.Draw(overlay, "RGBA")
font = ImageFont.load_default(max(14, width // 55))
for row in range(1, 20):
y = int(height * row * 0.05)
draw.line([(0, y), (width, y)], fill=(255, 0, 80, 150), width=max(1, width // 700))
if row % 2 == 0:
draw.text((4, y + 2), f"{row * 5}", font=font, fill=(255, 255, 0, 255))
for col in range(1, 10):
x = int(width * col * 0.10)
draw.line([(x, 0), (x, height)], fill=(0, 220, 255, 130), width=max(1, width // 700))
draw.text((x + 3, 3), f"{col * 10}", font=font, fill=(0, 255, 255, 255))
return overlay
def check_overlay(poster: Image.Image, regions: dict[str, Box],
focal_points: list[Focal]) -> Image.Image:
overlay = poster.convert("RGB").copy()
@@ -105,7 +88,7 @@ async def detect(poster: Path | Image.Image) -> DetectResult:
work_image = source.copy()
work_image.thumbnail((WORK_WIDTH_PX, WORK_WIDTH_PX * 3), Image.LANCZOS)
grid_image = grid_overlay(work_image)
grid_image = vlm_grid_overlay(work_image)
answer = await detect_llm.ask_with_images(
DetectAnswer, DETECT_PROMPT, [("격자를 씌운 포스터:", to_data_uri(grid_image))])
ink = ink_mask(work_image)