-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
71 lines (56 loc) · 2.37 KB
/
main.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
import argparse
import yaml
def parse_args():
parser = argparse.ArgumentParser(description='Test dlc creation')
parser.add_argument('--model', type=str, help='specify model')
parser.add_argument('--task', type=str, help='specify task')
parser.add_argument('--project', type=str, help='specify project')
parser.add_argument('--iteration', type=str, help='specify iteration')
parser.add_argument('--snapshot', type=str, help='specify snapshot')
parser.add_argument('--shuffle', type=str, help='specify shuffle')
parser.add_argument('--scorer', type=str, default='unknown', help='specify scorer name')
parser.add_argument('--dataset', type=str, help='specify dataset')
parser.add_argument('--mm_dataset', type=str, help='specify mmaction2 dataset')
parser.add_argument('--species', nargs='+', help='specify species')
parser.add_argument('--all_keypoints', nargs='+', help='specify all keypoints')
parser.add_argument('--keypoints', nargs='+', help='specify keypoints')
parser.add_argument('--visibility', type=str, help='specify visibility')
parser.add_argument('--network', type=str, help='specify network type')
parser.add_argument('--gpu', type=str, help='specify GPU id')
parser.add_argument('--cross_validation', type=str, help='specify cross validation')
args = parser.parse_args()
return args
def read_config():
with open('conf.yaml', 'r') as file:
config = yaml.safe_load(file)
return config
def use_deeplabcut(args, cfg):
from tools.dlc_utils import DLC
dl = DLC(args)
if args.task == 'create':
dl.create_project()
dl.generate_csv()
elif args.task == 'create_dataset':
dl.create_training_dataset()
elif args.task == 'train':
dl.train(cfg)
elif args.task == 'evaluate':
dl.evaluate()
def use_posec3d(args, cfg):
if args.task == 'create_dataset':
from tools.mmaction_utils import MMA
mm = MMA(args)
mm.analyze_videos()
mm.create_training_dataset()
elif args.task == 'train':
from tools.mm_distr_train import distributed_training
distributed_training(args, cfg)
def main():
args = parse_args()
cfg = read_config()
if args.model == 'DEEPLABCUT':
use_deeplabcut(args, cfg)
elif args.model == 'POSEC3D':
use_posec3d(args, cfg)
if __name__ == "__main__":
main()