MCPcopy Create free account
hub / github.com/MotrixLab/insactor / main

Function main

mimic.py:22–113  ·  view source on GitHub ↗
(argv)

Source from the content-addressed store, hash-verified

20
21
22def main(argv):
23 with open(FLAGS.config, 'r') as f:
24 args = AttrDict(yaml.safe_load(f))
25
26 logdir = "logs/exp"
27 pretrain = None
28 for k, v in args.items():
29 if k == 'motion_dir':
30 logdir += f"_{v.split('/')[-1].split('.')[0]}"
31 elif k == 'pretrain':
32 from brax.io import model
33 pretrain = model.load_params(v)
34 logdir += f"_resume"
35 else:
36 logdir += f"_{v}"
37
38 model_fn = functools.partial(
39 apg_networks.make_apg_networks,
40 hidden_layer_sizes=(512, 512, 512) if not args.get('large', False) else (1024,) * 5
41 )
42
43 local_device_count = jax.local_device_count()
44 train_set = MotionDataset(motion_dir=args.motion_dir, seq_len=args.ep_len, subset=args.get('subset', None), resample=args.get('resample', False))
45 train_sampler = RandomSampler(train_set, replacement=True, num_samples=2**31)
46 train_loader = NumpyLoader(
47 train_set,
48 sampler=train_sampler,
49 batch_size=args.num_envs * local_device_count,
50 num_workers=0
51 )
52
53 test_set = MotionDataset(motion_dir=args.motion_dir, seq_len=args.ep_len_eval, subset=args.get('subset', None))
54 test_sampler = RandomSampler(test_set, replacement=True, num_samples=2**31)
55 test_loader = NumpyLoader(
56 test_set,
57 batch_size=args.num_eval_envs,
58 sampler=test_sampler,
59 num_workers=0
60 )
61 train_env = envs.get_environment(
62 env_name="humanoid_mimic_train",
63 system_config=args.system_config,
64 early_termination=args.early_termination,
65 demo_replay_mode=args.demo_replay_mode,
66 err_threshold=args.threshold,
67 replay_rate=args.replay_rate,
68 reward_scaling=args.reward_scaling,
69 vel_weight=args.vel_weight,
70 rot_weight=args.get('rot_weight', 0.25),
71 ang_weight=args.get('ang_weight', 0.01),
72 foot_weight=args.get('foot_weight', 0.0),
73 local=args.get('local', 'none'),
74 )
75
76 eval_env = envs.get_environment(
77 env_name="humanoid_mimic",
78 system_config=args.system_config,
79 vel_weight=args.vel_weight,

Callers

nothing calls this directly

Calls 3

AttrDictClass · 0.90
MotionDatasetClass · 0.90
NumpyLoaderClass · 0.90

Tested by

no test coverage detected