|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+import argparse
|
|
|
2
|
+import torch
|
|
|
3
|
+import torchvision.models
|
|
|
4
|
+import sys
|
|
|
5
|
+import pandas
|
|
|
6
|
+
|
|
|
7
|
+
|
|
|
8
|
+
|
|
|
9
|
+'''
|
|
|
10
|
+filename:train_model_1.0.py
|
|
|
11
|
+create date: 11/17/2020 Tue
|
|
|
12
|
+Author: Jeong Geol Kim
|
|
|
13
|
+Contact: atarib4816@gmail.com
|
|
|
14
|
+Description: This .py file will train, save weight and save Results with parameters. parameters will input by .txt file.
|
|
|
15
|
+eg) train_model_1.0.py -r train_parameter.lcfg
|
|
|
16
|
+guidelines for train_parameter.txt
|
|
|
17
|
+filename format: partofarchitecture_backbone_yymmdd.lcfg
|
|
|
18
|
+eg) shapesort_mobilenetv2_201118.txt
|
|
|
19
|
+'''
|
|
|
20
|
+
|
|
|
21
|
+
|
|
|
22
|
+def Params_Set():
|
|
|
23
|
+ '''
|
|
|
24
|
+ Description: read options from .lcfg and initialize learning options.
|
|
|
25
|
+ You should write
|
|
|
26
|
+ '''
|
|
|
27
|
+ HELP_TEXT = "how to use .py" #TODO: write description more precisely
|
|
|
28
|
+ N_OF_PARAMS = 3 #from now on, .txt file has 3 pramas(backbone Name, iterations, save period)
|
|
|
29
|
+
|
|
|
30
|
+ parser = argparse.ArgumentParser(description = HELP_TEXT)
|
|
|
31
|
+ parser.add_argument("-r", required = True, help = '.lcfg file contains with learning configures')
|
|
|
32
|
+ args = parser.parse_args()
|
|
|
33
|
+
|
|
|
34
|
+ f = open(args.r, 'r')
|
|
|
35
|
+ p_string = f.readline()
|
|
|
36
|
+ f.close()
|
|
|
37
|
+ params = p_string.split()
|
|
|
38
|
+
|
|
|
39
|
+ if str(args.r[-4:]) != 'lcfg':
|
|
|
40
|
+ print ("Error: {} is wrong filename extension. Learning configures must written in .lcfg file")
|
|
|
41
|
+ return
|
|
|
42
|
+ elif len(params) != N_OF_PARAMS:
|
|
|
43
|
+ print("Error: {} is broken. please check learning configures.".format(args.r))
|
|
|
44
|
+ return
|
|
|
45
|
+ else:
|
|
|
46
|
+ print("---Learning Options---")
|
|
|
47
|
+ print("Backbone Name: {}".format(params[0]))
|
|
|
48
|
+ print("Number of iterations: {}".format(params[1]))
|
|
|
49
|
+ print("Period of saving weight: {}".format(params[2]))
|
|
|
50
|
+ return params, args.r
|
|
|
51
|
+
|
|
|
52
|
+
|
|
|
53
|
+def Preprocess():
|
|
|
54
|
+ pass
|
|
|
55
|
+
|
|
|
56
|
+
|
|
|
57
|
+
|
|
|
58
|
+def Model_Construct():
|
|
|
59
|
+ pass
|
|
|
60
|
+
|
|
|
61
|
+def Train():
|
|
|
62
|
+ pass
|
|
|
63
|
+
|
|
|
64
|
+def Save_Weight():
|
|
|
65
|
+ pass
|
|
|
66
|
+
|
|
|
67
|
+
|
|
|
68
|
+def Result():
|
|
|
69
|
+ pass
|
|
|
70
|
+
|
|
|
71
|
+
|
|
|
72
|
+
|
|
|
73
|
+
|
|
|
74
|
+if __name__ == "__main__":
|
|
|
75
|
+ #get all params from option files
|
|
|
76
|
+ params, name_of_lcfg = Params_Set()
|
|
|
77
|
+
|
|
|
78
|
+ Preprocess()
|
|
|
79
|
+
|
|
|
80
|
+ Model_Construct()
|
|
|
81
|
+
|
|
|
82
|
+ Train()
|
|
|
83
|
+
|
|
|
84
|
+ Save_Weight()
|
|
|
85
|
+
|
|
|
86
|
+ Result()
|
|
|
87
|
+
|
|
|
88
|
+
|
|
|
89
|
+
|
|
|
90
|
+
|
|
|
91
|
+
|