Download code/runner/profile_sample.py from Noctis12138/dexhand-train-kit: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/Noctis12138/dexhand-train-kit/resolve/main/code/runner/profile_sample.py
- Command line
-
hf download hf://Noctis12138/dexhand-train-kit/code/runner/profile_sample.py
-
curl -L -o profile_sample.py https://huggingface.co/Noctis12138/dexhand-train-kit/resolve/main/code/runner/profile_sample.py
1.25 kB
| """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)) | |