v0.7 (#26)
* update from scratch configs * update gym pretraining configs - use fewer epochs * update robomimic pretraining configs - use fewer epochs * allow trajectory plotting in eval agent * add simple vit unet * update avoid pretraining configs - use fewer epochs * update furniture pretraining configs - use same amount of epochs as before * add robomimic diffusion unet pretraining configs * update robomimic finetuning configs - higher lr * add vit unet checkpoint urls * update pretraining and finetuning instructions as configs are updated
This commit is contained in:
@@ -57,6 +57,7 @@ class EvalAgent:
|
||||
self.horizon_steps = cfg.horizon_steps
|
||||
self.max_episode_steps = cfg.env.max_episode_steps
|
||||
self.reset_at_iteration = cfg.env.get("reset_at_iteration", True)
|
||||
self.save_full_observations = cfg.env.get("save_full_observations", False)
|
||||
self.furniture_sparse_reward = (
|
||||
cfg.env.specific.get("sparse_reward", False)
|
||||
if "specific" in cfg.env
|
||||
@@ -85,6 +86,10 @@ class EvalAgent:
|
||||
assert not (
|
||||
self.n_render <= 0 and self.render_video
|
||||
), "Need to set n_render > 0 if saving video"
|
||||
self.traj_plotter = (
|
||||
hydra.utils.instantiate(cfg.plotter)
|
||||
if "plotter" in cfg else None
|
||||
)
|
||||
|
||||
def run(self):
|
||||
pass
|
||||
|
||||
@@ -37,6 +37,11 @@ class EvalDiffusionAgent(EvalAgent):
|
||||
prev_obs_venv = self.reset_env_all(options_venv=options_venv)
|
||||
firsts_trajs[0] = 1
|
||||
reward_trajs = np.zeros((self.n_steps, self.n_envs))
|
||||
if self.save_full_observations: # state-only
|
||||
obs_full_trajs = np.empty((0, self.n_envs, self.obs_dim))
|
||||
obs_full_trajs = np.vstack(
|
||||
(obs_full_trajs, prev_obs_venv["state"][:, -1][None])
|
||||
)
|
||||
|
||||
# Collect a set of trajectories from env
|
||||
for step in range(self.n_steps):
|
||||
@@ -62,6 +67,13 @@ class EvalDiffusionAgent(EvalAgent):
|
||||
)
|
||||
reward_trajs[step] = reward_venv
|
||||
firsts_trajs[step + 1] = terminated_venv | truncated_venv
|
||||
if self.save_full_observations: # state-only
|
||||
obs_full_venv = np.array(
|
||||
[info["full_obs"]["state"] for info in info_venv]
|
||||
) # n_envs x act_steps x obs_dim
|
||||
obs_full_trajs = np.vstack(
|
||||
(obs_full_trajs, obs_full_venv.transpose(1, 0, 2))
|
||||
)
|
||||
|
||||
# update for next step
|
||||
prev_obs_venv = obs_venv
|
||||
@@ -108,6 +120,16 @@ class EvalDiffusionAgent(EvalAgent):
|
||||
success_rate = 0
|
||||
log.info("[WARNING] No episode completed within the iteration!")
|
||||
|
||||
# Plot state trajectories (only in D3IL)
|
||||
if self.traj_plotter is not None:
|
||||
self.traj_plotter(
|
||||
obs_full_trajs=obs_full_trajs,
|
||||
n_render=self.n_render,
|
||||
max_episode_steps=self.max_episode_steps,
|
||||
render_dir=self.render_dir,
|
||||
itr=0,
|
||||
)
|
||||
|
||||
# Log loss and save metrics
|
||||
time = timer()
|
||||
log.info(
|
||||
|
||||
Reference in New Issue
Block a user