'scene_name': 'bedroom_05', 'terminal_state_id': int(task_scope), #'initial_state': EVAL_INIT_LOC, }) real_target_xz.append([xz_numpy[int(task_scope)][0], xz_numpy[int(task_scope)][1]]) ep_rewards = [] ep_lengths = [] ep_collisions = [] scopes = [network_scope, scene_scope, task_scope] #time.sleep(5) if 1: time.sleep(1) cv2.imshow('target image', env.observation_target) cv2.waitKey(0) viewer = SimpleImageViewer() viewer.imshow(env.observation,str(0)) time.sleep(5) for i_episode in range(NUM_EVAL_EPISODES): env.reset() current_idindex=env.current_state_id terminal = False ep_reward = 0 ep_collision = 0 ep_t = 0 ep_action = [] show_target = [] max_value = [] max_index = 0
random_start=False, random_terminal=False, whe_show=False, terminal_id=20, start_id=0, whe_use_image=True, whe_flatten=False, num_of_frames=1) # manually disable terminal states # env.terminals = np.zeros_like(env.terminals) # env.terminal_states, = np.where(env.terminals) # env.reset() # 命令参数初始化 human_agent_action = None human_wants_restart = False stop_requested = False viewer = SimpleImageViewer() viewer.imshow(env.observation) viewer.window.on_key_press = key_press print("Use arrow keys to move the agent.") print("Press R to reset agent\'s location.") print("Press Q to quit.") rollout(env) print("Goodbye.")
#fo.write('%s \n', %task_scope) env = Environment({ 'scene_name': scene_scope, 'terminal_state_id': task_scope[0], 'checkpoint_state_id': task_scope[1] }) ep_rewards = [] ep_lengths = [] ep_collisions = [] scopes = [network_scope, scene_scope, task_scope] print('evaluation: %s %s' % (scene_scope, task_scope)) viewer = SimpleImageViewer() #NUM_EVAL_EPISODES for i_episode in range(2): env.reset() terminal = False ep_reward = 0 ep_collision = 0 ep_t = 0 f.write(str(counter * 5 + i_episode) + ': [') path_x = [] path_y = [] path_x.append(int(env.x * 2)) path_y.append(int(env.z * 2)) int(env.z * 2)
if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument("-s", "--scene_dump", type=str, default="./data/nnew1.h5", help="path to a hdf5 scene dump file") parser.add_argument("-n", "--n_episode", type=int, default=20, help="number of episode to run") args = parser.parse_args() print("Loading scene dump {}".format(args.scene_dump)) env = THORDiscreteEnvironment({'h5_file_path': args.scene_dump}) viewer = SimpleImageViewer() results = [] for i in range(args.n_episode): env.reset() graph = build_graph() results.append(navigate(env, graph)) print("Success for %s times out of %s episode" % (len(np.array(results).nonzero()), args.n_episode)) viewer.close()
print("Loading scene dump {}".format(args.scene_dump)) env = THORDiscreteEnvironment({ 'h5_file_path': args.scene_dump, 'initial_state': args.start, }) # manually disable terminal states env.terminals = np.zeros_like(env.terminals) env.terminal_states, = np.where(env.terminals) env.reset() human_agent_action = None human_wants_restart = False stop_requested = False action_list = [int(i) for i in args.action.split(',')] if args.action else None action_idx = 0 save_img = None viewer = SimpleImageViewer(save_dir=args.save_dir) viewer.imshow(env.observation, save_img=0) viewer.window.on_key_press = key_press print("Use arrow keys to move the agent.") print("Press R to reset agent\'s location.") print("Press Q to quit.") rollout(env) print("Goodbye.")
'terminal_state_id': int(task_scope), #'initial_state': EVAL_INIT_LOC, }) real_target_xz.append( [xz_numpy[int(task_scope)][0], xz_numpy[int(task_scope)][1]]) ep_rewards = [] ep_lengths = [] ep_collisions = [] scopes = [network_scope, scene_scope, task_scope] #time.sleep(5) if 1: time.sleep(1) cv2.imshow('target image', env.observation_target) cv2.waitKey(0) viewer = SimpleImageViewer() viewer.imshow(env.observation, str(0)) time.sleep(5) for i_episode in range(NUM_EVAL_EPISODES): env.reset() current_idindex = env.current_state_id terminal = False ep_reward = 0 ep_collision = 0 ep_t = 0 ep_action = [] show_target = [] max_value = [] max_index = 0