@@ -28,15 +28,25 @@ def eval(custom_args, ckpt_path=None):
28
28
# TODO: add support for eval mode
29
29
beauty_print ("Start evaluating" )
30
30
31
- env , args = setup (custom_args , eval_mode = True )
31
+ env , agent = setup (custom_args , eval_mode = True )
32
32
33
33
# load checkpoint
34
34
if ckpt_path is None :
35
35
ckpt_path = model_zoo (name = "CURICabinetPPO_right_arm.pt" )
36
- agent .load ( ckpt_path )
36
+ agent .save_or_load_agent ( cwd = ckpt_path , if_save = False )
37
37
38
38
# evaluate the agent
39
- trainer .eval ()
39
+ state = env .reset ()
40
+ episode_reward = 0
41
+ for i in range (2 ** 10 ):
42
+ action = agent .act .get_action (state ).detach ()
43
+ next_state , reward , done , _ = env .step (action )
44
+ episode_reward += reward .mean ()
45
+ # if done:
46
+ # print(f'Step {i:>6}, Episode return {episode_reward:8.3f}')
47
+ # break
48
+ # else:
49
+ state = next_state
40
50
41
51
42
52
if __name__ == '__main__' :
@@ -47,15 +57,12 @@ def eval(custom_args, ckpt_path=None):
47
57
parser .add_argument ("--sim_device" , type = str , default = "cuda:{}" .format (gpu_id ))
48
58
parser .add_argument ("--rl_device" , type = str , default = "cuda:{}" .format (gpu_id ))
49
59
parser .add_argument ("--graphics_device_id" , type = int , default = gpu_id )
50
- parser .add_argument ("--headless" , type = str , default = "False " )
60
+ parser .add_argument ("--headless" , type = str , default = "True " )
51
61
parser .add_argument ("--test" , action = "store_true" , help = "turn to test mode while adding this argument" )
52
62
custom_args = parser .parse_args ()
53
63
54
64
if not custom_args .test :
55
65
train (custom_args )
56
66
else :
57
- # TODO: add support for eval mode
58
- folder = 'CURICabinetSAC_22-11-27_18-38-53-296354'
59
- ckpt_path = "/home/ubuntu/Github/Knowledge-Universe/Robotics/Roadmap-for-robot-science/rofunc/examples/learning/runs/{}/checkpoints/best_agent.pt" .format (
60
- folder )
67
+ ckpt_path = "/home/ubuntu/Github/Knowledge-Universe/Robotics/Roadmap-for-robot-science/rofunc/examples/learning/result/CURICabinet_SAC_42/actor_53608448_00007.742.pth"
61
68
eval (custom_args , ckpt_path = ckpt_path )
0 commit comments