robomind-vla / test_battery_api.py
mitvho09's picture
RoboMind VLA: vision-language reward model for robot locomotion (built with Codex)
321ba64 verified
Raw
History Blame Contribute Delete
2.09 kB
import json
import os
import urllib.request
URL = "https://mitvho09--robomind-gradio-serve.modal.run/judge/video"
TEST_DIR = "temp_rollouts/test_battery"
results = []
for fname in sorted(os.listdir(TEST_DIR)):
if not fname.endswith(".mp4"):
continue
parts = fname.replace(".mp4", "").rsplit("_", 2)
env_tier = fname.replace("_ep0.mp4", "")
fpath = os.path.join(TEST_DIR, fname)
print(f"Testing {env_tier}...", end=" ", flush=True)
with open(fpath, "rb") as f:
video_data = f.read()
boundary = "----WebKitFormBoundary7MA4YWxkTrZu0gW"
body = (
f"--{boundary}\r\n"
f'Content-Disposition: form-data; name="file"; filename="{fname}"\r\n'
f"Content-Type: video/mp4\r\n\r\n"
).encode() + video_data + f"\r\n--{boundary}--\r\n".encode()
req = urllib.request.Request(
URL,
data=body,
headers={"Content-Type": f"multipart/form-data; boundary={boundary}"},
method="POST",
)
try:
with urllib.request.urlopen(req, timeout=120) as resp:
data = json.loads(resp.read().decode())
hybrid = data.get("hybrid", {})
reward = hybrid.get("predicted_reward", -1)
vlm_reward = hybrid.get("vlm_reward", -1)
rule_reward = hybrid.get("rule_reward", -1)
stability = hybrid.get("stability", "?")
method = hybrid.get("method", "?")
print(f"reward={reward:.3f} vlm={vlm_reward:.3f} rule={rule_reward:.3f} stability={stability} method={method}")
results.append({"env_tier": env_tier, "reward": reward, "vlm": vlm_reward, "rule": rule_reward, "stability": stability})
except Exception as e:
print(f"ERROR: {e}")
results.append({"env_tier": env_tier, "reward": -1, "error": str(e)})
print("\n=== SUMMARY ===")
print(f"{'Env/Tier':<25} {'Reward':>7} {'VLM':>7} {'Rule':>7} {'Stability':<12}")
print("-" * 60)
for r in results:
print(f"{r['env_tier']:<25} {r.get('reward',-1):>7.3f} {r.get('vlm',0):>7.3f} {r.get('rule',0):>7.3f} {r.get('stability','?'):<12}")