Commit 56ee893a authored by nilabha's avatar nilabha

add changes to support render for eval

parent 3f321add
Pipeline #5031 passed with stage
in 2 minutes and 31 seconds
evaluation_num_workers: 2
# Evaluation wokers for the evaluation run.
evaluation_interval: 50
# Episodes each time evaluation runs.
evaluation_num_episodes: 50
# Override the env config for evaluation.
evaluation_config:
explore: False
env_config:
seed: 100
render: human
\ No newline at end of file
evaluation_num_workers: 2
# Enable evaluation, once per training iteration.
evaluation_interval: 1
# Run 1 episode each time evaluation runs.
evaluation_num_episodes: 2
# Override the env config for evaluation.
evaluation_config:
explore: False
env_config:
seed: 100
render: human
\ No newline at end of file
......@@ -447,9 +447,10 @@ class FlatlandRenderWrapper(RailEnv,gym.Env):
show_debug=False,
screen_height=600, # Adjust these parameters to fit your resolution
screen_width=800) # Adjust these parameters to fit your resolution
self.renderer.show = False
def update_renderer(self, mode='human'):
image = self.renderer.render_env(show=True, show_observations=False, show_predictions=False,
image = self.renderer.render_env(show=False, show_observations=False, show_predictions=False,
return_image=True)
return image[:,:,:3]
......@@ -462,12 +463,12 @@ class FlatlandRenderWrapper(RailEnv,gym.Env):
super().close()
if self.renderer:
try:
self.renderer.close_window()
self.renderer = None
if self.renderer.show:
self.renderer.close_window()
except Exception as e:
# This is since the last step(Due to a stopping criteria) is skipped by rllib
# Due to this done is not true and the env does not close
# Finally the env is closed when RLLib exits but at that time there is no window
# and hence the error
print("Could Not close window due to:",e)
self.renderer = None
......@@ -192,6 +192,7 @@ def run(args, parser):
eval_configs = get_eval_config(exp['config'].get('env_config',\
{}).get('eval_generator',"default"))
eval_seed = eval_configs.get('evaluation_config',{}).get('env_config',{}).get('seed')
eval_render = eval_configs.get('evaluation_config',{}).get('env_config',{}).get('render')
# add evaluation config to the current config
exp['config'] = merge_dicts(exp['config'],eval_configs)
......@@ -201,6 +202,9 @@ def run(args, parser):
if eval_seed and eval_env_config:
# We override the env seed from the evaluation config
eval_env_config['seed'] = eval_seed
if eval_render and eval_env_config:
# We override the env render from the evaluation config
eval_env_config['render'] = eval_render
# Remove any wandb related configs
if eval_env_config:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment