Download code-changes.diff from luca0621/robocasa-delayed-recall-eval: direct link, hf CLI and curl.
- Browser
- Download file 28.6 kB
-
https://huggingface.co/datasets/luca0621/robocasa-delayed-recall-eval/resolve/main/code-changes.diff
- Command line
-
hf download hf://datasets/luca0621/robocasa-delayed-recall-eval/code-changes.diff
-
curl -L -o code-changes.diff https://huggingface.co/datasets/luca0621/robocasa-delayed-recall-eval/resolve/main/code-changes.diff
28.6 kB
| --- original/compare_parity.py | |
| +++ packaged/compare_parity.py | |
| import h5py | |
| import numpy as np | |
| -E = Path('/data/robo_ttt/robocasa_memory_20261103/evaluation-ck30000-20261108') | |
| +ORIGINAL_ROOT = '/data/robo_ttt/robocasa_memory_20261103' | |
| +ROOT = __import__('os').environ.get('RDR_ROOT', ORIGINAL_ROOT) # [packaged] relocatable root, default = original | |
| +E = Path(ROOT)/'evaluation-ck30000-20261108' | |
| + | |
| + | |
| +def L(p): # [packaged] map an original absolute path recorded in plans / source metadata onto RDR_ROOT | |
| + p = str(p) | |
| + return Path(ROOT+p[len(ORIGINAL_ROOT):]) if p.startswith(ORIGINAL_ROOT) else Path(p) | |
| OLD = E/'cotrain-ck3000-20261114'; P = E/'cotrain-delay-n10-20261115'/'parity'/'parity-d0' | |
| --- original/evaluate_delayed.py | |
| +++ packaged/evaluate_delayed.py | |
| import time | |
| from pathlib import Path | |
| -E = Path('/data/robo_ttt/robocasa_memory_20261103/evaluation-ck30000-20261108') | |
| +ORIGINAL_ROOT = '/data/robo_ttt/robocasa_memory_20261103' | |
| +ROOT = __import__('os').environ.get('RDR_ROOT', ORIGINAL_ROOT) # [packaged] relocatable root, default = original | |
| +E = Path(ROOT)/'evaluation-ck30000-20261108' | |
| + | |
| + | |
| +def L(p): # [packaged] map an original absolute path recorded in plans / source metadata onto RDR_ROOT | |
| + p = str(p) | |
| + return Path(ROOT+p[len(ORIGINAL_ROOT):]) if p.startswith(ORIGINAL_ROOT) else Path(p) | |
| R = E.parent | |
| OLD = E/'cotrain-ck3000-20261114' | |
| N = E/'cotrain-delay-n10-20261115' | |
| TASKS = {'cup': 'OpenCabinetAndReturnCup', 'spice': 'UncoverAndRetrieveSpice'} | |
| KEYS = ['observation.images.'+c for c in CAMERAS] | |
| +WRIST = 'robot0_eye_in_hand' | |
| +WRIST_NEAR_DIVISOR = 10 # wrist near plane 0.001*extent (29 mm in these kitchens) -> 2.9 mm | |
| + | |
| + | |
| +# [packaged] same wrist near-plane fix as evaluate_delayed_v2.py (default ON; --no-wrist-near-fix = original rendering) | |
| +def render_frames(env, io, wrist_near_fix): | |
| + """camera_frames(), except (optionally) the wrist camera is rendered with a 10x closer near plane. | |
| + | |
| + MuJoCo's near plane is vis.map.znear * stat.extent; the ~29 m kitchen extent puts it at 2.9 cm, so geometry within | |
| + 2.9 cm of the wrist camera is clipped (see-through). The agent-view cameras (the left one is the policy history) are | |
| + rendered with the unchanged global setting, so they stay bit-identical to camera_frames().""" | |
| + if not wrist_near_fix: | |
| + return camera_frames(env, io, KEYS) | |
| + m = env.sim.model._model; z0 = m.vis.map.znear; frames = {} | |
| + for key in KEYS: | |
| + cam = key.split('.')[-1] | |
| + try: | |
| + if cam == WRIST: m.vis.map.znear = z0/WRIST_NEAR_DIVISOR | |
| + frames[key] = np.ascontiguousarray(env.sim.render(width=io['render_width'], height=io['render_height'], camera_name=cam)[::-1]) | |
| + finally: | |
| + m.vis.map.znear = z0 | |
| + return frames | |
| def delayed_recall_success(env, task, chores_done): | |
| def main(): | |
| p = argparse.ArgumentParser(); p.add_argument('--stage', required=True); p.add_argument('--trial', required=True) | |
| - p.add_argument('--gpu', type=int, choices=[0, 1], required=True); a = p.parse_args() | |
| + p.add_argument('--gpu', type=int, choices=[0, 1], required=True) | |
| + p.add_argument('--wrist-near-fix', dest='wrist_near_fix', action='store_true', default=True, # [packaged] default ON | |
| + help='(default) render the wrist camera with a 2.9 mm near plane (no see-through); agent views unchanged') | |
| + p.add_argument('--no-wrist-near-fix', dest='wrist_near_fix', action='store_false', # [packaged] | |
| + help='original 2.9 cm wrist near plane: exact reproduction of the original 1/5/15-min and immediate runs and of the training-data rendering') | |
| + a = p.parse_args() | |
| stage = N/a.stage; pauses = [N/'USER_PAUSED.json', N/'STOP', HERE/'STOP', stage/'STOP', stage/'USER_PAUSED.json'] | |
| plan = read(stage/'plan.json'); case = next(x for x in plan['cases'] if x['trial_id'] == a.trial) | |
| out = stage/'episodes'/a.trial; out.mkdir(parents=True, exist_ok=False) | |
| def progress(status, **kw): write(out/'status.json', dict(status=status, updated_unix=time.time(), trial=a.trial, policy_steps=steps, **kw)) | |
| try: | |
| check_pause(pauses) | |
| - src = Path(case['source_dir']); g = read(src/'result.json'); tsrc = Path(case['training_source_dir']) | |
| + src = L(case['source_dir']); g = read(src/'result.json'); tsrc = L(case['training_source_dir']) | |
| assert g['status'] == 'verified' and g['trajectory_sha256'] == case['source_trajectory_sha256'] | |
| progress('checking_source_hashes') | |
| assert digest(src/'trajectory.hdf5') == case['source_trajectory_sha256'] | |
| - assert digest(tsrc/'training.hdf5') == case['training_hdf5_sha256'] | |
| + assert not (tsrc/'training.hdf5').exists() or digest(tsrc/'training.hdf5') == case['training_hdf5_sha256'] # [packaged] RGB reference optional | |
| b = case['storage_steps']; h = case['handoff_step'] | |
| spec = importlib.util.spec_from_file_location('frozen_data_env', E/case['generator_version']/'data_env.py') | |
| module = importlib.util.module_from_spec(spec); spec.loader.exec_module(module) | |
| io = read(OLD/'io.json'); env = module.make(g['scenario'], out/'assets'); obs = env.reset() | |
| - assert read(OLD/'download-status.json')['status'] == 'verified' | |
| + zn = float(env.sim.model._model.vis.map.znear*env.sim.model._model.stat.extent) # [packaged] | |
| + result.update(wrist_near_fix=dict(enabled=a.wrist_near_fix, wrist_near_plane_m=zn/(WRIST_NEAR_DIVISOR if a.wrist_near_fix else 1), agent_view_near_plane_m=zn)) # [packaged] | |
| + assert not (OLD/'download-status.json').exists() or read(OLD/'download-status.json')['status'] == 'verified' # [packaged] optional record | |
| penv = dict(os.environ, CUDA_VISIBLE_DEVICES=str(a.gpu), PYTHONPATH=str(OLD/'code')+':'+str(OLD/'author-code'), SM_L2NORM_ROW_PAD='65536') | |
| command = [str(E/'policy-venv/bin/python'), str(OLD/'policy_entry.py'), '--checkpoint', str(OLD/'checkpoint/model'), | |
| '--io-config', str(OLD/'io.json'), '--repo', str(E/'SimpleMemVLA'), '--max-subtask-tokens', '256', | |
| video = EvaluationVideo(out) | |
| maxerr = 0.; rgb_storage = {c: 0 for c in CAMERAS}; checkpoint_rgb = {}; hidden = [] | |
| progress('replaying_source', boundary=b, handoff=h) | |
| - with h5py.File(src/'trajectory.hdf5') as trajectory, h5py.File(tsrc/'training.hdf5') as training: | |
| + with h5py.File(src/'trajectory.hdf5') as trajectory, (h5py.File(tsrc/'training.hdf5') if (tsrc/'training.hdf5').exists() else __import__('contextlib').nullcontext()) as training: # [packaged] | |
| assert trajectory['actions'].dtype == np.float64 and len(trajectory['actions']) == h | |
| for i in range(h+1): | |
| check_pause(pauses) | |
| error = float(np.max(np.abs(env.sim.get_state().flatten()-trajectory['states'][i]))) | |
| assert np.isfinite(error) and error <= 1e-8, ('state_replay', i, error); maxerr = max(maxerr, error) | |
| assert np.array_equal(encode_state(obs, io), trajectory['observation.state'][i]), ('proprio_replay', i) | |
| - images = camera_frames(env, io, KEYS) | |
| + images = render_frames(env, io, a.wrist_near_fix) # [packaged] | |
| assert all(v.shape == (256, 256, 3) and v.std() > 5 for v in images.values()), ('invalid_rgb', i) | |
| - if i <= b: | |
| + if training is not None and i <= b: # [packaged] | |
| for c in CAMERAS: | |
| d = int(np.abs(images['observation.images.'+c].astype(np.int16)-training['rgb/'+c][i].astype(np.int16)).max()) | |
| - rgb_storage[c] = max(rgb_storage[c], d); assert d == 0, ('storage_rgb', i, c, d) | |
| + rgb_storage[c] = max(rgb_storage[c], d); assert d == 0 or (a.wrist_near_fix and c == WRIST), ('storage_rgb', i, c, d) # [packaged] wrist recorded, not asserted, with the fix | |
| for label, step in (('initial', 0), ('immediate-handoff', b), ('delayed-handoff', h)): | |
| if i == step: | |
| for c in CAMERAS: Image.fromarray(images['observation.images.'+c]).save(out/f'{label}-{c}.png') | |
| if label != 'initial': | |
| checkpoint_rgb[label] = {c: int(np.abs(np.asarray(Image.open(src/f'{label}-{c}.png')).astype(np.int16) | |
| - images['observation.images.'+c].astype(np.int16)).max()) for c in CAMERAS} | |
| - assert all(v == 0 for v in checkpoint_rgb[label].values()), (label, checkpoint_rgb[label]) | |
| + assert all(v == 0 for c, v in checkpoint_rgb[label].items() if not (a.wrist_near_fix and c == WRIST)), (label, checkpoint_rgb[label]) # [packaged] | |
| if i > b: hidden.append(concealed(env, family)) | |
| if i < h: | |
| policy.observe(images); video.append_reference(images, i) | |
| states.append(env.sim.get_state().flatten().copy()); observations.append(encode_state(obs, io)); actions.append(action) | |
| video.append_action(images, step, case['instruction']) | |
| obs = env.step(action)[0]; steps = step+1 | |
| - images = camera_frames(env, io, KEYS) | |
| + images = render_frames(env, io, a.wrist_near_fix) # [packaged] | |
| assert all(v.shape == (256, 256, 3) and v.dtype == np.uint8 and v.std() > 5 for v in images.values()) | |
| policy.observe(images) | |
| current = flags(env, family, origin, chores_done) | |
| --- original/evaluate_delayed_v2.py | |
| +++ packaged/evaluate_delayed_v2.py | |
| import time | |
| from pathlib import Path | |
| -E = Path('/data/robo_ttt/robocasa_memory_20261103/evaluation-ck30000-20261108') | |
| +ORIGINAL_ROOT = '/data/robo_ttt/robocasa_memory_20261103' | |
| +ROOT = __import__('os').environ.get('RDR_ROOT', ORIGINAL_ROOT) # [packaged] relocatable root, default = original | |
| +E = Path(ROOT)/'evaluation-ck30000-20261108' | |
| + | |
| + | |
| +def L(p): # [packaged] map an original absolute path recorded in plans / source metadata onto RDR_ROOT | |
| + p = str(p) | |
| + return Path(ROOT+p[len(ORIGINAL_ROOT):]) if p.startswith(ORIGINAL_ROOT) else Path(p) | |
| R = E.parent | |
| OLD = E/'cotrain-ck3000-20261114' | |
| N = E/'cotrain-delay-n10-20261115' | |
| p = argparse.ArgumentParser(); p.add_argument('--stage', required=True); p.add_argument('--trial', required=True) | |
| p.add_argument('--gpu', type=int, choices=[0, 1], required=True) | |
| p.add_argument('--bounded-history', action='store_true', help='disk-backed policy history buffers (I/O only; inputs bit-identical)') | |
| - p.add_argument('--wrist-near-fix', action='store_true', help='render the wrist camera with a 2.9 mm near plane (no see-through); agent views unchanged') | |
| + p.add_argument('--wrist-near-fix', dest='wrist_near_fix', action='store_true', default=True, # [packaged] default ON | |
| + help='(default) render the wrist camera with a 2.9 mm near plane (no see-through); agent views unchanged') | |
| + p.add_argument('--no-wrist-near-fix', dest='wrist_near_fix', action='store_false', # [packaged] | |
| + help='original 2.9 cm wrist near plane: exact reproduction of the original 1/5/15-min and immediate runs and of the training-data rendering') | |
| a = p.parse_args() | |
| stage = N/a.stage; pauses = [N/'USER_PAUSED.json', N/'STOP', HERE/'STOP', stage/'STOP', stage/'USER_PAUSED.json'] | |
| plan = read(stage/'plan.json'); case = next(x for x in plan['cases'] if x['trial_id'] == a.trial) | |
| def progress(status, **kw): write(out/'status.json', dict(status=status, updated_unix=time.time(), trial=a.trial, policy_steps=steps, **kw)) | |
| try: | |
| check_pause(pauses) | |
| - src = Path(case['source_dir']); g = read(src/'result.json'); kind = case['source_kind'] | |
| + src = L(case['source_dir']); g = read(src/'result.json'); kind = case['source_kind'] | |
| assert g['status'] == 'verified' and g['trajectory_sha256'] == case['source_trajectory_sha256'] | |
| progress('checking_source_hashes') | |
| assert digest(src/'trajectory.hdf5') == case['source_trajectory_sha256'] | |
| b = case['storage_steps']; h = case['handoff_step'] | |
| if kind == 'short': | |
| - tsrc = Path(case['training_source_dir']); assert digest(tsrc/'training.hdf5') == case['training_hdf5_sha256'] | |
| + tsrc = L(case['training_source_dir']); assert not (tsrc/'training.hdf5').exists() or digest(tsrc/'training.hdf5') == case['training_hdf5_sha256'] # [packaged] RGB reference optional | |
| spec = importlib.util.spec_from_file_location('frozen_data_env', E/case['generator_version']/'data_env.py') | |
| module = importlib.util.module_from_spec(spec); spec.loader.exec_module(module) | |
| if family == 'cup' and case['chores'] != ['pack_drink']: | |
| else: | |
| from experiments.robocasa_memory.evaluation.driver import make_environment | |
| with h5py.File(src/'trajectory.hdf5') as f: meta = json.loads(f.attrs['ep_meta']) | |
| - env = make_environment(dict(metadata=meta, minutes=case['env_minutes']), meta['memory_task'].get('asset_dir') or out/'assets') | |
| - cache = h5py.File(case['frame_cache'], 'r'); assert int(cache.attrs['handoff_step']) == h | |
| + env = make_environment(dict(metadata=meta, minutes=case['env_minutes']), (L(meta['memory_task']['asset_dir']) if meta['memory_task'].get('asset_dir') else out/'assets')) | |
| + cache = h5py.File(L(case['frame_cache']), 'r') if L(case['frame_cache']).exists() else None; assert cache is None or int(cache.attrs['handoff_step']) == h # [packaged] frame cache optional | |
| io = read(OLD/'io.json'); obs = env.reset() | |
| - assert read(OLD/'download-status.json')['status'] == 'verified' | |
| + assert not (OLD/'download-status.json').exists() or read(OLD/'download-status.json')['status'] == 'verified' # [packaged] optional record | |
| penv = dict(os.environ, CUDA_VISIBLE_DEVICES=str(a.gpu), PYTHONPATH=str(OLD/'code')+':'+str(OLD/'author-code'), SM_L2NORM_ROW_PAD='65536') | |
| history_dir = Path('/tmp/sm-history')/(a.stage.replace('/', '_')+'__'+a.trial) | |
| if a.bounded_history: penv['SM_HISTORY_DIR'] = str(history_dir) | |
| video = EvaluationVideo(out) | |
| maxerr = 0.; rgb_ref = {c: 0 for c in CAMERAS}; checkpoint_rgb = {}; hidden = []; observed_hashes = [] | |
| progress('replaying_source', boundary=b, handoff=h) | |
| - training = h5py.File(tsrc/'training.hdf5', 'r') if kind == 'short' else None | |
| + training = h5py.File(tsrc/'training.hdf5', 'r') if kind == 'short' and (tsrc/'training.hdf5').exists() else None # [packaged] | |
| with h5py.File(src/'trajectory.hdf5') as trajectory: | |
| assert len(trajectory['actions']) == h | |
| assert trajectory['actions'].dtype == (np.float64 if kind == 'short' else np.float32) | |
| images = render_frames(env, io, a.wrist_near_fix) | |
| assert all(v.shape == (256, 256, 3) and v.std() > 5 for v in images.values()), ('invalid_rgb', i) | |
| # EGL reference: training frames through storage (short), or the EGL-rendered left-agentview cache (long). | |
| - if kind == 'short' and i <= b: | |
| + if kind == 'short' and training is not None and i <= b: # [packaged] | |
| refs = {c: training['rgb/'+c][i] for c in CAMERAS} | |
| - elif kind == 'long': | |
| + elif kind == 'long' and cache is not None: # [packaged] | |
| refs = {'robot0_agentview_left': cache['robot0_agentview_left'][i]} | |
| if i == h: refs.update({c: cache[c+'_at_handoff'][()] for c in CAMERAS}) | |
| else: refs = {} | |
| obs = env.step(trajectory['actions'][i])[0] | |
| if i % 200 == 0: progress('replaying_source', native_step=i, boundary=b, handoff=h) | |
| if training: training.close() | |
| - if kind == 'long': cache.close() | |
| + if kind == 'long' and cache is not None: cache.close() # [packaged] | |
| first_hidden = next((j for j, x in enumerate(hidden) if x), None) | |
| assert first_hidden is not None and all(hidden[first_hidden:]), 'target became visible before handoff' | |
| if kind == 'short': assert first_hidden == 0, 'short sources must be concealed from the storage boundary on' | |
| --- original/evaluate_parity.py | |
| +++ packaged/evaluate_parity.py | |
| import time | |
| from pathlib import Path | |
| -E = Path('/data/robo_ttt/robocasa_memory_20261103/evaluation-ck30000-20261108') | |
| +ORIGINAL_ROOT = '/data/robo_ttt/robocasa_memory_20261103' | |
| +ROOT = __import__('os').environ.get('RDR_ROOT', ORIGINAL_ROOT) # [packaged] relocatable root, default = original | |
| +E = Path(ROOT)/'evaluation-ck30000-20261108' | |
| + | |
| + | |
| +def L(p): # [packaged] map an original absolute path recorded in plans / source metadata onto RDR_ROOT | |
| + p = str(p) | |
| + return Path(ROOT+p[len(ORIGINAL_ROOT):]) if p.startswith(ORIGINAL_ROOT) else Path(p) | |
| R = E.parent | |
| OLD = E/'cotrain-ck3000-20261114' | |
| N = E/'cotrain-delay-n10-20261115' | |
| TASKS = {'cup': 'OpenCabinetAndReturnCup', 'spice': 'UncoverAndRetrieveSpice'} | |
| KEYS = ['observation.images.'+c for c in CAMERAS] | |
| +WRIST = 'robot0_eye_in_hand' | |
| +WRIST_NEAR_DIVISOR = 10 # wrist near plane 0.001*extent (29 mm in these kitchens) -> 2.9 mm | |
| + | |
| + | |
| +# [packaged] same wrist near-plane fix as evaluate_delayed_v2.py (default ON; --no-wrist-near-fix = original rendering) | |
| +def render_frames(env, io, wrist_near_fix): | |
| + """camera_frames(), except (optionally) the wrist camera is rendered with a 10x closer near plane. | |
| + | |
| + MuJoCo's near plane is vis.map.znear * stat.extent; the ~29 m kitchen extent puts it at 2.9 cm, so geometry within | |
| + 2.9 cm of the wrist camera is clipped (see-through). The agent-view cameras (the left one is the policy history) are | |
| + rendered with the unchanged global setting, so they stay bit-identical to camera_frames().""" | |
| + if not wrist_near_fix: | |
| + return camera_frames(env, io, KEYS) | |
| + m = env.sim.model._model; z0 = m.vis.map.znear; frames = {} | |
| + for key in KEYS: | |
| + cam = key.split('.')[-1] | |
| + try: | |
| + if cam == WRIST: m.vis.map.znear = z0/WRIST_NEAR_DIVISOR | |
| + frames[key] = np.ascontiguousarray(env.sim.render(width=io['render_width'], height=io['render_height'], camera_name=cam)[::-1]) | |
| + finally: | |
| + m.vis.map.znear = z0 | |
| + return frames | |
| def delayed_recall_success(env, task, chores_done): | |
| def main(): | |
| p = argparse.ArgumentParser(); p.add_argument('--stage', required=True); p.add_argument('--trial', required=True) | |
| - p.add_argument('--gpu', type=int, choices=[0, 1], required=True); a = p.parse_args() | |
| + p.add_argument('--gpu', type=int, choices=[0, 1], required=True) | |
| + p.add_argument('--wrist-near-fix', dest='wrist_near_fix', action='store_true', default=True, # [packaged] default ON | |
| + help='(default) render the wrist camera with a 2.9 mm near plane (no see-through); agent views unchanged') | |
| + p.add_argument('--no-wrist-near-fix', dest='wrist_near_fix', action='store_false', # [packaged] | |
| + help='original 2.9 cm wrist near plane: exact reproduction of the original 1/5/15-min and immediate runs and of the training-data rendering') | |
| + a = p.parse_args() | |
| stage = N/'parity'/a.stage; pauses = [N/'USER_PAUSED.json', N/'STOP', HERE/'STOP', stage/'STOP', stage/'USER_PAUSED.json'] | |
| plan = read(stage/'plan.json'); case = next(x for x in plan['cases'] if x['trial_id'] == a.trial) | |
| out = stage/'episodes'/a.trial; out.mkdir(parents=True, exist_ok=False) | |
| def progress(status, **kw): write(out/'status.json', dict(status=status, updated_unix=time.time(), trial=a.trial, policy_steps=steps, **kw)) | |
| try: | |
| check_pause(pauses) | |
| - src = Path(case['source_dir']); g = read(src/'result.json'); tsrc = Path(case['training_source_dir']); assert src == tsrc | |
| + src = L(case['source_dir']); g = read(src/'result.json'); tsrc = L(case['training_source_dir']); assert src == tsrc | |
| assert g['status'] == 'verified' and g['trajectory_sha256'] == case['source_trajectory_sha256'] and g['storage_steps'] == case['handoff_step'] | |
| progress('checking_source_hashes') | |
| assert digest(src/'trajectory.hdf5') == case['source_trajectory_sha256'] | |
| - assert digest(tsrc/'training.hdf5') == case['training_hdf5_sha256'] | |
| + assert not (tsrc/'training.hdf5').exists() or digest(tsrc/'training.hdf5') == case['training_hdf5_sha256'] # [packaged] RGB reference optional | |
| b = case['storage_steps']; h = case['handoff_step'] | |
| spec = importlib.util.spec_from_file_location('frozen_data_env', E/case['generator_version']/'data_env.py') | |
| module = importlib.util.module_from_spec(spec); spec.loader.exec_module(module) | |
| io = read(OLD/'io.json'); env = module.make(g['scenario'], out/'assets'); obs = env.reset() | |
| - assert read(OLD/'download-status.json')['status'] == 'verified' | |
| + zn = float(env.sim.model._model.vis.map.znear*env.sim.model._model.stat.extent) # [packaged] | |
| + result.update(wrist_near_fix=dict(enabled=a.wrist_near_fix, wrist_near_plane_m=zn/(WRIST_NEAR_DIVISOR if a.wrist_near_fix else 1), agent_view_near_plane_m=zn)) # [packaged] | |
| + assert not (OLD/'download-status.json').exists() or read(OLD/'download-status.json')['status'] == 'verified' # [packaged] optional record | |
| penv = dict(os.environ, CUDA_VISIBLE_DEVICES=str(a.gpu), PYTHONPATH=str(OLD/'code')+':'+str(OLD/'author-code'), SM_L2NORM_ROW_PAD='65536') | |
| command = [str(E/'policy-venv/bin/python'), str(OLD/'policy_entry.py'), '--checkpoint', str(OLD/'checkpoint/model'), | |
| '--io-config', str(OLD/'io.json'), '--repo', str(E/'SimpleMemVLA'), '--max-subtask-tokens', '256', | |
| video = EvaluationVideo(out) | |
| maxerr = 0.; rgb_storage = {c: 0 for c in CAMERAS}; checkpoint_rgb = {}; hidden = [] | |
| progress('replaying_source', boundary=b, handoff=h) | |
| - with h5py.File(src/'trajectory.hdf5') as trajectory, h5py.File(tsrc/'training.hdf5') as training: | |
| + with h5py.File(src/'trajectory.hdf5') as trajectory, (h5py.File(tsrc/'training.hdf5') if (tsrc/'training.hdf5').exists() else __import__('contextlib').nullcontext()) as training: # [packaged] | |
| assert trajectory['actions'].dtype == np.float64 and len(trajectory['actions']) > h | |
| for i in range(h+1): | |
| check_pause(pauses) | |
| error = float(np.max(np.abs(env.sim.get_state().flatten()-trajectory['states'][i]))) | |
| assert np.isfinite(error) and error <= 1e-8, ('state_replay', i, error); maxerr = max(maxerr, error) | |
| assert np.array_equal(encode_state(obs, io), trajectory['observation.state'][i]), ('proprio_replay', i) | |
| - images = camera_frames(env, io, KEYS) | |
| + images = render_frames(env, io, a.wrist_near_fix) # [packaged] | |
| assert all(v.shape == (256, 256, 3) and v.std() > 5 for v in images.values()), ('invalid_rgb', i) | |
| - if i <= b: | |
| + if training is not None and i <= b: # [packaged] | |
| for c in CAMERAS: | |
| d = int(np.abs(images['observation.images.'+c].astype(np.int16)-training['rgb/'+c][i].astype(np.int16)).max()) | |
| - rgb_storage[c] = max(rgb_storage[c], d); assert d == 0, ('storage_rgb', i, c, d) | |
| + rgb_storage[c] = max(rgb_storage[c], d); assert d == 0 or (a.wrist_near_fix and c == WRIST), ('storage_rgb', i, c, d) # [packaged] wrist recorded, not asserted, with the fix | |
| for label, step in (('initial', 0), ('immediate-handoff', b)): | |
| if i == step: | |
| for c in CAMERAS: Image.fromarray(images['observation.images.'+c]).save(out/f'{label}-{c}.png') | |
| if label != 'initial': | |
| checkpoint_rgb[label] = {c: int(np.abs(np.asarray(Image.open(src/f'handoff-{c}.png')).astype(np.int16) | |
| - images['observation.images.'+c].astype(np.int16)).max()) for c in CAMERAS} | |
| - assert all(v == 0 for v in checkpoint_rgb[label].values()), (label, checkpoint_rgb[label]) | |
| + assert all(v == 0 for c, v in checkpoint_rgb[label].items() if not (a.wrist_near_fix and c == WRIST)), (label, checkpoint_rgb[label]) # [packaged] | |
| if i > b: hidden.append(concealed(env, family)) | |
| if i < h: | |
| policy.observe(images); video.append_reference(images, i) | |
| states.append(env.sim.get_state().flatten().copy()); observations.append(encode_state(obs, io)); actions.append(action) | |
| video.append_action(images, step, case['instruction']) | |
| obs = env.step(action)[0]; steps = step+1 | |
| - images = camera_frames(env, io, KEYS) | |
| + images = render_frames(env, io, a.wrist_near_fix) # [packaged] | |
| assert all(v.shape == (256, 256, 3) and v.dtype == np.uint8 and v.std() > 5 for v in images.values()) | |
| policy.observe(images) | |
| current = flags(env, family, origin, chores_done) | |
| --- original/make_plan_v2.py | |
| +++ packaged/make_plan_v2.py | |
| from pathlib import Path | |
| import h5py | |
| -E = Path('/data/robo_ttt/robocasa_memory_20261103/evaluation-ck30000-20261108') | |
| +ORIGINAL_ROOT = '/data/robo_ttt/robocasa_memory_20261103' | |
| +ROOT = __import__('os').environ.get('RDR_ROOT', ORIGINAL_ROOT) # [packaged] relocatable root, default = original | |
| +E = Path(ROOT)/'evaluation-ck30000-20261108' | |
| + | |
| + | |
| +def L(p): # [packaged] map an original absolute path recorded in plans / source metadata onto RDR_ROOT | |
| + p = str(p) | |
| + return Path(ROOT+p[len(ORIGINAL_ROOT):]) if p.startswith(ORIGINAL_ROOT) else Path(p) | |
| OLD = E/'cotrain-ck3000-20261114' | |
| N = E/'cotrain-delay-n10-20261115' | |
| sys.path.insert(0, str(OLD/'code')) | |
| --- original/policy_entry_bounded.py | |
| +++ packaged/policy_entry_bounded.py | |
| import sys | |
| from pathlib import Path | |
| -root = Path('/data/robo_ttt/robocasa_memory_20261103/evaluation-ck30000-20261108/cotrain-ck3000-20261114') | |
| +root = Path(os.environ.get('RDR_ROOT', '/data/robo_ttt/robocasa_memory_20261103'))/'evaluation-ck30000-20261108'/'cotrain-ck3000-20261114' # [packaged] relocatable root | |
| os.environ.update(GIT_CONFIG_COUNT='1', GIT_CONFIG_KEY_0='safe.directory', | |
| GIT_CONFIG_VALUE_0=str(root.parent/'SimpleMemVLA')) | |
| sys.path.insert(0, str(root/'author-code')) | |
| --- original/rollout_stats.py | |
| +++ packaged/rollout_stats.py | |
| import h5py | |
| import numpy as np | |
| -E = Path('/data/robo_ttt/robocasa_memory_20261103/evaluation-ck30000-20261108') | |
| +ORIGINAL_ROOT = '/data/robo_ttt/robocasa_memory_20261103' | |
| +ROOT = __import__('os').environ.get('RDR_ROOT', ORIGINAL_ROOT) # [packaged] relocatable root, default = original | |
| +E = Path(ROOT)/'evaluation-ck30000-20261108' | |
| + | |
| + | |
| +def L(p): # [packaged] map an original absolute path recorded in plans / source metadata onto RDR_ROOT | |
| + p = str(p) | |
| + return Path(ROOT+p[len(ORIGINAL_ROOT):]) if p.startswith(ORIGINAL_ROOT) else Path(p) | |
| OLD = E/'cotrain-ck3000-20261114'; N = E/'cotrain-delay-n10-20261115' | |
| ARM, BASE = slice(0, 6), slice(7, 11) # native action: arm 0-5, gripper 6, base/torso 7-10, mode 11 | |
| --- original/run_stage.py | |
| +++ packaged/run_stage.py | |
| import argparse, fcntl, hashlib, json, os, subprocess, time | |
| from pathlib import Path | |
| -E = Path('/data/robo_ttt/robocasa_memory_20261103/evaluation-ck30000-20261108') | |
| +ORIGINAL_ROOT = '/data/robo_ttt/robocasa_memory_20261103' | |
| +ROOT = __import__('os').environ.get('RDR_ROOT', ORIGINAL_ROOT) # [packaged] relocatable root, default = original | |
| +E = Path(ROOT)/'evaluation-ck30000-20261108' | |
| + | |
| + | |
| +def L(p): # [packaged] map an original absolute path recorded in plans / source metadata onto RDR_ROOT | |
| + p = str(p) | |
| + return Path(ROOT+p[len(ORIGINAL_ROOT):]) if p.startswith(ORIGINAL_ROOT) else Path(p) | |
| R = E.parent | |
| N = E/'cotrain-delay-n10-20261115' | |
| HERE = Path(__file__).resolve().parent | |