freestream / tests /probe_avatar.py
LoveLogicAI's picture
v0.1.0
3a34595 verified
Raw History Blame Contribute Delete
1.61 kB
"""Probe: render every avatar posture mode; catch the working-mode crash."""
import sys
import traceback
import urllib.request
from pathlib import Path
Path("/tmp/probe").mkdir(parents=True, exist_ok=True)
for f in ("freestream/__init__.py", "freestream/avatar.py"):
dest = Path("/tmp/probe") / f
dest.parent.mkdir(parents=True, exist_ok=True)
with urllib.request.urlopen(
f"https://huggingface.co/datasets/LoveLogicAI/freestream/resolve/main/{f}",
timeout=60) as r:
dest.write_bytes(r.read())
sys.path.insert(0, "/tmp/probe")
from freestream.avatar import AvatarRenderer, generate_placeholder, render_procedural # noqa: E402
generate_placeholder("/tmp/probe/face.png")
r = AvatarRenderer("/tmp/probe/face.png")
for mode in ("idle", "thinking", "speaking", "working"):
try:
img = r.frame(0.2 if mode == "speaking" else 0.0, mode)
# hold working for several frames to exercise the spring/typing paths
if mode == "working":
for _ in range(20):
img = r.frame(0.0, mode)
print(f"OK {mode}: {img.size}", flush=True)
except Exception:
print(f"FAIL {mode}:", flush=True)
traceback.print_exc()
# also raw render_procedural in working mode at full device_t
try:
img = render_procedural(0.0, mode="working", device_t=1.0, typing_pulse=1.0,
blink=0.0, gaze=(3, 5))
print("OK raw working @device_t=1.0:", img.size, flush=True)
except Exception:
print("FAIL raw working:", flush=True)
traceback.print_exc()
print("[probe] done", flush=True)