-
Notifications
You must be signed in to change notification settings - Fork 1
/
train.py
35 lines (29 loc) · 965 Bytes
/
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
"""
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 diffusion_policy.workspace.base_workspace import BaseWorkspace
# 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(
'diffusion_policy','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()