RobotZero / eval /source /robot_tools /droid /scripts /report_pick.py
JiayiWuLeo's picture
Add source_all batch 7/10
868a5eb verified
Raw History Blame Contribute Delete
2.5 kB
"""Picked DROID episodes (one per task) + their fresh entities.json, alongside the
2026-09-08 per-camera sidecar for the same episode, so the two prompt versions can
be compared. Also a coverage count. Optional sheets (ext1 top, wrist bottom) with
--sheets into ~/droid_sheets_5s/."""
import os, json, sys
from pathlib import Path
root = Path("/home/wujiayir/robot_tools/droid")
picks = [l.rstrip("\n").split("\t") for l in open(root / "pick_5s_tasks.tsv")][1:]
uuid2task = {ep: (t, n, sec) for t, n, ep, sec in picks}
rows, missing = [], []
for line in open(root / "pick_5s.txt"):
outj, nf, vids = line.rstrip("\n").split("\t")
outj = Path(outj); ep = outj.parent.parent.parent.name
t, n, sec = uuid2task[ep]
if not outj.exists():
missing.append(ep); continue
d = json.load(open(outj))
old = sorted(outj.parent.glob("*.entities.json"))
o = json.load(open(old[0])) if old else {}
rows.append((int(n), t, ep, sec, d["direct"], d["indirect"], o.get("direct"), o.get("indirect")))
rows.sort(key=lambda r: -r[0])
print(f"done {len(rows)} / {len(rows)+len(missing)} missing: {missing}")
same = sum(1 for r in rows if r[6] is not None and set(r[4]) == set(r[6]))
print(f"direct identical to the 09-08 sidecar: {same}/{sum(1 for r in rows if r[6] is not None)}")
print()
print("| n_eps | task | episode | sec | direct | indirect | 09-08 direct | 09-08 indirect |")
print("|---|---|---|---|---|---|---|---|")
for n, t, ep, sec, di, ii, od, oi in rows:
print(f"| {n} | {t[:60]} | {ep[:28]} | {sec} | {', '.join(di)} | {', '.join(ii)} | "
f"{', '.join(od) if od else '-'} | {', '.join(oi) if oi else '-'} |")
if "--sheets" in sys.argv:
os.environ.setdefault("OPENCV_FFMPEG_CAPTURE_OPTIONS", "threads;1")
import cv2, numpy as np
out = Path.home() / "droid_sheets_5s"; out.mkdir(exist_ok=True)
def frames(p, k=8):
c = cv2.VideoCapture(str(p)); fr = []
while True:
ok, f = c.read()
if not ok: break
fr.append(cv2.resize(f, (640, 360)))
return [fr[i] for i in np.linspace(0, len(fr) - 1, k, dtype=int)]
for line in open(root / "pick_5s.txt"):
outj, nf, vids = line.rstrip("\n").split("\t")
v = vids.split(); ep = Path(outj).parent.parent.parent.name
sheet = np.vstack([np.hstack(frames(v[0])), np.hstack(frames(v[2]))])
cv2.imwrite(str(out / f"{ep}.jpg"), sheet, [cv2.IMWRITE_JPEG_QUALITY, 80])
print("sheets:", len(list(out.glob("*.jpg"))))