add motion layer
This commit is contained in:
1 parent
0a8e4cdbe5
commit
65504585b6
12 files changed
+401
-5
No files matched your search
+2
-3
@@ -1,6 +1,5 @@
|
||||
# 프로젝트
|
||||
backend/test_result/
|
||||
|
||||
backend/test_*/
|
||||
# 시크릿
|
||||
.env
|
||||
.env.*
|
||||
@@ -30,4 +29,4 @@ htmlcov/
|
||||
# 에디터 / OS
|
||||
.idea/
|
||||
.vscode/
|
||||
.DS_Store
|
||||
.DS_Store
|
||||
@@ -0,0 +1,23 @@
|
||||
"""③ motion 단계 VLM 응답 스키마.
|
||||
|
||||
모션 키는 Literal로 고정한다 — 어휘 밖의 값이 나올 수 없다.
|
||||
키 목록은 raw_prompt/motion_phrase.json과 일치해야 하며, motion.py가 기동 시 대조한다.
|
||||
"""
|
||||
from typing import Literal
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
MotionKey = Literal[
|
||||
"firework", "water", "wave", "cloud", "smoke", "moon", "sun", "star", "light",
|
||||
"flag", "foliage", "wheel", "vessel", "crowd", "ray", "snow", "fog", "glow",
|
||||
]
|
||||
|
||||
|
||||
class MotionElement(BaseModel):
|
||||
motion: MotionKey
|
||||
what: str
|
||||
confident: bool
|
||||
|
||||
|
||||
class MotionAnswer(BaseModel):
|
||||
elements: list[MotionElement]
|
||||
@@ -0,0 +1,19 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class MotionItem(BaseModel):
|
||||
motion: str
|
||||
what: str
|
||||
|
||||
|
||||
class DroppedMotion(BaseModel):
|
||||
motion: str
|
||||
what: str
|
||||
why: str
|
||||
|
||||
|
||||
class MotionPlan(BaseModel):
|
||||
prompt: str
|
||||
has_qr: bool
|
||||
kept: list[MotionItem]
|
||||
dropped: list[DroppedMotion]
|
||||
@@ -0,0 +1,86 @@
|
||||
"""③ motion — 포스터에서 움직일 요소를 골라 i2v 프롬프트를 만든다.
|
||||
|
||||
모션 어휘를 고정 카탈로그로 나열했더니 모델이 포스터에 없는 관람차를 그려 넣었다.
|
||||
생성 모델에게 조건문은 주문서로 읽힌다. 그래서 역할을 나눈다 —
|
||||
**무엇이 있는가**는 VLM이 그림을 보고 답하고, **어떻게 움직이는가**는 검증된 문구가 정한다.
|
||||
"""
|
||||
from pathlib import Path
|
||||
from typing import get_args
|
||||
|
||||
from PIL import Image
|
||||
|
||||
from answers.motion_answer import MotionAnswer, MotionElement, MotionKey
|
||||
from models.motion import DroppedMotion, MotionItem, MotionPlan
|
||||
from settings import settings
|
||||
from utils.common_llm import StructuredLLM
|
||||
from utils.image import to_data_uri
|
||||
from utils.prompt import load_prompt, load_prompt_json
|
||||
from utils.qr import qr_box
|
||||
|
||||
Image.MAX_IMAGE_PIXELS = None
|
||||
|
||||
POSTER_MAX_SIZE = (1100, 1600)
|
||||
|
||||
MOTION_PHRASES: dict[str, str] = load_prompt_json("motion_phrase")
|
||||
MOTION_QR_BLOCKS: dict[str, dict[str, str]] = load_prompt_json("motion_qr")
|
||||
MOTION_FRAME = load_prompt("motion_frame")
|
||||
MOTION_VLM_PROMPT = load_prompt("motion_vlm")
|
||||
|
||||
motion_llm = StructuredLLM("gpt-4o", settings.chatgpt_api_key)
|
||||
|
||||
_missing_phrases = set(get_args(MotionKey)) - MOTION_PHRASES.keys()
|
||||
if _missing_phrases:
|
||||
raise RuntimeError(f"motion_phrase.json에 문구가 없는 모션 키: {sorted(_missing_phrases)}")
|
||||
|
||||
|
||||
def build_prompt(elements: list[MotionElement], has_qr: bool, extra: str = "") -> MotionPlan:
|
||||
"""확신 있는 요소만 남기고, 같은 종류는 한 번만 지시한다."""
|
||||
kept, dropped = [], []
|
||||
for element in elements:
|
||||
if element.confident:
|
||||
kept.append(MotionItem(motion=element.motion, what=element.what))
|
||||
else:
|
||||
# 애매하면 안 움직이는 쪽이 기본값
|
||||
dropped.append(DroppedMotion(motion=element.motion, what=element.what, why="확신없음"))
|
||||
|
||||
seen: set[str] = set()
|
||||
lines = []
|
||||
for item in kept:
|
||||
if item.motion in seen:
|
||||
continue
|
||||
seen.add(item.motion)
|
||||
lines.append(MOTION_PHRASES[item.motion])
|
||||
|
||||
body = "\n\n".join(lines)
|
||||
if extra: # 포스터별 고정 지시
|
||||
body += "\n\n" + extra.strip()
|
||||
qr_blocks = MOTION_QR_BLOCKS["present" if has_qr else "absent"]
|
||||
return MotionPlan(
|
||||
prompt=MOTION_FRAME.format(body=body, **qr_blocks),
|
||||
has_qr=has_qr,
|
||||
kept=kept,
|
||||
dropped=dropped,
|
||||
)
|
||||
|
||||
|
||||
async def plan_motion(poster: Path | Image.Image, *, has_qr: bool | None = None,
|
||||
force_motions: list[str] | None = None, extra: str = "") -> MotionPlan:
|
||||
"""force_motions를 주면 VLM을 건너뛴다 — 검수 게이트의 수동 추가·제거용. 빈 리스트면 0종."""
|
||||
source = (Image.open(poster) if isinstance(poster, Path) else poster).convert("RGB")
|
||||
|
||||
if force_motions is None:
|
||||
answer = await motion_llm.ask_with_images(
|
||||
MotionAnswer, MOTION_VLM_PROMPT,
|
||||
[("포스터:", to_data_uri(source, POSTER_MAX_SIZE))])
|
||||
elements = answer.elements
|
||||
else:
|
||||
unknown = [key for key in force_motions if key not in MOTION_PHRASES]
|
||||
if unknown:
|
||||
raise ValueError(f"미지의 모션 키: {unknown} — 허용: {', '.join(MOTION_PHRASES)}")
|
||||
elements = [MotionElement(motion=key, what="검수 게이트 수동 지정", confident=True)
|
||||
for key in force_motions]
|
||||
|
||||
# QR 언급은 주문서다 — 없는 포스터에 보존 문구를 넣으면 모델이 QR을 그려 넣는다
|
||||
if has_qr is None:
|
||||
has_qr = qr_box(source) is not None
|
||||
return build_prompt(elements, has_qr, extra)
|
||||
@@ -0,0 +1,34 @@
|
||||
An illustrated festival poster comes alive as a bold motion piece.
|
||||
Locked-off camera: the poster never moves, but the artwork inside it does.
|
||||
|
||||
STYLE LOCK - keep the poster's exact illustration style, palette and lighting in
|
||||
every frame. Do not re-render anything as photoreal, 3D or textured. Flat shapes
|
||||
stay flat. Line weights and colours stay exactly as drawn.
|
||||
|
||||
ANIMATE ONLY WHAT IS ALREADY DRAWN. Do not invent, add or introduce any object,
|
||||
structure, ride, person or vehicle that is not already visible in the source image.
|
||||
|
||||
WHAT MOVES - and how, unmistakably:
|
||||
|
||||
{body}
|
||||
|
||||
Everything else holds still.
|
||||
|
||||
FROZEN - pixel-identical, never redrawn, moved or restyled: all Korean and Latin
|
||||
text, the title, the slogan, the dates, the place names, {frozen_block} The layout and composition do not
|
||||
change.
|
||||
|
||||
DO NOT TOUCH THE PRINTED LAYER. This image already carries printed text and
|
||||
graphics painted onto it. Reproduce every letter, digit and mark exactly as it
|
||||
appears - same glyphs, same position, same size. Never repaint, re-letter,
|
||||
translate, duplicate or "improve" any text.
|
||||
|
||||
ADD NOTHING. {add_nothing_line}Do not add any new text, caption, title, subtitle, logo, emblem,
|
||||
seal, stamp, QR code, watermark, border, frame or white margin. The frame edges
|
||||
stay exactly as they are. If you are unsure whether something is text, leave it
|
||||
untouched.
|
||||
|
||||
No camera movement, no zoom, no colour grading, no added film grain.
|
||||
|
||||
AUDIO: ambient scene sound only. No music, no melody, no singing, no speech or
|
||||
narration of any kind.
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"firework": "FIREWORKS BURST. The firework blooms already in the sky keep exploding: petals of light race outward from each core, crackle into hundreds of sparks, then drift down as glittering embers and fade. New bursts open at those same positions, staggered, over and over - in the colours already drawn.",
|
||||
"water": "THE WATER CHURNS. The current spirals and roars: foam shears off the crests, spray flicks up where currents collide, and the water races on.",
|
||||
"wave": "THE WAVES ROLL. Swells rise and break in place, white foam churning along each crest, then sliding back.",
|
||||
"cloud": "CLOUDS DRIFT. They slide slowly across the sky, thinning and thickening as they go, never leaving the frame.",
|
||||
"smoke": "SMOKE CURLS. It rises and coils, thinning as it climbs.",
|
||||
"moon": "THE MOON BREATHES. Its glow pulses - the halo swells and softens.",
|
||||
"sun": "THE SUN BLAZES. Its rays extend and retract, flaring outward and easing back.",
|
||||
"star": "STARS FLICKER. The scattered specks twinkle hard, each on its own rhythm.",
|
||||
"light": "THE LIGHTS TWINKLE. Lanterns and bulbs brighten and dim, each at its own pace.",
|
||||
"flag": "FABRIC SNAPS. Flags and banners ripple and stream in the wind.",
|
||||
"foliage": "LEAVES SWAY. Branches and grass bend and spring back in a light breeze.",
|
||||
"wheel": "THE WHEEL TURNS. It rotates slowly and continuously, never speeding up.",
|
||||
"vessel": "THE VESSEL RIDES THE SWELL. It rocks and pitches on the moving water. Its silhouette stays one flat solid shape and never gains detail.",
|
||||
"crowd": "THE FIGURES STIR. They shift their weight and sway slightly in place, never walking out of position.",
|
||||
"ray": "THE LIGHT RAYS PULSE. The beams already radiating across the artwork brighten and stretch outward, then ease back, shimmering as they go. No new light source appears.",
|
||||
"snow": "SNOW DRIFTS. The flakes and sparkles already scattered in the air float slowly downward and twinkle, each on its own path.",
|
||||
"fog": "FOG BREATHES. The haze already in the dark thickens and thins, curling slowly across the scene, never covering the text.",
|
||||
"glow": "THE GLOW WAVERS. The warm light already on the scene flickers like candlelight - brightening and dimming - and the shadows it casts shift with it. The light source itself never moves."
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"present": {
|
||||
"frozen_block": "the QR codes, and the\nsponsor logo bar. Never redraw, blur, distort or restyle the QR code - its black\nmodules must stay sharp, square and separated.",
|
||||
"add_nothing_line": ""
|
||||
},
|
||||
"absent": {
|
||||
"frozen_block": "and the sponsor logo bar.",
|
||||
"add_nothing_line": "This poster has NO QR code - never add one. "
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
축제·공연 포스터다. **이 그림 안에 실제로 그려져 있는 것만** 골라라.
|
||||
|
||||
아래 목록에서 포스터에 **실제로 보이는** 항목만 답한다. 없으면 넣지 마라.
|
||||
있을 법한 것, 축제라면 보통 있는 것을 추측해서 넣으면 안 된다.
|
||||
|
||||
firework 불꽃놀이 / water 물살·소용돌이·강 / wave 파도 / cloud 구름 / smoke 연기
|
||||
moon 달 / sun 해 / star 별 / light 등불·전구·조명 / flag 깃발·현수막·천
|
||||
foliage 나뭇잎·풀 / wheel 바퀴·관람차·풍차·회전목마 / vessel 배·선박
|
||||
crowd 사람 무리 / ray 방사형 광선·빛줄기 / snow 눈·반짝이 입자 / fog 안개·연무
|
||||
glow 촛불·붉은 광원처럼 흔들리는 빛과 그림자
|
||||
|
||||
- motion 은 위 영어 키 그대로.
|
||||
- what 은 그것이 포스터에서 무엇인지 한국어 한 줄.
|
||||
- confident 는 확실히 보이면 true, 애매하면 false. **애매하면 false로 두어라.**
|
||||
- 글자·로고·QR코드는 그림이 아니다. 절대 넣지 마라.
|
||||
@@ -0,0 +1,44 @@
|
||||
"""motion 수동 확인용.
|
||||
|
||||
사용: uv run python test_motion.py <포스터경로> [모션키,쉼표구분]
|
||||
모션키를 주면 VLM을 건너뛰고 그 목록으로 프롬프트를 만든다(빈 문자열이면 0종).
|
||||
결과는 test_result/<이름>.motion.txt(채택·탈락)와 <이름>.i2v.txt(프롬프트 원문)로 떨어진다.
|
||||
"""
|
||||
import asyncio
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from motion import plan_motion
|
||||
|
||||
TEST_RESULT_DIR = Path(__file__).parent / "test_result"
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
poster_path = Path(sys.argv[1])
|
||||
force_motions = None
|
||||
if len(sys.argv) > 2:
|
||||
force_motions = [key.strip() for key in sys.argv[2].split(",") if key.strip()]
|
||||
|
||||
TEST_RESULT_DIR.mkdir(exist_ok=True)
|
||||
output_base = TEST_RESULT_DIR / poster_path.stem
|
||||
|
||||
plan = await plan_motion(poster_path, force_motions=force_motions)
|
||||
|
||||
summary_path = output_base.with_suffix(".motion.txt")
|
||||
prompt_path = output_base.with_suffix(".i2v.txt")
|
||||
summary_path.write_text(
|
||||
plan.model_dump_json(indent=2, exclude={"prompt"}), encoding="utf-8")
|
||||
prompt_path.write_text(plan.prompt, encoding="utf-8")
|
||||
|
||||
print(f"QR {'있음' if plan.has_qr else '없음'} / 채택 {len(plan.kept)}종")
|
||||
for item in plan.kept:
|
||||
print(f" ✓ {item.motion:9} {item.what}")
|
||||
for item in plan.dropped:
|
||||
print(f" ✗ {item.motion:9} {item.what} — {item.why}")
|
||||
if not plan.kept:
|
||||
print("\n※ 움직일 요소가 없다 — i2v를 건너뛰고 정지 포스터로 가는 것이 안전하다.")
|
||||
print(f"\n{summary_path}\n{prompt_path}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
@@ -1,3 +1,4 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
RAW_PROMPT_DIR = Path(__file__).resolve().parent.parent / "raw_prompt"
|
||||
@@ -5,3 +6,7 @@ RAW_PROMPT_DIR = Path(__file__).resolve().parent.parent / "raw_prompt"
|
||||
|
||||
def load_prompt(name: str) -> str:
|
||||
return (RAW_PROMPT_DIR / f"{name}.txt").read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def load_prompt_json(name: str) -> dict:
|
||||
return json.loads((RAW_PROMPT_DIR / f"{name}.json").read_text(encoding="utf-8"))
|
||||
@@ -0,0 +1,109 @@
|
||||
"""포스터에서 QR 흰 카드를 찾는다.
|
||||
|
||||
"우상단에서 가장 큰 흰 블롭"을 QR로 삼던 검출기는 하늘 그러데이션·흰 글자띠·색 체크무늬를
|
||||
줄줄이 걸었다. 배치 27장으로 캘리브레이션해 파인더 패턴(1:1:3:1:1)까지 확인한다.
|
||||
"""
|
||||
import numpy as np
|
||||
from PIL import Image
|
||||
from scipy import ndimage
|
||||
|
||||
# QR은 우상단에만 있지 않다 — 우하단에 단 포스터를 통째로 놓친 적이 있다. 네 귀퉁이를 다 본다.
|
||||
CORNER_WINDOWS = ((0.70, 0.00, 1.00, 0.18), (0.70, 0.82, 1.00, 1.00),
|
||||
(0.00, 0.00, 0.30, 0.18), (0.00, 0.82, 0.30, 1.00))
|
||||
FINDER_HIT_THRESHOLD = 30
|
||||
|
||||
|
||||
def otsu_threshold(gray: np.ndarray) -> int:
|
||||
histogram, _ = np.histogram(gray, bins=256, range=(0, 256))
|
||||
dark_counts = np.cumsum(histogram)
|
||||
light_counts = gray.size - dark_counts
|
||||
cumulative = np.cumsum(histogram * np.arange(256))
|
||||
dark_mean = np.divide(cumulative, dark_counts, out=np.zeros(256), where=dark_counts > 0)
|
||||
light_mean = np.divide(cumulative[-1] - cumulative, light_counts,
|
||||
out=np.zeros(256), where=light_counts > 0)
|
||||
return int(np.argmax(dark_counts * light_counts * (dark_mean - light_mean) ** 2))
|
||||
|
||||
|
||||
def finder_pattern_hits(binary: np.ndarray) -> int:
|
||||
"""QR 파인더 패턴(모서리 겹눈)의 1:1:3:1:1 런 비율을 만족하는 스캔라인 수."""
|
||||
hits = 0
|
||||
for line in binary:
|
||||
change_points = np.flatnonzero(np.diff(line)) + 1
|
||||
if len(change_points) < 4:
|
||||
continue
|
||||
bounds = np.concatenate(([0], change_points, [len(line)]))
|
||||
runs, values = np.diff(bounds), line[bounds[:-1]]
|
||||
for start in range(len(runs) - 4):
|
||||
if values[start] != 1: # 어두운 런에서 시작해야 한다
|
||||
continue
|
||||
run = runs[start:start + 5]
|
||||
unit = run.sum() / 7.0
|
||||
if unit >= 1 and abs(run[0] - unit) <= .6 * unit and abs(run[1] - unit) <= .6 * unit \
|
||||
and abs(run[2] - 3 * unit) <= 1.2 * unit \
|
||||
and abs(run[3] - unit) <= .6 * unit and abs(run[4] - unit) <= .6 * unit:
|
||||
hits += 1
|
||||
break
|
||||
return hits
|
||||
|
||||
|
||||
def is_qr(poster: Image.Image, box: tuple[int, int, int, int]) -> bool:
|
||||
"""밝은 블롭이 정말 QR인가. 정답과 오검출이 aspect·채도·잉크·파인더 어느 축으로도 겹치지 않는다."""
|
||||
left, top, right, bottom = box
|
||||
width, height = right - left, bottom - top
|
||||
if not (0.75 <= width / max(height, 1) <= 1.35):
|
||||
return False
|
||||
if not (0.015 <= width / poster.width <= 0.15):
|
||||
return False
|
||||
card = poster.crop(box).convert("RGB")
|
||||
if max(width, height) > 400: # 파인더 스캔은 400px면 충분하다
|
||||
scale = 400 / max(width, height)
|
||||
card = card.resize((max(1, round(width * scale)), max(1, round(height * scale))),
|
||||
Image.LANCZOS)
|
||||
pixels = np.asarray(card).astype(np.float32)
|
||||
if float(np.mean(pixels.max(2) - pixels.min(2))) > 22: # QR은 무채색이다
|
||||
return False
|
||||
gray = pixels.mean(2)
|
||||
binary = (gray < otsu_threshold(gray)).astype(np.uint8)
|
||||
if not (0.15 <= float(binary.mean()) <= 0.60): # 글자는 더 성기고 반전 블록은 더 빽빽하다
|
||||
return False
|
||||
return (finder_pattern_hits(binary) >= FINDER_HIT_THRESHOLD
|
||||
and finder_pattern_hits(binary.T) >= FINDER_HIT_THRESHOLD)
|
||||
|
||||
|
||||
def find_white_blobs(poster: Image.Image, window: tuple[float, float, float, float],
|
||||
top_n: int = 6) -> list[tuple[int, int, int, int]]:
|
||||
"""정규 좌표 창 안의 밝은 블롭 bbox들. 큰 것부터."""
|
||||
width, height = poster.size
|
||||
offset_x, offset_y = int(width * window[0]), int(height * window[1])
|
||||
region = np.asarray(poster.convert("RGB")).astype(np.float32)[
|
||||
offset_y:int(height * window[3]), offset_x:int(width * window[2])]
|
||||
if region.size == 0:
|
||||
return []
|
||||
white = ndimage.binary_closing(region.min(2) > 205, np.ones((9, 9), bool))
|
||||
labels, count = ndimage.label(white)
|
||||
if count == 0:
|
||||
return []
|
||||
sizes = ndimage.sum(white, labels, range(1, count + 1))
|
||||
boxes = ndimage.find_objects(labels, max_label=count)
|
||||
found = []
|
||||
for index in np.argsort(sizes)[::-1][:top_n]: # 가장 큰 게 QR이 아닐 수도 있다
|
||||
rows, cols = boxes[int(index)]
|
||||
found.append((offset_x + cols.start, offset_y + rows.start,
|
||||
offset_x + cols.stop, offset_y + rows.stop))
|
||||
return found
|
||||
|
||||
|
||||
def qr_box(poster: Image.Image, strict: bool = True,
|
||||
window: tuple[float, float, float, float] | None = None
|
||||
) -> tuple[int, int, int, int] | None:
|
||||
"""QR 흰 카드의 bbox. 없으면 None.
|
||||
|
||||
strict=True(원본 포스터용): is_qr을 통과한 블롭만. QR의 유무는 원본이 정한다.
|
||||
strict=False(모델 출력 검증용): 창 안의 가장 큰 흰 블롭. 모델이 뭉갠 QR은 파인더가
|
||||
살아남지 못하므로, 묻는 것은 "QR인가"가 아니라 "예상한 자리에 흰 카드가 있는가"다.
|
||||
"""
|
||||
for corner in ((window,) if window else CORNER_WINDOWS):
|
||||
for box in find_white_blobs(poster, corner):
|
||||
if not strict or is_qr(poster, box):
|
||||
return box
|
||||
return None
|
||||
+34
-2
@@ -1,6 +1,12 @@
|
||||
# known_issue.md
|
||||
|
||||
## `recommended_mode` — 죽은 필드
|
||||
이슈는 파이프라인 단계별로 묶는다.
|
||||
단계: ① detect ② narration_text ③ motion ④ tts ⑤ bgm ⑥ i2v ⑦ render.
|
||||
어느 단계에도 속하지 않으면 공통에 둔다.
|
||||
|
||||
## ① detect
|
||||
|
||||
### `recommended_mode` — 죽은 필드
|
||||
|
||||
`models/detect.py`의 `Regions.recommended_mode`는 현재 아무 데서도 읽히지 않는다.
|
||||
`detect.py`가 `title_style == "calligraphy"`이면 `layered`, 아니면 `camera`로 채우기만 한다.
|
||||
@@ -16,7 +22,7 @@
|
||||
|
||||
판단 유보로 필드는 남겨둔다. 레이어 경로를 되살리지 않기로 하면 지운다.
|
||||
|
||||
## `GridBox` 좌표 순서가 강제되지 않는다
|
||||
### `GridBox` 좌표 순서가 강제되지 않는다
|
||||
|
||||
`answers/detect_answer.py`의 `GridBox`는 `x0 < x1`, `y0 < y1`을 보장하지 않는다.
|
||||
프롬프트에도 순서 조건이 없고 스키마에도 밸리데이터가 없다.
|
||||
@@ -28,3 +34,29 @@ PIL이 예외를 낸다.
|
||||
|
||||
원본 CLI(`detect_regions.py`)에도 같은 구멍이 있다.
|
||||
막으려면 프롬프트에 순서 조건을 넣거나 `GridBox`에 밸리데이터를 단다.
|
||||
|
||||
### focal_points를 VLM이 실제 지점이 아니라 멋대로 잡는다
|
||||
|
||||
focal_points 좌표가 포스터를 보고 잰 값이 아니라 그럴듯하게 배치한 값으로 나온다.
|
||||
관측된 형태는 균등 간격·동일 높이지만, 원인이 같다면 다른 양상으로도 나올 수 있다.
|
||||
|
||||
이유는 아마도 둘이다.
|
||||
|
||||
- **검증이 없다.** 박스는 VLM이 대충 답해도 `tighten_box()`가 잉크 경계로 다시 잡아준다.
|
||||
focal_points는 그 후처리가 없어 VLM 값이 곧 최종값이다.
|
||||
- **틀릴 수 없는 답이다.** 박스와 달리 focal은 정답 경계가 없어서, 모델이 지어내도
|
||||
스키마도 후처리도 걸러내지 못한다.
|
||||
|
||||
프롬프트로 격자를 읽게 못박거나, focal도 박스로 받아 후처리를 태우는 방향이 있다.
|
||||
후자는 잉크 기반이라 글자에는 듣고 그림에는 덜 듣는다.
|
||||
|
||||
## ② narration_text
|
||||
|
||||
### `models/narration.py`가 없다
|
||||
|
||||
`generate_narration()`이 `answers`의 `NarrationAnswer`를 그대로 반환한다.
|
||||
detect와 달리 후처리가 없어 LLM 응답이 곧 결과이고, 지금 모델을 만들면 필드를 그대로
|
||||
베끼는 껍데기가 되기 때문이다.
|
||||
|
||||
대신 `answers` 타입이 이 단계의 공개 반환 타입이 되어 LLM 레이어가 위로 새어나간다.
|
||||
API 레이어가 다른 형태를 요구하면 그때 `models/narration.py`를 만들고 변환을 넣는다.
|
||||
Reference in new issue
Block a user