-
Notifications
You must be signed in to change notification settings - Fork 3
/
train_grasppose.py
67 lines (48 loc) · 2.28 KB
/
train_grasppose.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
import argparse
import os
import sys
from utils.cfg_parser import Config
from WholeGraspPose.trainer import Trainer
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='GrabNet-Training')
parser.add_argument('--work-dir', default='logs/GraspPose', type=str,
help='The path to the downloaded grab data')
parser.add_argument('--gender', default=None, type=str,
help='The gender of dataset')
parser.add_argument('--data_path', default = '/cluster/work/cvl/wuyan/data/GRAB-series/GrabPose_r_fullbody/data', type=str,
help='The path to the folder that contains grabpose data')
parser.add_argument('--batch-size', default=64, type=int,
help='Training batch size')
parser.add_argument('--n-workers', default=8, type=int,
help='Number of PyTorch dataloader workers')
parser.add_argument('--lr', default=5e-4, type=float,
help='Training learning rate')
parser.add_argument('--kl-coef', default=0.5, type=float,
help='KL divergence coefficent for Coarsenet training')
parser.add_argument('--use-multigpu', default=False,
type=lambda arg: arg.lower() in ['true', '1'],
help='If to use multiple GPUs for training')
parser.add_argument('--exp_name', default = None, type=str,
help='experiment name')
args = parser.parse_args()
work_dir = os.path.join(args.work_dir, args.exp_name)
cwd = os.getcwd()
default_cfg_path = 'WholeGraspPose/configs/WholeGraspPose.yaml'
cfg = {
'batch_size': args.batch_size,
'n_workers': args.n_workers,
'use_multigpu': args.use_multigpu,
'kl_coef': args.kl_coef,
'dataset_dir': args.data_path,
'base_dir': cwd,
'work_dir': work_dir,
'base_lr': args.lr,
'best_net': None,
'gender': args.gender,
'exp_name': args.exp_name,
}
cfg = Config(default_cfg_path=default_cfg_path, **cfg)
grabpose_trainer = Trainer(cfg=cfg)
grabpose_trainer.fit()
cfg = grabpose_trainer.cfg
cfg.write_cfg(os.path.join(work_dir, 'TR%02d_%s' % (cfg.try_num, os.path.basename(default_cfg_path))))