(WIP) config 자동 생성 및 gate4 / 동작 검증 실패 (local RAM 부족)
This commit is contained in:
1 parent
89d9062f35
commit
c3f40899a4
25 files changed
+679
-1
No files matched your search
@@ -0,0 +1,64 @@
|
||||
"""⑩ config 생성 수동 확인용.
|
||||
|
||||
사용: uv run python -m tests.playreel.test_build_layer_config <goods_id>
|
||||
upscaled.png 에서 detect + 인물 사각을 뽑아 layer_config.json 을 만든다.
|
||||
결과는 nol_<goods_id>/layer_config.json 과 layer_config_check.jpg.
|
||||
"""
|
||||
import asyncio
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from PIL import Image, ImageDraw
|
||||
|
||||
from services.build_layer_config import build_layer_config
|
||||
|
||||
TEST_RESULT_DIR = Path(__file__).parent.parent / "test_result" / "playreel"
|
||||
COLORS = {"fixed": (255, 60, 60), "sil": (255, 255, 0), "punch": (60, 220, 255)}
|
||||
|
||||
|
||||
def draw_check(poster: Image.Image, config) -> Image.Image:
|
||||
overlay = poster.convert("RGB").copy()
|
||||
width, height = overlay.size
|
||||
draw = ImageDraw.Draw(overlay)
|
||||
line = max(3, width // 300)
|
||||
|
||||
def box(rect, color, label):
|
||||
draw.rectangle([rect[0] * width, rect[1] * height, rect[2] * width, rect[3] * height],
|
||||
outline=color, width=line)
|
||||
draw.text((rect[0] * width + 6, rect[1] * height + 4), label, fill=color)
|
||||
|
||||
for rect in config.fixed_rects:
|
||||
box(rect, COLORS["fixed"], "fixed")
|
||||
if config.sil_box[2] > config.sil_box[0]:
|
||||
box(config.sil_box, COLORS["sil"], "person")
|
||||
for rect, at, peak in config.punches:
|
||||
box(rect, COLORS["punch"], f"punch {at}s x{peak}")
|
||||
return overlay
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
goods_id = sys.argv[1]
|
||||
product_dir = TEST_RESULT_DIR / f"nol_{goods_id}"
|
||||
poster_path = product_dir / "upscaled.png"
|
||||
if not poster_path.exists():
|
||||
raise SystemExit(f"{poster_path} 없음 — test_upscale_poster 를 먼저 돌릴 것")
|
||||
|
||||
config = await build_layer_config(poster_path)
|
||||
|
||||
config_path = product_dir / "layer_config.json"
|
||||
check_path = product_dir / "layer_config_check.jpg"
|
||||
config_path.write_text(config.model_dump_json(indent=2), encoding="utf-8")
|
||||
with Image.open(poster_path) as poster:
|
||||
draw_check(poster, config).save(check_path, quality=90)
|
||||
|
||||
print(f"mask={config.mask.mode} · 고정사각 {len(config.fixed_rects)}"
|
||||
f" · 글리프 {len(config.glyphs)} · 펀치 {len(config.punches)}")
|
||||
for rect, at, peak in config.punches:
|
||||
print(f" punch {at}s x{peak} {tuple(round(v, 3) for v in rect)}")
|
||||
if config.sil_box[2] <= config.sil_box[0]:
|
||||
print("※ 인물 사각을 못 잡았다 — 인물이 없거나 VLM이 놓쳤다")
|
||||
print(f"\n{config_path}\n{check_path}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
@@ -0,0 +1,86 @@
|
||||
"""⑪ compose 수동 확인용 — 30초 롱컷 조립.
|
||||
|
||||
사용: uv run python -m tests.playreel.test_compose_long <goods_id> [variant]
|
||||
hybrid.mp4 가 있으면 그것을, 없으면 clip.mp4 를 훅으로 쓴다.
|
||||
결과는 nol_<goods_id>/longcut_<variant>.mp4 와 longcut_<variant>.json.
|
||||
"""
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from PIL import Image
|
||||
|
||||
from models.detail_section import DetailSection
|
||||
from models.longcut import EndBandInfo
|
||||
from models.nol import NolMeta
|
||||
from models.tts import NarrationTimeline
|
||||
from services.compose_long import compose_longcut
|
||||
|
||||
TEST_RESULT_DIR = Path(__file__).parent.parent / "test_result" / "playreel"
|
||||
QR_DIR = Path(__file__).parent.parent.parent / "assets" / "nol"
|
||||
|
||||
|
||||
def load_sections(sections_dir: Path) -> list[DetailSection]:
|
||||
index_path = sections_dir / "index.json"
|
||||
if not index_path.exists():
|
||||
raise SystemExit(f"{index_path} 없음 — test_split_detail 을 먼저 돌릴 것")
|
||||
return [DetailSection(source=item["source"], index=item["index"],
|
||||
y0=item["y0"], y1=item["y1"],
|
||||
image=Image.open(sections_dir / item["file"]),
|
||||
tag=item["tag"])
|
||||
for item in json.loads(index_path.read_text(encoding="utf-8"))]
|
||||
|
||||
|
||||
def band_info(meta: NolMeta) -> EndBandInfo:
|
||||
period = f"{meta.play_start_date or ''} ~ {meta.play_end_date or ''}".strip(" ~")
|
||||
detail = " · ".join(part for part in (period.replace("-", "."), meta.place_name) if part)
|
||||
return EndBandInfo(title=meta.goods_name or "", detail=detail)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
goods_id = sys.argv[1]
|
||||
variant = sys.argv[2] if len(sys.argv) > 2 else "v1"
|
||||
product_dir = TEST_RESULT_DIR / f"nol_{goods_id}"
|
||||
|
||||
hybrid = product_dir / "hybrid.mp4"
|
||||
clip_path = hybrid if hybrid.exists() else product_dir / "clip.mp4"
|
||||
required = [product_dir / "upscaled.png", clip_path,
|
||||
product_dir / "timeline.json", product_dir / "narration.mp3"]
|
||||
for path in required:
|
||||
if not path.exists():
|
||||
raise SystemExit(f"{path} 없음 — 앞 단계를 먼저 돌릴 것")
|
||||
if not hybrid.exists():
|
||||
print("※ hybrid.mp4 가 없어 원본 클립을 쓴다 — 제목이 흔들릴 수 있다")
|
||||
|
||||
output_path = product_dir / f"longcut_{variant}.mp4"
|
||||
if output_path.exists():
|
||||
raise SystemExit(f"덮어쓰기 금지: {output_path} — variant 를 바꿀 것")
|
||||
|
||||
meta = NolMeta.model_validate_json((product_dir / "meta.json").read_text(encoding="utf-8"))
|
||||
timeline = NarrationTimeline.model_validate_json(
|
||||
(product_dir / "timeline.json").read_text(encoding="utf-8"))
|
||||
bgm_path = product_dir / "bgm.mp3"
|
||||
qr_path = QR_DIR / f"qr_{goods_id}.png"
|
||||
|
||||
result = compose_longcut(
|
||||
product_dir / "upscaled.png", clip_path.read_bytes(), timeline,
|
||||
(product_dir / "narration.mp3").read_bytes(),
|
||||
load_sections(product_dir / "sections"), band_info(meta),
|
||||
bgm_mp3=bgm_path.read_bytes() if bgm_path.exists() else None,
|
||||
qr=Image.open(qr_path) if qr_path.exists() else None)
|
||||
|
||||
output_path.write_bytes(result.video)
|
||||
(product_dir / f"longcut_{variant}.json").write_text(
|
||||
result.plan.model_dump_json(indent=2), encoding="utf-8")
|
||||
|
||||
for scene in result.plan.scenes:
|
||||
label = f"{scene.section} [{scene.tag}]" if scene.section else ""
|
||||
print(f" 큐{scene.cue} {scene.kind:7} {label}")
|
||||
if not qr_path.exists():
|
||||
print(f"※ {qr_path.name} 없음 — 엔드밴드에 QR을 안 넣는다")
|
||||
print(f"\n{result.frames}프레임 · {result.duration:.2f}초 · {len(result.video) / 1e6:.1f}MB")
|
||||
print(output_path)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
# Playreel 롱컷 — 게이트 ④ 승인 뒤, 게이트 ⑤(final_confirm) 직전까지.
|
||||
# 사용: tests/run_playreel_after_gate4.sh <goods_id> [variant]
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
goods_id="${1:?사용: $0 <goods_id> [variant]}"
|
||||
variant="${2:-v1}"
|
||||
config="tests/test_result/playreel/nol_${goods_id}/layer_config.json"
|
||||
|
||||
run() { echo; echo "── $1 ──"; shift; uv run python -m "$@"; }
|
||||
|
||||
if [ ! -f "$config" ]; then
|
||||
run "⑩ config 생성" tests.playreel.test_build_layer_config "$goods_id"
|
||||
fi
|
||||
run "⑩ hybrid" tests.playreel.test_hybrid_poster "$goods_id" "$config"
|
||||
run "⑪ compose" tests.playreel.test_compose_long "$goods_id" "$variant"
|
||||
|
||||
cat <<EOF
|
||||
|
||||
══ 게이트 ⑤ final_confirm — 마지막 확인 ══
|
||||
longcut_${variant}.mp4 를 보고 여섯 가지를 본다
|
||||
첫 프레임이 포스터 원본인가
|
||||
제목이 온전한가
|
||||
상세페이지가 풀프레임으로 스크롤되는가
|
||||
캐스팅 스케줄이 들어갔는가
|
||||
엔드밴드에 로고·CTA·QR이 있는가
|
||||
나레이션이 BGM에 묻히지 않는가
|
||||
|
||||
다시 만들 때는 variant 를 바꾼다 — 덮어쓰기는 막혀 있다.
|
||||
EOF
|
||||
Reference in new issue
Block a user