File size: 1,253 Bytes
6a08a28 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | """Time one training sample: raw LeRobot read (video + mask decode) vs. our repack (mask overlay) vs. openpi transforms."""
import os, sys, time, random, pathlib
SYT = pathlib.Path(os.environ["SYT"]); sys.path.insert(0, str(SYT / "code/aug")); sys.path.insert(0, str(SYT / "code/runner"))
import argparse
from openpi.training import data_loader as dl
import run as R
a = argparse.Namespace(kind="subtask", repo_id=sys.argv[1])
cfg = R.build_config(a, batch_size=8, num_workers=0)
data_config = cfg.data.create(cfg.assets_dirs, cfg.model)
ds = dl.create_torch_dataset(data_config, cfg.model.action_horizon, cfg.model)
idx = random.Random(0).sample(range(len(ds)), 12)
t = time.time(); raws = [ds[i] for i in idx]; t_raw = (time.time() - t) / len(idx)
rep = data_config.repack_transforms.inputs
t = time.time(); reps = []
for r in raws:
x = r
for f in rep:
x = f(x)
reps.append(x)
t_rep = (time.time() - t) / len(idx)
t = time.time()
for x in reps:
for f in data_config.data_transforms.inputs:
x = f(x)
t_dt = (time.time() - t) / len(idx)
print(f"per sample: raw read {t_raw:.3f}s | repack+mask overlay {t_rep:.3f}s | data transforms {t_dt:.3f}s")
print("keys:", sorted(k for k in raws[0] if "image" in k or "mask" in k))
|