-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinference.py
56 lines (39 loc) · 1.82 KB
/
inference.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os
import sys
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.append(BASE_DIR)
sys.path.append(os.path.join(BASE_DIR, 'tasks'))
sys.path.append(os.path.join(BASE_DIR, 'run_utils'))
sys.path.append(os.path.join(BASE_DIR, 'utils'))
sys.path.append(os.path.join(BASE_DIR, 'agents'))
sys.path.append(os.path.join(BASE_DIR, 'assets'))
sys.path.append(os.path.join(BASE_DIR, 'collision_predictor'))
sys.path.append(os.path.join(BASE_DIR, 'pcfgrasp_method'))
sys.path.append(os.path.join(BASE_DIR, 'agents', 'ppo'))
from run_utils.register import gen_task, gen_agent
from run_utils.parser import get_args, gen_sim_params, set_seed
from run_utils.config import load_config
import torch
def inference():
# torch.backends.cuda.matmul.allow_tf32 = True
# torch.backends.cudnn.benchmark = True
# torch.backends.cudnn.deterministic = False
# torch.backends.cudnn.allow_tf32 = True
# task selection 这里输出的是一个vec task,不过由于isaac gym本身的特点,导致vec task 和其他的不同,task本身就是多环境的
print('train.task.env')
env = gen_task(args, cfg, sim_params=sim_params, logdir=logdir)
# agent selection
agent = gen_agent(args, env, cfg, logdir)
#执行了PPO对象的run函数,后面的参数是最大迭代次数和保存间隔
print('train.agent.run')
agent.inference(args.model_dir)
# 这里相当于之前的train部分,不过现在dataset是从环境仿真中实时获得的,这里的agent现在就不一定是ppo了
if __name__ == '__main__':
#get args
args = get_args()
#load cfg
cfg, logdir = load_config(args)
#sim_params
sim_params = gen_sim_params(args, cfg)
# set_seed(cfg_train.get("seed", -1), cfg_train.get("torch_deterministic", False))
inference()