-
Notifications
You must be signed in to change notification settings - Fork 45
/
opt.py
72 lines (63 loc) · 4.02 KB
/
opt.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
68
69
70
71
72
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import argparse
from pprint import pprint
class Options:
def __init__(self):
self.parser = argparse.ArgumentParser()
self.opt = None
def _initial(self):
# ===============================================================
# General options
# ===============================================================
self.parser.add_argument('--data_dir', type=str, default='/home/wei/Downloads/h3.6m/dataset/', help='path to H36M dataset')
self.parser.add_argument('--data_dir_3dpw', type=str, default='/home/wei/Downloads/3DPW/sequenceFiles/', help='path to 3DPW dataset')
self.parser.add_argument('--data_dir_cmu', type=str, default='/home/wei/Downloads/cmu_mocap/', help='path to CMU dataset')
self.parser.add_argument('--exp', type=str, default='test', help='ID of experiment')
self.parser.add_argument('--ckpt', type=str, default='checkpoint/', help='path to save checkpoint')
# ===============================================================
# Model options
# ===============================================================
self.parser.add_argument('--max_norm', dest='max_norm', action='store_true',
help='maxnorm constraint to weights')
self.parser.add_argument('--linear_size', type=int, default=256, help='size of each model layer')
self.parser.add_argument('--num_stage', type=int, default=12, help='# layers in linear model')
# ===============================================================
# Running options
# ===============================================================
self.parser.add_argument('--lr', type=float, default=5.0e-4)
self.parser.add_argument('--lr_decay', type=int, default=2, help='every lr_decay epoch do lr decay')
self.parser.add_argument('--lr_gamma', type=float, default=0.96)
self.parser.add_argument('--input_n', type=int, default=10, help='observed seq length')
self.parser.add_argument('--output_n', type=int, default=25, help='future seq length')
self.parser.add_argument('--dct_n', type=int, default=35, help='number of DCT coeff. preserved for 3D')
self.parser.add_argument('--actions', type=str, default='all', help='path to save checkpoint')
self.parser.add_argument('--epochs', type=int, default=50)
self.parser.add_argument('--dropout', type=float, default=0.5,
help='dropout probability, 1.0 to make no dropout')
self.parser.add_argument('--train_batch', type=int, default=16)
self.parser.add_argument('--test_batch', type=int, default=128)
self.parser.add_argument('--job', type=int, default=10, help='subprocesses to use for data loading')
self.parser.add_argument('--is_load', dest='is_load', action='store_true', help='wether to load existing model')
self.parser.add_argument('--sample_rate', type=int, default=2, help='frame sampling rate')
self.parser.add_argument('--is_norm_dct', dest='is_norm_dct', action='store_true', help='whether to normalize the dct coeff')
self.parser.add_argument('--is_norm', dest='is_norm', action='store_true', help='whether to normalize the angles/3d coordinates')
self.parser.set_defaults(max_norm=True)
self.parser.set_defaults(is_load=False)
# self.parser.set_defaults(is_norm_dct=True)
# self.parser.set_defaults(is_norm=True)
def _print(self):
print("\n==================Options=================")
pprint(vars(self.opt), indent=4)
print("==========================================\n")
def parse(self):
self._initial()
self.opt = self.parser.parse_args()
# do some pre-check
ckpt = os.path.join(self.opt.ckpt, self.opt.exp)
if not os.path.isdir(ckpt):
os.makedirs(ckpt)
self.opt.ckpt = ckpt
self._print()
return self.opt