1+ from __future__ import absolute_import
2+ from __future__ import division
3+ from __future__ import print_function
4+ import sys
5+ sys .path .append ('./' )
6+
7+ import six
8+ import os
9+ import os .path as osp
10+ import math
11+ import argparse
12+
13+
14+ parser = argparse .ArgumentParser (description = "Softmax loss classification" )
15+ # data
16+ parser .add_argument ('--synthetic_train_data_dir' , nargs = '+' , type = str , metavar = 'PATH' ,
17+ default = ['/share/zhui/reg_dataset/NIPS2014' ])
18+ parser .add_argument ('--real_train_data_dir' , type = str , metavar = 'PATH' ,
19+ default = '/data/zhui/benchmark/cocotext_trainval' )
20+ parser .add_argument ('--extra_train_data_dir' , nargs = '+' , type = str , metavar = 'PATH' ,
21+ default = ['/share/zhui/reg_dataset/CVPR2016' ])
22+ parser .add_argument ('--test_data_dir' , type = str , metavar = 'PATH' ,
23+ default = '/share/zhui/reg_dataset/IIIT5K_3000' )
24+ parser .add_argument ('--MULTI_TRAINDATA' , action = 'store_true' , default = False ,
25+ help = 'whether use the extra_train_data for training.' )
26+ parser .add_argument ('-b' , '--batch_size' , type = int , default = 128 )
27+ parser .add_argument ('-j' , '--workers' , type = int , default = 8 )
28+ parser .add_argument ('--height' , type = int , default = 64 ,
29+ help = "input height, default: 256 for resnet*, " "64 for inception" )
30+ parser .add_argument ('--width' , type = int , default = 256 ,
31+ help = "input width, default: 128 for resnet*, " "256 for inception" )
32+ parser .add_argument ('--keep_ratio' , action = 'store_true' , default = False ,
33+ help = 'length fixed or lenghth variable.' )
34+ parser .add_argument ('--voc_type' , type = str , default = 'ALLCASES_SYMBOLS' ,
35+ choices = ['LOWERCASE' , 'ALLCASES' , 'ALLCASES_SYMBOLS' ])
36+ parser .add_argument ('--mix_data' , action = 'store_true' ,
37+ help = "whether combine multi datasets in the training stage." )
38+ parser .add_argument ('--num_train' , type = int , default = math .inf )
39+ parser .add_argument ('--num_test' , type = int , default = math .inf )
40+ parser .add_argument ('--aug' , action = 'store_true' , default = False ,
41+ help = 'whether use data augmentation.' )
42+ parser .add_argument ('--lexicon_type' , type = str , default = '0' , choices = ['0' , '50' , '1k' , 'full' ],
43+ help = 'which lexicon associated to image is used.' )
44+ parser .add_argument ('--image_path' , type = str , default = '' ,
45+ help = 'the path of single image, used in demo.py.' )
46+ parser .add_argument ('--tps_inputsize' , nargs = '+' , type = int , default = [32 , 64 ])
47+ parser .add_argument ('--tps_outputsize' , nargs = '+' , type = int , default = [32 , 100 ])
48+ # model
49+ parser .add_argument ('-a' , '--arch' , type = str , default = 'ResNet_ASTER' )
50+ parser .add_argument ('--dropout' , type = float , default = 0.5 )
51+ parser .add_argument ('--max_len' , type = int , default = 100 )
52+ parser .add_argument ('--n_group' , type = int , default = 1 )
53+ parser .add_argument ('--STN_ON' , action = 'store_true' ,
54+ help = 'add the stn head.' )
55+ parser .add_argument ('--tps_margins' , nargs = '+' , type = float , default = [0.05 ,0.05 ])
56+ parser .add_argument ('--stn_activation' , type = str , default = 'none' )
57+ parser .add_argument ('--num_control_points' , type = int , default = 20 )
58+ parser .add_argument ('--stn_with_dropout' , action = 'store_true' , default = False )
59+ ## lstm
60+ parser .add_argument ('--with_lstm' , action = 'store_true' , default = False ,
61+ help = 'whether append lstm after cnn in the encoder part.' )
62+ parser .add_argument ('--decoder_sdim' , type = int , default = 512 ,
63+ help = "the dim of hidden layer in decoder." )
64+ parser .add_argument ('--attDim' , type = int , default = 512 ,
65+ help = "the dim for attention." )
66+ # optimizer
67+ parser .add_argument ('--lr' , type = float , default = 1 ,
68+ help = "learning rate of new parameters, for pretrained "
69+ "parameters it is 10 times smaller than this" )
70+ parser .add_argument ('--momentum' , type = float , default = 0.9 )
71+ parser .add_argument ('--weight_decay' , type = float , default = 0.0 ) # the model maybe under-fitting, 0.0 gives much better results.
72+ parser .add_argument ('--grad_clip' , type = float , default = 1.0 )
73+ parser .add_argument ('--loss_weights' , nargs = '+' , type = float , default = [1 ,1 ,1 ])
74+ # training configs
75+ parser .add_argument ('--resume' , type = str , default = '' , metavar = 'PATH' )
76+ parser .add_argument ('--evaluate' , action = 'store_true' ,
77+ help = "evaluation only" )
78+ parser .add_argument ('--epochs' , type = int , default = 6 )
79+ parser .add_argument ('--start_save' , type = int , default = 0 ,
80+ help = "start saving checkpoints after specific epoch" )
81+ parser .add_argument ('--seed' , type = int , default = 1 )
82+ parser .add_argument ('--print_freq' , type = int , default = 100 )
83+ parser .add_argument ('--cuda' , default = True , type = bool ,
84+ help = 'whether use cuda support.' )
85+ # testing configs
86+ parser .add_argument ('--evaluation_metric' , type = str , default = 'accuracy' )
87+ parser .add_argument ('--evaluate_with_lexicon' , action = 'store_true' , default = False )
88+ parser .add_argument ('--beam_width' , type = int , default = 5 )
89+ # misc
90+ working_dir = osp .dirname (osp .dirname (osp .abspath (__file__ )))
91+ parser .add_argument ('--logs_dir' , type = str , metavar = 'PATH' ,
92+ default = osp .join (working_dir , 'logs' ))
93+ parser .add_argument ('--real_logs_dir' , type = str , metavar = 'PATH' ,
94+ default = '/media/mkyang/research/recognition/selfattention_rec' )
95+ parser .add_argument ('--debug' , action = 'store_true' ,
96+ help = "if debugging, some steps will be passed." )
97+ parser .add_argument ('--vis_dir' , type = str , metavar = 'PATH' , default = '' ,
98+ help = "whether visualize the results while evaluation." )
99+ parser .add_argument ('--run_on_remote' , action = 'store_true' , default = False ,
100+ help = "run the code on remote or local." )
101+
102+ def get_args (sys_args ):
103+ global_args = parser .parse_args (sys_args )
104+ return global_args
0 commit comments