posteralive gate 조정

This commit is contained in:
jaehwang committed 2026-09-09 11:32:24 +09:00
1 parent 3ee1c3bdfc
commit a2543e19d4
2 files changed
+24 -21

No files matched your search

+13 -15
View File
@@ -3,6 +3,9 @@
"파일이 존재하는가"만 보던 검증 탓에 구름이 제목을 덮은 클립이 검수대까지 간 적이 있다.
픽셀 지표 하나로는 갈리지 않아서 — 영역 평균차는 제목 뒤 불꽃과 제목 위 구름을 구분 못 하고
글리프 휘도차는 흰 구름이 흰 글자를 덮으면 0에 수렴한다 — 2단을 VLM 가독성 판정으로 둔다.
두 단 모두 첫 프레임을 기준으로 삼는다. detect가 읽은 제목 문자열과는 대조하지 않는다 —
상자가 제목의 일부만 덮으면 잘려 나간 글자를 훼손으로 오인한다.
"""
import numpy as np
from PIL import Image
@@ -76,18 +79,20 @@ def pixel_score(crops: list[Image.Image]) -> float | None:
for crop in crops[1:])
async def ask_legibility(crops: list[Image.Image], times: list[float],
title: str) -> TitleGateAnswer:
images = [(f"[{index}] t={at}s:", to_data_uri(crop, CROP_MAX_SIZE))
async def ask_legibility(crops: list[Image.Image], times: list[float]) -> TitleGateAnswer:
"""[0]이 기준이다. 옮겨 적은 제목과 대조하지 않는다 —
detect가 읽은 글자와 detect가 잡은 상자가 어긋나면 그 차이를 훼손으로 오인한다."""
images = [(f"[{index}] t={at}s{' (원본)' if index == 0 else ''}:",
to_data_uri(crop, CROP_MAX_SIZE))
for index, (crop, at) in enumerate(zip(crops, times, strict=True))]
return await title_gate_llm.ask_with_images(
TitleGateAnswer,
f"기대 제목: {title!r}\n시점 {len(crops)}장. 각 이미지를 순서대로 판정하라.",
f"시점 {len(crops)}장. [0]을 기준으로 각 이미지를 순서대로 판정하라.",
images, system=TITLE_GATE_PROMPT)
async def check_title(clip: bytes, regions: Regions) -> TitleGateVerdict:
"""판단 근거가 없으면(제목 상자·텍스트 없음) 통과시키고 사유를 남긴다."""
"""제목 상자가 없으면 판단 근거가 없으므로 통과시키고 사유를 남긴다."""
clip_seconds = duration(clip)
times = [round(max(0.0, min(clip_seconds - 0.05, fraction * clip_seconds)), 2)
for fraction in SAMPLE_FRACTIONS]
@@ -99,26 +104,19 @@ async def check_title(clip: bytes, regions: Regions) -> TitleGateVerdict:
crops = [frame.crop(box) for frame in frames]
score = pixel_score(crops)
title = (regions.regions["title"].text or "").strip()
verdict = TitleGateVerdict(passed=True, samples=times,
pixel_score=round(score, 2) if score is not None else None)
if score is not None and score > PIXEL_HARD_FAIL:
# 정렬 후에도 넘는 값은 대개 배경 통과라 즉시 실패시키지 않고 VLM으로 넘긴다
verdict.pixel_hard = True
if not title:
verdict.passed = False
verdict.reason = f"획변화 {score:.1f} > {PIXEL_HARD_FAIL}, title.text 없어 VLM 판정 불가"
return verdict
if not title:
verdict.skip = "title.text 없음 — VLM 가독성 판정 불가"
return verdict
answer = await ask_legibility(crops, times, title)
answer = await ask_legibility(crops, times)
verdict.frames = [FrameVerdict(index=frame.index, time=times[frame.index],
legible=frame.legible, broken=frame.broken)
for frame in answer.frames if frame.index < len(times)]
broken = [frame for frame in verdict.frames if not frame.legible]
# [0]은 원본이라 판정 대상이 아니다
broken = [frame for frame in verdict.frames if not frame.legible and frame.index > 0]
if broken:
verdict.passed = False
verdict.reason = "제목 가독 훼손: " + "; ".join(