-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtrain.py
67 lines (57 loc) · 1.79 KB
/
train.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
57
58
59
60
61
62
63
64
65
66
67
"""
Usage:
Training:
python train.py --config-name=train_diffusion_lowdim_workspace
"""
import sys
# use line-buffering for both stdout and stderr
sys.stdout = open(sys.stdout.fileno(), mode='w', buffering=1)
sys.stderr = open(sys.stderr.fileno(), mode='w', buffering=1)
import hydra
from omegaconf import OmegaConf
import pathlib
from equi_diffpo.workspace.base_workspace import BaseWorkspace
max_steps = {
'stack_d1': 400,
'stack_three_d1': 400,
'square_d2': 400,
'threading_d2': 400,
'coffee_d2': 400,
'three_piece_assembly_d2': 500,
'hammer_cleanup_d1': 500,
'mug_cleanup_d1': 500,
'kitchen_d1': 800,
'nut_assembly_d0': 500,
'pick_place_d0': 1000,
'coffee_preparation_d1': 800,
'tool_hang': 700,
'can': 400,
'lift': 400,
'square': 400,
}
def get_ws_x_center(task_name):
if task_name.startswith('kitchen_') or task_name.startswith('hammer_cleanup_'):
return -0.2
else:
return 0.
def get_ws_y_center(task_name):
return 0.
OmegaConf.register_new_resolver("get_max_steps", lambda x: max_steps[x], replace=True)
OmegaConf.register_new_resolver("get_ws_x_center", get_ws_x_center, replace=True)
OmegaConf.register_new_resolver("get_ws_y_center", get_ws_y_center, replace=True)
# allows arbitrary python code execution in configs using the ${eval:''} resolver
OmegaConf.register_new_resolver("eval", eval, replace=True)
@hydra.main(
version_base=None,
config_path=str(pathlib.Path(__file__).parent.joinpath(
'equi_diffpo','config'))
)
def main(cfg: OmegaConf):
# resolve immediately so all the ${now:} resolvers
# will use the same time.
OmegaConf.resolve(cfg)
cls = hydra.utils.get_class(cfg._target_)
workspace: BaseWorkspace = cls(cfg)
workspace.run()
if __name__ == "__main__":
main()