worldmodel-bench / wm_bench_verify.py
SeaWolf-AI's picture
Upload 9 files
ee97e7d verified
"""
World Model Bench โ€” Scoring Verification Suite v1.0
๋ชฉ์ : ์ฑ„์  ํ•จ์ˆ˜์˜ ๋ชจ๋“  ๋ถ„๊ธฐ๋ฅผ ํ…Œ์ŠคํŠธํ•˜์—ฌ
"๋ˆ„๊ฐ€ ๋Œ๋ ค๋„ ๊ฐ™์€ ์ ์ˆ˜" ๋ณด์žฅ
๊ฒ€์ฆ ๋ฒ”์œ„:
- ํŒŒ์„œ ์—ฃ์ง€์ผ€์ด์Šค (๋นˆ ์ž…๋ ฅ, ์ž˜๋ชป๋œ ํฌ๋งท, ๋Œ€์†Œ๋ฌธ์ž ๋“ฑ)
- 10๊ฐœ ์ฑ„์  ํ•จ์ˆ˜ ร— ๋ชจ๋“  ์ ์ˆ˜ ๋ถ„๊ธฐ
- ๊ฒฝ๊ณ„๊ฐ’ ํ…Œ์ŠคํŠธ (0์ , ๋งŒ์ , ๋ถ€๋ถ„ ์ ์ˆ˜)
- ํ†ตํ•ฉ ์ ์ˆ˜ ๊ณ„์‚ฐ + ๋“ฑ๊ธ‰ ๊ฒฝ๊ณ„
"""
import sys
sys.path.insert(0, '/mnt/user-data/outputs')
from wm_bench_scoring import (
parse_predict_line, parse_motion_line, PredictDirection,
get_action_intensity, get_emotion_intensity, get_motion_direction,
count_descriptors,
score_c01, score_c02, score_c03, score_c04, score_c05,
score_c06, score_c07, score_c08, score_c09, score_c10,
calculate_wm_score,
)
passed = 0
failed = 0
total = 0
def check(test_name, condition, detail=""):
global passed, failed, total
total += 1
if condition:
passed += 1
print(f" โœ“ {test_name}")
else:
failed += 1
print(f" โœ— {test_name} โ€” {detail}")
print("=" * 70)
print(" WM Bench Scoring Verification Suite")
print("=" * 70)
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
print("\n[1/12] ํŒŒ์„œ: parse_predict_line")
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
# ์ •์ƒ ์ž…๋ ฅ
p = parse_predict_line("PREDICT: left=safe(open), right=danger(wall), fwd=danger(beast), back=safe")
check("์ •์ƒ ํŒŒ์‹ฑ 4๋ฐฉํ–ฅ", len(p) == 4)
check("left=safe", p["left"].is_safe and not p["left"].is_danger)
check("right=danger", p["right"].is_danger and not p["right"].is_safe)
check("right reason=wall", p["right"].reason == "wall")
check("fwd reason=beast", p["fwd"].reason == "beast")
check("back=safe no reason", p["back"].is_safe and p["back"].reason is None)
# ๋Œ€์†Œ๋ฌธ์ž ํ˜ผํ•ฉ
p2 = parse_predict_line("PREDICT: Left=Safe(Open), RIGHT=DANGER(WALL), FWD=danger(Beast), Back=safe")
check("๋Œ€์†Œ๋ฌธ์ž left safe", p2["left"].is_safe)
check("๋Œ€์†Œ๋ฌธ์ž right danger", p2["right"].is_danger)
check("๋Œ€์†Œ๋ฌธ์ž reason", p2["right"].reason == "wall")
# forward/backward ์ •๊ทœํ™”
p3 = parse_predict_line("PREDICT: left=safe, right=safe, forward=danger(wall), backward=safe")
check("forwardโ†’fwd ์ •๊ทœํ™”", "fwd" in p3)
check("backwardโ†’back ์ •๊ทœํ™”", "back" in p3)
# ๋นˆ ์ž…๋ ฅ
p4 = parse_predict_line("")
check("๋นˆ ์ž…๋ ฅ ๋นˆ ๊ฒฐ๊ณผ", len(p4) == 0)
# PREDICT: ์—†๋Š” ๊ฒฝ์šฐ
p5 = parse_predict_line("left=safe, right=danger(wall)")
check("PREDICT: ์—†์–ด๋„ ํŒŒ์‹ฑ", len(p5) >= 2)
# ์ด์œ  ์—†๋Š” danger
p6 = parse_predict_line("PREDICT: left=danger, right=safe")
check("์ด์œ  ์—†๋Š” danger", p6["left"].is_danger and p6["left"].reason is None)
# ๊ณต๋ฐฑ ๋งŽ์€ ๊ฒฝ์šฐ
p7 = parse_predict_line("PREDICT: left = safe(open) , right = danger( wall ) ")
check("๊ณต๋ฐฑ ๊ณผ๋‹ค ํŒŒ์‹ฑ", "left" in p7 or len(p7) >= 1)
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
print("\n[2/12] ํŒŒ์„œ: parse_motion_line")
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
m1 = parse_motion_line("MOTION: a person sprinting right in terror")
check("์ •์ƒ ํŒŒ์‹ฑ", m1 == "a person sprinting right in terror")
m2 = parse_motion_line("MOTION:a person walking forward")
check("๊ณต๋ฐฑ ์—†์ด", "walking forward" in m2)
m3 = parse_motion_line("a person just walking")
check("MOTION: ์—†์–ด๋„", "walking" in m3)
m4 = parse_motion_line("MOTION: A Person SPRINTING LEFT")
check("๋Œ€์†Œ๋ฌธ์ž ์†Œ๋ฌธ์žํ™”", "sprinting" in m4)
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
print("\n[3/12] ํ‚ค์›Œ๋“œ ์‚ฌ์ „: ํ–‰๋™ ๊ฐ•๋„")
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
check("sprint=4", get_action_intensity("sprinting away") == 4)
check("walk=2", get_action_intensity("walking slowly") == 2)
check("desperate=5", get_action_intensity("desperate escape") == 5)
check("stand=1", get_action_intensity("standing still") == 1)
check("๋นˆ ํ…์ŠคํŠธ=0", get_action_intensity("") == 0)
check("๋ณตํ•ฉ: sprint+desperate=5", get_action_intensity("desperately sprinting") == 5)
check("unknown word=0", get_action_intensity("xyzzy foobar") == 0)
check("freeze=1", get_action_intensity("freezing in place") == 1)
check("run=4", get_action_intensity("running fast") == 4)
check("jog=3", get_action_intensity("jogging ahead") == 3)
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
print("\n[4/12] ํ‚ค์›Œ๋“œ ์‚ฌ์ „: ๊ฐ์ • ๊ฐ•๋„")
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
check("terror=5", get_emotion_intensity("in terror") == 5)
check("fear=4", get_emotion_intensity("with fear") == 4)
check("anxious=3", get_emotion_intensity("feeling anxious") == 3)
check("cautious=2", get_emotion_intensity("being cautious") == 2)
check("calm=1", get_emotion_intensity("staying calm") == 1)
check("๋นˆ=0", get_emotion_intensity("") == 0)
check("terrified=5", get_emotion_intensity("terrified") == 5)
check("๋ณตํ•ฉ: terror+fear=5", get_emotion_intensity("terrified with fear") == 5)
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
print("\n[5/12] ํ‚ค์›Œ๋“œ ์‚ฌ์ „: ๋ฐฉํ–ฅ ์ถ”์ถœ")
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
check("right", get_motion_direction("sprinting right") == "right")
check("left", get_motion_direction("moving left") == "left")
check("forwardโ†’fwd", get_motion_direction("walking forward") == "fwd")
check("backwardโ†’back", get_motion_direction("stepping backward") == "back")
check("aroundโ†’back", get_motion_direction("turning around") == "back")
check("์—†์Œโ†’None", get_motion_direction("a person standing still") is None)
check("aheadโ†’fwd", get_motion_direction("running ahead") == "fwd")
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
print("\n[6/12] C01: ํ™˜๊ฒฝ ์ธ์‹ ์ •ํ™•๋„")
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
gt = {"left": "safe", "right": "danger", "fwd": "danger", "back": "safe"}
# ๋งŒ์ 
p = parse_predict_line("PREDICT: left=safe, right=danger(wall), fwd=danger(beast), back=safe")
s, r = score_c01({}, p, gt)
check("4/4 ์ •ํ™• = 20์ ", s == 20)
# 3/4
p = parse_predict_line("PREDICT: left=safe, right=danger(wall), fwd=safe, back=safe")
s, r = score_c01({}, p, gt)
check("3/4 ์ •ํ™• = 15์ ", s == 15)
# 2/4
p = parse_predict_line("PREDICT: left=safe, right=safe, fwd=safe, back=safe")
s, r = score_c01({}, p, gt)
check("2/4 ์ •ํ™• = 10์ ", s == 10)
# 0/4
p = parse_predict_line("PREDICT: left=danger, right=safe, fwd=safe, back=danger")
s, r = score_c01({}, p, gt)
check("0/4 ์ •ํ™• = 0์ ", s == 0)
# ๋ถ€๋ถ„ ์ถœ๋ ฅ (2๋ฐฉํ–ฅ๋งŒ)
p = parse_predict_line("PREDICT: left=safe, right=danger(wall)")
s, r = score_c01({}, p, gt)
check("2๋ฐฉํ–ฅ๋งŒ ์ถœ๋ ฅ (fwd,back ๋ˆ„๋ฝ)", s <= 10)
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
print("\n[7/12] C02: ๊ฐœ์ฒด ์ธ์‹ ๋ฐ ๋ถ„๋ฅ˜")
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
# ๋งŒ์ : ๋งน์ˆ˜ ์ •ํ™• ์ธ์‹
gt = {"entity_type": "beast", "entity_direction": "fwd", "is_threat": True}
p = parse_predict_line("PREDICT: left=safe, right=safe, fwd=danger(beast), back=safe")
s, r = score_c02({}, p, gt)
check("๋งน์ˆ˜ ์™„๋ฒฝ ์ธ์‹ = 20์ ", s == 20, f"got {s}")
# ์œ ํ˜• ์˜ค์ธ: beast๋ฅผ woman์œผ๋กœ
p = parse_predict_line("PREDICT: left=safe, right=safe, fwd=danger(woman), back=safe")
s, r = score_c02({}, p, gt)
check("์œ ํ˜• ์˜ค์ธ < 20์ ", s < 20 and s > 0, f"got {s}")
# ๋ฐฉํ–ฅ ์˜ค์ธ
p = parse_predict_line("PREDICT: left=danger(beast), right=safe, fwd=safe, back=safe")
s, r = score_c02({}, p, gt)
check("๋ฐฉํ–ฅ ์˜ค์ธ < 15์ ", s < 15, f"got {s}")
# ๊ฐœ์ฒด ์—†์Œ ์ •ํ™•
gt_none = {"entity_type": None, "entity_direction": None, "is_threat": False}
p = parse_predict_line("PREDICT: left=safe, right=safe, fwd=safe, back=safe")
s, r = score_c02({}, p, gt_none)
check("๊ฐœ์ฒด ์—†์Œ ์ •ํ™• = 20์ ", s == 20, f"got {s}")
# ๊ฐœ์ฒด ์—†๋Š”๋ฐ danger ์˜ค์ธ
p = parse_predict_line("PREDICT: left=safe, right=danger(beast), fwd=safe, back=safe")
s, r = score_c02({}, p, gt_none)
check("์—†๋Š”๋ฐ ์˜ค์ธ = 10์ ", s == 10, f"got {s}")
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
print("\n[8/12] C03: ์˜ˆ์ธก ๊ธฐ๋ฐ˜ ์ถ”๋ก ")
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
gt = {
"danger_directions": ["fwd", "left"],
"safe_directions": ["right", "back"],
"optimal_direction": "right",
}
# ๋งŒ์ : ์ตœ์  ๋ฐฉํ–ฅ + safe + PREDICT ์ผ๊ด€
p = parse_predict_line("PREDICT: left=danger(wall), right=safe(open), fwd=danger(beast), back=safe")
s, r = score_c03({}, p, "a person sprinting right away from beast", gt)
check("์ตœ์  ๋ฐฉํ–ฅ ์„ ํƒ = 20์ ", s == 20, f"got {s}")
# ์ฐจ์„ : back ์„ ํƒ (safe์ด์ง€๋งŒ optimal ์•„๋‹˜)
s, r = score_c03({}, p, "a person running backward quickly", gt)
check("์ฐจ์„  ๋ฐฉํ–ฅ back = 16์ ", s == 16, f"got {s}")
# ์œ„ํ—˜ ๋ฐฉํ–ฅ ์„ ํƒ
s, r = score_c03({}, p, "a person walking forward slowly", gt)
check("danger ๋ฐฉํ–ฅ fwd = ๋‚ฎ์€ ์ ์ˆ˜", s <= 8, f"got {s}")
# ๋ฐฉํ–ฅ ํ‚ค์›Œ๋“œ ์—†์Œ
s, r = score_c03({}, p, "a person standing in panic", gt)
check("๋ฐฉํ–ฅ ์—†์Œ = ๋ถ€๋ถ„ ์ ์ˆ˜", 0 <= s <= 10, f"got {s}")
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
print("\n[9/12] C04: ์œ„ํ˜‘ ์ฐจ๋ณ„ ๋ฐ˜์‘")
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
gt = {"expected_a_higher": True, "min_intensity_diff": 2}
# ๋งŒ์ : A ๊ฐ•ํ•จ, B ์•ฝํ•จ, ์ฐจ์ด ์ถฉ๋ถ„
s, r = score_c04("a person sprinting away in terror", "a person walking away cautiously", gt)
check("sprint(5) vs walk(2) = 20์ ", s == 20, f"got {s}")
# ๋™์ผ ๊ฐ•๋„
s, r = score_c04("a person walking forward", "a person walking slowly", gt)
check("๋™์ผ ๊ฐ•๋„ = ๋‚ฎ์€ ์ ์ˆ˜", s <= 10, f"got {s}")
# ์—ญ์ „: B๊ฐ€ ๋” ๊ฐ•ํ•จ (๊ฐ•๋„ ์ฐจ์ด๋Š” ์žˆ์œผ๋ฏ€๋กœ ๋ถ€๋ถ„ ์ ์ˆ˜)
s, r = score_c04("a person standing still", "a person sprinting away", gt)
check("์—ญ์ „ = ๋ถ€๋ถ„ ์ ์ˆ˜ (๊ฐ•๋„ ์ฐจ์ด๋Š” ์ธ์ •)", 8 <= s <= 14, f"got {s}")
# ์–‘์ชฝ ์ €๊ฐ•๋„ ๋ฐ˜์‘ (์ฐจ์ด ์—†์Œ)
s, r = score_c04("a person looking around", "a person standing there", gt)
check("์–‘์ชฝ ์ €๊ฐ•๋„ = ๋ถ€๋ถ„ ์ ์ˆ˜", 4 <= s <= 8, f"got {s}")
# ์ฐจ์ด ์žˆ์ง€๋งŒ ๋ถ€์กฑ
s, r = score_c04("a person jogging away", "a person walking forward", gt)
check("์ฐจ์ด 1 < min_diff 2", s < 20, f"got {s}")
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
print("\n[10/12] C05: ๊ฐ์ • ์—์Šค์ปฌ๋ ˆ์ด์…˜")
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
# ๋งŒ์ : ์ฆ๊ฐ€ ์ถ”์„ธ
s, r = score_c05([
"a person stepping back",
"a person running away in fear",
"a person desperately fleeing in terror",
], {"expected_trend": "increasing"})
check("์ฆ๊ฐ€ ์ถ”์„ธ = ๋†’์€ ์ ์ˆ˜", s >= 16, f"got {s}")
# ๊ฐ์†Œ ์ถ”์„ธ (๊ธฐ๋Œ€: ๊ฐ์†Œ)
s, r = score_c05([
"a person sprinting in terror",
"a person jogging cautiously",
"a person walking calmly",
], {"expected_trend": "decreasing"})
check("๊ฐ์†Œ ์ถ”์„ธ = ๋†’์€ ์ ์ˆ˜", s >= 16, f"got {s}")
# ์•ˆ์ • (๊ธฐ๋Œ€: ์•ˆ์ •)
s, r = score_c05([
"a person walking forward",
"a person walking ahead",
"a person walking steadily",
], {"expected_trend": "stable"})
check("์•ˆ์ • ์œ ์ง€ = ๋†’์€ ์ ์ˆ˜", s >= 14, f"got {s}")
# ์—ญ์ „ (๊ธฐ๋Œ€: ์ฆ๊ฐ€์ธ๋ฐ ๊ฐ์†Œ)
s, r = score_c05([
"a person desperately fleeing",
"a person walking calmly",
"a person standing still",
], {"expected_trend": "increasing"})
check("์—ญ์ „ = ๋‚ฎ์€ ์ ์ˆ˜", s <= 8, f"got {s}")
# ์‹œํ€€์Šค 1๊ฐœ๋งŒ
s, r = score_c05(["a person walking"], {"expected_trend": "increasing"})
check("์‹œํ€€์Šค 1๊ฐœ = 0์ ", s == 0)
# 4๊ฐœ ์‹œํ€€์Šค ๋‹จ์กฐ ์ฆ๊ฐ€
s, r = score_c05([
"a person standing still",
"a person stepping back",
"a person running away",
"a person desperately sprinting in terror",
], {"expected_trend": "increasing"})
check("4๋‹จ๊ณ„ ๋‹จ์กฐ ์ฆ๊ฐ€", s >= 18, f"got {s}")
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
print("\n[11/12] C08: ๋ชจ์…˜ ํ‘œํ˜„๋ ฅ")
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
gt_high = {"expected_min_intensity": 4, "expected_emotion": True, "expected_min_descriptors": 2}
gt_low = {"expected_min_intensity": 1, "expected_emotion": False, "expected_min_descriptors": 1}
# ๋งŒ์ : ํ’๋ถ€ํ•œ ํ‘œํ˜„
s, r = score_c08("a person desperately sprinting right in terror", gt_high)
check("ํ’๋ถ€ํ•œ ํ‘œํ˜„ = 20์ ", s == 20, f"got {s}")
# ๊ฐ์ • ์—†๋Š” ํ‘œํ˜„ (๊ธฐ๋Œ€: ๊ฐ์ • ์žˆ์Œ)
s, r = score_c08("a person moving right", gt_high)
check("๊ฐ์ • ์—†์Œ < ๋งŒ์ ", s < 15, f"got {s}")
# ํ‰์ƒ์‹œ (๊ธฐ๋Œ€: ๊ฐ์ • ์—†์Œ)
s, r = score_c08("a person walking forward steadily", gt_low)
check("ํ‰์ƒ์‹œ ์ ์ ˆ = ๋†’์€ ์ ์ˆ˜", s >= 14, f"got {s}")
# ๋„ˆ๋ฌด ๊ธด ํ…์ŠคํŠธ
long_motion = "a person " + " ".join(["really"] * 25) + " running"
s, r = score_c08(long_motion, gt_high)
check("30๋‹จ์–ด ์ดˆ๊ณผ = ๊ธธ์ด ๊ฐ์ ", s < 20, f"got {s}")
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
print("\n[12/12] C09: ์‹ค์‹œ๊ฐ„ ์„ฑ๋Šฅ")
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
# ๋งŒ์ 
s, r = score_c09({"fps": 50, "cognitive_latency_ms": 2000, "frame_drop_rate": 0.005, "gpu_memory_stable": True})
check("์™„๋ฒฝ ์„ฑ๋Šฅ = 20์ ", s == 20)
# ์ตœ์†Œ
s, r = score_c09({"fps": 20, "cognitive_latency_ms": 8000, "frame_drop_rate": 0.03, "gpu_memory_stable": True})
check("์ตœ์†Œ ์„ฑ๋Šฅ", 5 <= s <= 12, f"got {s}")
# ๋ฏธ๋‹ฌ
s, r = score_c09({"fps": 5, "cognitive_latency_ms": 15000, "frame_drop_rate": 0.1, "gpu_memory_stable": False})
check("๋ฏธ๋‹ฌ ์„ฑ๋Šฅ = ๋‚ฎ์€ ์ ์ˆ˜", s <= 3, f"got {s}")
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
print("\n[BONUS] ํ†ตํ•ฉ ์ ์ˆ˜ + ๋“ฑ๊ธ‰ ๊ฒฝ๊ณ„")
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
# S๋“ฑ๊ธ‰ ๊ฒฝ๊ณ„
r = calculate_wm_score({"C01":100,"C02":100,"C03":100,"C04":100,"C05":100,"C06":100,"C07":100,"C08":100,"C09":100,"C10":100})
check(f"๋งŒ์  = {r['wm_score']} (S๋“ฑ๊ธ‰)", r["grade"] == "S" and r["wm_score"] == 1000)
# A๋“ฑ๊ธ‰ ๊ฒฝ๊ณ„
r = calculate_wm_score({"C01":80,"C02":80,"C03":80,"C04":80,"C05":80,"C06":80,"C07":80,"C08":80,"C09":80,"C10":80})
check(f"80์ ๋Œ€ = {r['wm_score']} ({r['grade']}๋“ฑ๊ธ‰)", r["wm_score"] >= 750)
# B๋“ฑ๊ธ‰
r = calculate_wm_score({"C01":65,"C02":75,"C03":85,"C04":90,"C05":85,"C06":60,"C07":70,"C08":80,"C09":85,"C10":35})
check(f"VIDRAFT ๊ธฐ์ค€์  = {r['wm_score']} ({r['grade']}๋“ฑ๊ธ‰)", r["grade"] in ("B", "A"))
# F๋“ฑ๊ธ‰
r = calculate_wm_score({"C01":10,"C02":10,"C03":10,"C04":10,"C05":10,"C06":10,"C07":10,"C08":10,"C09":10,"C10":10})
check(f"์ตœ์ € = {r['wm_score']} ({r['grade']}๋“ฑ๊ธ‰)", r["wm_score"] < 200)
# 0์ 
r = calculate_wm_score({"C01":0,"C02":0,"C03":0,"C04":0,"C05":0,"C06":0,"C07":0,"C08":0,"C09":0,"C10":0})
check(f"0์  = {r['wm_score']} ({r['grade']}๋“ฑ๊ธ‰)", r["wm_score"] == 0 and r["grade"] == "F")
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
print("\n" + "=" * 70)
print(f" ๊ฒฐ๊ณผ: {passed}/{total} ํ†ต๊ณผ, {failed}/{total} ์‹คํŒจ")
if failed == 0:
print(" โœ… ๋ชจ๋“  ํ…Œ์ŠคํŠธ ํ†ต๊ณผ โ€” ์ฑ„์  ์‹œ์Šคํ…œ ๊ฒ€์ฆ ์™„๋ฃŒ")
else:
print(f" โŒ {failed}๊ฐœ ์‹คํŒจ โ€” ์ˆ˜์ • ํ•„์š”")
print("=" * 70)