-
Notifications
You must be signed in to change notification settings - Fork 4
/
train.py
62 lines (49 loc) · 1.58 KB
/
train.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
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
from yolo_solver import YoloSolver
from dataset import yoloDataset
import config as cfg
from yoloLoss import yoloLoss
import argparse
import tensorflow as tf
import os
parser = argparse.ArgumentParser()
parser.add_argument('-n','--net',type=str,default='Vgg16',choices=cfg.net_style,help='net style')
parser.add_argument('--gpu',type=int,default=1,help='train gpu')
FLAGS,unknown = parser.parse_known_args()
os.environ['CUDA_VISIBLE_DEVICES']= str(FLAGS.gpu)
vgg16_config = {
'name':'Vgg16',
'pretained_model':'./model/vgg16.npy',
'mode':0
}
vgg19_config = {
'name':'Vgg19',
'pretained_model':'./model/vgg16.npy',
'mode':0
}
resnet50_config = {
'name':'resnet50',
'pretained_model':'./model/resnet',
'mode':1
}
def choose_net(FLAGS,nets):
for net in nets:
if net['name'] == FLAGS.net:
return net
return resnet50_config
def main():
print('please choose net from:',cfg.net_style)
netconfig = choose_net(FLAGS,[vgg16_config,vgg19_config,resnet50_config])
train_dataset = yoloDataset(cfg.common_params,cfg.dataset_params,cfg.dataset_params['train_file'])
test_dataset = yoloDataset(cfg.common_params,cfg.dataset_params,cfg.dataset_params['test_file'],train=False)
dataset = {
'train':train_dataset,
'test':test_dataset
}
yololoss = yoloLoss(cfg.common_params,netconfig)
solver = YoloSolver(dataset,netconfig,yololoss,cfg.common_params,cfg.solver_params)
solver.solve()
if __name__=='__main__':
main()