Download exp2/code/sitecustomize.py from Kavin60606/isr-aloha-transfer-cube-experiment: direct link, hf CLI and curl.
- Browser
- Download file 1.88 kB
-
https://huggingface.co/datasets/Kavin60606/isr-aloha-transfer-cube-experiment/resolve/main/exp2/code/sitecustomize.py
- Command line
-
hf download hf://datasets/Kavin60606/isr-aloha-transfer-cube-experiment/exp2/code/sitecustomize.py
-
curl -L -o sitecustomize.py https://huggingface.co/datasets/Kavin60606/isr-aloha-transfer-cube-experiment/resolve/main/exp2/code/sitecustomize.py
1.88 kB
| import os | |
| if os.environ.get("ISR_MEMDECODE") == "1": | |
| try: import memdecode # noqa | |
| except Exception as e: print("memdecode patch failed:", e) | |
| if os.environ.get("ISR_GYM_ALOHA") == "1": | |
| try: | |
| import gym_aloha # noqa (registers gym_aloha/* envs in every process incl. forkserver children) | |
| from gym_aloha.env import AlohaEnv | |
| if not hasattr(AlohaEnv, "task_description"): AlohaEnv.task_description = property(lambda self: f"aloha {getattr(self, 'task', '')}") # lerobot_eval requires it | |
| except Exception as e: print("gym_aloha import failed:", e) | |
| if os.environ.get("ISR_ALOHA_DEG") == "1": # policy trained in degrees; env speaks radians | |
| try: | |
| import numpy as np | |
| from gym_aloha.env import AlohaEnv | |
| _step, _reset = AlohaEnv.step, AlohaEnv.reset | |
| def _o(o): | |
| if isinstance(o, dict) and "agent_pos" in o: o["agent_pos"] = np.rad2deg(o["agent_pos"]).astype(np.float32) | |
| return o | |
| def step(self, action): o, r, te, tr, i = _step(self, np.deg2rad(np.asarray(action, dtype=np.float64))); return _o(o), r, te, tr, i | |
| def reset(self, *a, **k): o, i = _reset(self, *a, **k); return _o(o), i | |
| AlohaEnv.step, AlohaEnv.reset = step, reset | |
| except Exception as e: print("aloha deg shim failed:", e) | |
| if os.environ.get("ISR_ACTION_REPEAT", "1") != "1": # rate-matched deployment: hold each policy action N sim steps | |
| try: | |
| from gym_aloha.env import AlohaEnv | |
| _N = int(os.environ["ISR_ACTION_REPEAT"]); _step_r = AlohaEnv.step | |
| def step_rep(self, action): | |
| tot = 0.0 | |
| for _ in range(_N): | |
| o, r, te, tr, i = _step_r(self, action); tot += float(r) | |
| if te or tr: break | |
| return o, tot, te, tr, i | |
| AlohaEnv.step = step_rep | |
| except Exception as e: print("action repeat shim failed:", e) | |