phammminhhieu's picture
TRACE-VLA code snapshot 2026-11-22 11:47 +07: 456 canonical files + SHA256 manifest + sync report (part 2)
ae1ed83 verified
Raw History Blame Contribute Delete
1.09 kB
#!/usr/bin/env python3
"""Data Factory pilot: render agentview mp4s for one valid pair per
layout (both goals) from the saved episode arrays."""
import json
from pathlib import Path
import cv2
import numpy as np
EXP = Path.home() / "sera_v4_experiments"
OUT = EXP / "data_factory" / "pilot"
VID = OUT / "videos"
VID.mkdir(exist_ok=True)
man = json.loads((OUT / "manifest.json").read_text())
want = {}
for p in man["pairs"]:
if p["layout"] not in want:
want[p["layout"]] = p
for layout, pair in want.items():
for goal, ep_id in pair["episodes"].items():
d = np.load(OUT / "episodes" / f"{ep_id}.npz")
frames = d["agentview"]
path = VID / f"df_pair_{pair['pair_id']}_goal{goal}.mp4"
w = cv2.VideoWriter(str(path),
cv2.VideoWriter_fourcc(*"mp4v"), 10,
(256, 256))
for fr in frames:
w.write(cv2.cvtColor(fr, cv2.COLOR_RGB2BGR))
w.release()
print(path.name, len(frames), "frames",
path.stat().st_size, "bytes", flush=True)
print("DONE")