anthony01 commited on
Commit
279fbd2
·
1 Parent(s): 98a0c19

Initial commit

Browse files
.gitignore CHANGED
@@ -1,7 +1,7 @@
1
  # *.pth
2
  # processed_data/
3
  __pycache__/
4
- .ipynb_checkpoints/
5
  # *.npy
6
  .DS_Store
7
 
 
1
  # *.pth
2
  # processed_data/
3
  __pycache__/
4
+ # .ipynb_checkpoints/
5
  # *.npy
6
  .DS_Store
7
 
.ipynb_checkpoints/runner-checkpoint.py ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import warnings
2
+ import argparse
3
+
4
+ import train_nn
5
+ import train_xgb
6
+ from cnn_runner import save_cnn_features
7
+
8
+ parser = argparse.ArgumentParser(
9
+ description="INCLUDE trainer for xgboost, lstm and transformer"
10
+ )
11
+ parser.add_argument("--seed", default=0, type=int, help="seed value")
12
+ parser.add_argument(
13
+ "--dataset", default="include", type=str, help="options: include or include50"
14
+ )
15
+ parser.add_argument(
16
+ "--use_augs",
17
+ action="store_true",
18
+ help="use augmented data",
19
+ )
20
+ parser.add_argument(
21
+ "--use_cnn",
22
+ action="store_true",
23
+ help="use mobilenet to convert keypoints to videos and generate embeddings from CNN",
24
+ )
25
+ parser.add_argument(
26
+ "--model",
27
+ default="lstm",
28
+ type=str,
29
+ help="options: lstm, transformer, xgboost",
30
+ )
31
+ parser.add_argument(
32
+ "--data_dir",
33
+ default="",
34
+ type=str,
35
+ required=True,
36
+ help="location to train, val and test json files",
37
+ )
38
+ parser.add_argument(
39
+ "--save_path",
40
+ default="./",
41
+ type=str,
42
+ help="location to save trained model",
43
+ )
44
+ parser.add_argument(
45
+ "--epochs", default=50, type=int, help="number of epochs to train the model"
46
+ )
47
+ parser.add_argument("--batch_size", default=128, type=int, help="batch size of data")
48
+ parser.add_argument(
49
+ "--learning_rate",
50
+ default=1e-4,
51
+ type=float,
52
+ help="learning rate for training neural net",
53
+ )
54
+ parser.add_argument(
55
+ "--transformer_size", default="small", type=str, help="options: small, large"
56
+ )
57
+ parser.add_argument(
58
+ "--use_pretrained",
59
+ default=None,
60
+ help="use pretrained model. options: evaluate, resume_training",
61
+ )
62
+ args = parser.parse_args()
63
+
64
+
65
+ if __name__ == "__main__":
66
+
67
+ if args.model == "xgboost":
68
+ if args.use_pretrained:
69
+ raise Exception("Pre-trained models are not available for XGBoost")
70
+ if args.use_cnn:
71
+ warnings.warn(
72
+ "use_cnn flag set to true for xgboost model. xgboost will not use cnn features"
73
+ )
74
+ train_xgb.fit(args)
75
+ train_xgb.evaluate(args)
76
+
77
+ else:
78
+ if args.use_cnn:
79
+ save_cnn_features(args)
80
+ if args.use_augs:
81
+ warnings.warn("cannot perform augmentation on cnn features")
82
+ if args.use_pretrained == "evaluate":
83
+ train_nn.evaluate(args)
84
+ print("### Evaluated from pretrained model ###")
85
+ else:
86
+ print("### Starting to train. ###")
87
+ train_nn.fit(args)
88
+ train_nn.evaluate(args)