def train_main(data_dir, model_dir, train_steps, input_yaml): cfg_from_file(input_yaml) print('Using config:') pprint.pprint(cfg) imdb = get_imdb('voc_2007_trainval') print('Loaded dataset `{:s}` for training'.format(imdb.name)) roidb = get_training_roidb(imdb) output_dir = get_output_dir(imdb, None) log_dir = get_log_dir(imdb) print('Output will be saved to `{:s}`'.format(output_dir)) print('Logs will be saved to `{:s}`'.format(log_dir)) device_name = '/gpu:0' print(device_name) network = get_network('VGGnet_train') train_net(network, imdb, roidb, output_dir=output_dir, log_dir=log_dir, pretrained_model='data/pretrain_model/VGG_imagenet.npy', max_iters=int(cfg.TRAIN.max_steps), restore=bool(int(cfg.TRAIN.restore)))
# fix the random seeds (numpy and caffe) for reproducibility np.random.seed(cfg.RNG_SEED) imdb = get_imdb(args.imdb_name) print 'Loaded dataset `{:s}` for training'.format(imdb.name) roidb = get_training_roidb(imdb) output_dir = args.output_dir # get_output_dir(imdb, None) ## benz if not os.path.exists(output_dir): os.makedirs(output_dir) os.system('cp ./lib/rpn_msr/generate_anchors.py %s' % (output_dir)) os.system('cp ./lib/fast_rcnn/config.py %s' % (output_dir)) os.system('cp ./experiments/cfgs/faster_rcnn_kitti.yml %s' % (output_dir)) log_dir = get_log_dir(imdb) print 'Output will be saved to `{:s}`'.format(output_dir) print 'Logs will be saved to `{:s}`'.format(log_dir) device_name = '/gpu:{:d}'.format(args.gpu_id) print device_name network = get_network(args.network_name) print 'Use network `{:s}` in training'.format(args.network_name) train_net(network, imdb, roidb, output_dir=output_dir, log_dir=log_dir, pretrained_model=args.pretrained_model, max_iters=args.max_iters, restore=bool(int(args.restore)))
if __name__ == '__main__': # 将text.yml的配置与默认config中的默认配置进行合并 cfg_from_file('text.yml') print('Using config:~~~~~~~~~~~~~~~~') # 根据给定的名字,得到要加载的数据集 imdb = get_imdb('voc_2007_trainval') print('Loaded dataset `{:s}` for training'.format(imdb.name)) # 准备训练数据 roidb = get_training_roidb(imdb) # 模型输出的路径 # output_dir = get_output_dir(imdb, None) output_dir = './ckpt' # summary的输出路径 log_dir = get_log_dir(imdb) device_name = '/gpu:0' print(device_name) network = get_network('VGGnet_train') train_net( network, imdb, roidb, output_dir=output_dir, log_dir=log_dir, pretrained_model='./pretrain_vggmodel/VGG_imagenet.npy', # pretrained_model='/home/xiaofeng/data/ctpn/pretrainde_vgg', # pretrained_model=None, max_iters=180000, restore=bool(int(1)))
from lib.fast_rcnn.train import get_training_roidb, train_net from lib.fast_rcnn.config import cfg_from_file, get_output_dir, get_log_dir from lib.datasets.factory import get_imdb from lib.networks.factory import get_network from lib.fast_rcnn.config import cfg if __name__ == '__main__': cfg_from_file('ctpn/text.yml') print('Using config:') pprint.pprint(cfg) imdb = get_imdb('voc_2007_trainval') print('Loaded dataset `{:s}` for training'.format(imdb.name)) roidb = get_training_roidb(imdb) output_dir = get_output_dir(imdb, None) log_dir = get_log_dir(imdb) print('Output will be saved to `{:s}`'.format(output_dir)) print('Logs will be saved to `{:s}`'.format(log_dir)) device_name = '/gpu:0' print(device_name) network = get_network('VGGnet_train') train_net(network, imdb, roidb, output_dir=output_dir, log_dir=log_dir, pretrained_model='data/pretrain_model/VGG_imagenet.npy', max_iters=int(cfg.TRAIN.max_steps), restore=bool(int(cfg.TRAIN.restore)))
output_dir = get_output_dir(imdb, None) log_dir = get_log_dir(imdb) print('Output will be saved to `{:s}`'.format(output_dir)) print('Logs will be saved to `{:s}`'.format(log_dir)) # device_name = '/gpu:'+str(CUDA_VISIBLE_DEVICES) # print(device_name) # 用vgg16训练 training_flag = tf.placeholder(tf.bool) network = get_network('VGGnet_train', training_flag) pretrained_model = 'data/pretrain/VGG_imagenet.npy' # 用densenet作为骨干网络,不加载预训练权重 # training_flag = tf.placeholder(tf.bool) # network = get_network('Densenet_train', training_flag) # pretrained_model = None train_net(network, training_flag, imdb, roidb, imdb_test, roidb_test, output_dir=output_dir, log_dir=log_dir, pretrained_model=pretrained_model, max_iters=int(cfg.TRAIN.max_steps), restore=bool(int(cfg.TRAIN.restore)))
from lib.fast_rcnn.config import cfg_from_file, get_output_dir, get_log_dir from lib.datasets.factory import get_imdb from lib.networks.factory import get_network from lib.fast_rcnn.config import cfg if __name__ == '__main__': cfg_from_file('text.yml') print('Using config:~~~~~~~~~~~~~~~~') imdb = get_imdb('voc_2007_trainval') print('Loaded dataset `{:s}` for training'.format(imdb.name)) roidb = get_training_roidb(imdb) output_dir = get_output_dir(imdb, None) log_dir = get_log_dir(imdb) print('Output will be saved to `{:s}`'.format(output_dir)) print('Logs will be saved to `{:s}`'.format(log_dir)) device_name = '/gpu:0' print(device_name) network = get_network('VGGnet_train') train_net(network, imdb, roidb, output_dir=output_dir, log_dir=log_dir, pretrained_model= '/home/zihao/Downloads/project/ctpn/ctpn/VGG_imagenet.npy', max_iters=180000, restore=bool(int(1)))
from lib.fast_rcnn.train import get_training_roidb, train_net from lib.fast_rcnn.config import cfg_from_file, get_output_dir, get_log_dir from lib.datasets.factory import get_imdb from lib.networks.factory import get_network from lib.fast_rcnn.config import cfg if __name__ == '__main__': cfg_from_file('ctpn/text.yml') print('Using config:') pprint.pprint(cfg) imdb = get_imdb('voc_2007_trainval') print('Loaded dataset `{:s}` for training'.format(imdb.name)) roidb = get_training_roidb(imdb) output_dir = get_output_dir(imdb, None) log_dir = get_log_dir(imdb) print('Output will be saved to `{:s}`'.format(output_dir)) print('Logs will be saved to `{:s}`'.format(log_dir)) device_name = '/gpu:0' print(device_name) network = get_network('VGGnet_train') train_net(network, imdb, roidb, output_dir = output_dir, log_dir = log_dir, pretrained_model = 'VGG_imagenet.npy', max_iters = 150000, restore = bool(int(cfg.TRAIN.restore)))
# 将text.yml的配置与默认config中的默认配置进行合并 cfg_from_file('text.yml') print('Using config:~~~~~~~~~~~~~~~~') # 根据给定的名字,得到要加载的数据集 imdb = get_imdb('voc_2007_trainval') print('Loaded dataset `{:s}` for training'.format(imdb.name)) # 准备训练数据 roidb = get_training_roidb(imdb) # 模型输出的路径 output_dir = get_output_dir(imdb, None) # summary的输出路径 log_dir = get_log_dir(imdb) print('Output will be saved to `{:s}`'.format(output_dir)) print('Logs will be saved to `{:s}`'.format(log_dir)) device_name = '/gpu:0' print(device_name) network = get_network('VGGnet_train') train_net( network, imdb, roidb, output_dir=output_dir, log_dir=log_dir, pretrained_model= '/Users/xiaofeng/Code/Github/dataset/CHINESE_OCR/ctpn/pretrain/VGG_imagenet.npy', max_iters=180000, restore=bool(int(0)))
print('Using config:~~~~~~~~~~~~~~~~') # 根据给定的名字,得到要加载的数据集 imdb = get_imdb('voc_2007_trainval') print('Loaded dataset `{:s}` for training'.format(imdb.name)) # 准备训练数据 roidb = get_training_roidb(imdb) # 模型输出的路径 output_dir = get_output_dir(imdb, None) # summary的输出路径 log_dir = get_log_dir(imdb) print('Output will be saved to `{:s}`'.format(output_dir)) print('Logs will be saved to `{:s}`'.format(log_dir)) device_name = '/gpu:0' print(device_name) network = get_network('VGGnet_train') train_net( network, imdb, roidb, output_dir=output_dir, log_dir=log_dir, # pretrained_model= # '/Users/xiaofeng/Code/Github/dataset/CHINESE_OCR/ctpn/pretrain/VGG_imagenet.npy', # pretrained_model='/home/xiaofeng/data/ctpn/pretrainde_vgg', pretrained_model='/home/guyu/CHINESE-OCR/weight/VGG_imagenet.npy', max_iters=180000, restore=bool(int(1)))
cfg_from_list(args.set_cfgs) cfg.GPU_ID = args.gpu_id print('Using config:') pprint.pprint(cfg) if not args.randomize: # fix the random seeds (numpy and caffe) for reproducibility np.random.seed(cfg.RNG_SEED) caffe.set_random_seed(cfg.RNG_SEED) # set up caffe if args.cpu_mode: caffe.set_mode_cpu() else: caffe.set_mode_gpu() caffe.set_device(args.gpu_id) imdb, roidb = combined_roidb(args.imdb_name) print '{:d} roidb entries'.format(len(roidb)) output_dir = get_output_dir(imdb) print 'Output will be saved to `{:s}`'.format(output_dir) train_net(args.solver, roidb, output_dir, pretrained_model=args.pretrained_model, max_iters=args.max_iters)
if __name__ == '__main__': # 将text.yml的配置与默认config中的默认配置进行合并 cfg_from_file('text.yml') print('Using config:~~~~~~~~~~~~~~~~') # 根据给定的名字,得到要加载的数据集 imdb = get_imdb('voc_2007_trainval') print('Loaded dataset `{:s}` for training'.format(imdb.name)) # 准备训练数据 roidb = get_training_roidb(imdb) # 模型输出的路径 output_dir = get_output_dir(imdb, None) # summary的输出路径 log_dir = get_log_dir(imdb) print('Output will be saved to `{:s}`'.format(output_dir)) print('Logs will be saved to `{:s}`'.format(log_dir)) device_name = '/gpu:0' print(device_name) network = get_network('VGGnet_train') train_net(network, imdb, roidb, output_dir=output_dir, log_dir=log_dir, pretrained_model=None, max_iters=180000, restore=bool(int(1)))
from lib.datasets.factory import get_imdb from lib.networks.factory import get_network from lib.fast_rcnn.config import cfg if __name__ == '__main__': cfg_from_file('ctpn/text.yml') print('Using config:') pprint.pprint(cfg) imdb = get_imdb('voc_2007_trainval') print 'Loaded dataset `{:s}` for training'.format(imdb.name) roidb = get_training_roidb(imdb) output_dir = get_output_dir(imdb, None) log_dir = get_log_dir(imdb) print 'Output will be saved to `{:s}`'.format(output_dir) print 'Logs will be saved to `{:s}`'.format(log_dir) device_name = '/gpu:0' print device_name network = get_network('VGGnet_train') train_net(network, imdb, roidb, output_dir=output_dir, log_dir=log_dir, pretrained_model='data/pretrain/VGG_imagenet.npy', max_iters=180000, restore=bool(int(0)))
if len(sys.argv) == 1: parser.print_help() sys.exit(1) args = parser.parse_args() return args if __name__ == '__main__': args = parse_args() if args.cfg_file is not None: cfg_from_file(args.cfg_file) pprint.pprint(cfg) np.random.seed(cfg.RNG_SEED) imdb = get_imdb(args.imdb_name) print 'Loaded dataset `{:s}` for training'.format(imdb.name) roidb = get_training_roidb(imdb) print('total samples: {:d}'.format(len(roidb))) output_dir = get_output_dir(imdb, None) log_dir = get_log_dir(imdb) print 'Output will be saved to `{:s}`'.format(output_dir) print 'Logs will be saved to `{:s}`'.format(log_dir) print 'use device /gpu:0' # always use gpu 0 network = get_network(args.network_name) print 'Use network `{:s}` in training'.format(args.network_name) train_net(network, imdb, roidb, output_dir=output_dir, log_dir=log_dir, pretrained_model=args.pretrained_model, restore=args.restore)
from lib.fast_rcnn.config import cfg if __name__ == '__main__': cfg_from_file('ctpn/text.yml') print('Using config:') pprint.pprint(cfg) imdb = get_imdb('voc_2007_trainval') print('Loaded dataset `{:s}` for training'.format(imdb.name)) roidb = get_training_roidb(imdb) output_dir = get_output_dir(imdb, None) log_dir = get_log_dir(imdb) print('Output will be saved to `{:s}`'.format(output_dir)) print('Logs will be saved to `{:s}`'.format(log_dir)) device_name = '/gpu:1' print(device_name) network = get_network('VGGnet_train') train_net( network, imdb, roidb, output_dir=output_dir, log_dir=log_dir, pretrained_model= '/home/alex/source/text-detection-ctpn/data/pretrain/VGG_imagenet.npy', # data/pretrain/VGG_imagenet.npy max_iters=int(cfg.TRAIN.max_steps), restore=bool(int(cfg.TRAIN.restore)))
print('Using config:') imdb = get_imdb('voc_2007_train') print('Loaded dataset `{:s}` for training'.format(imdb.name)) roidb = get_training_roidb(imdb) output_dir = get_output_dir(imdb, 'textline_v4') log_dir = get_log_dir(imdb) print('Output will be saved to `{:s}`'.format(output_dir)) print('Logs will be saved to `{:s}`'.format(log_dir)) device_name = '/gpu:0' print(device_name) network = get_network('VGGnet_train') pprint.pprint(cfg) # print(bool(int(cfg.TRAIN.restore))) # print(cfg.TRAIN.RPN_BBOX_INSIDE_WEIGHTS) # print(cfg.TRAIN.restore) # assert 0 train_net( network, imdb, roidb, output_dir=output_dir, log_dir=log_dir, pretrained_model='data/pretrain/VGG_imagenet.npy', max_iters=int(cfg.TRAIN.max_steps), pretrained_dir= '/home/CORP/yaqi.wang/pycharm/detection/text-detection-ctpn/model/textline_v4', restore=bool(int(cfg.TRAIN.restore)))
this_dir = os.path.dirname(__file__) from lib.fast_rcnn.train import get_training_roidb, train_net from lib.fast_rcnn.config import cfg_from_file, get_output_dir, get_log_dir from lib.datasets.factory import get_imdb from lib.networks.factory import get_network from lib.fast_rcnn.config import cfg if __name__ == '__main__': cfg_from_file('ctpn/text.yml') # print('Using config:') # pprint.pprint(cfg) imdb = get_imdb('voc_2007_trainval', cfg.DATA_DIR + '/template_generative') print('Loaded dataset `{:s}` for training'.format(imdb.name)) roidb = get_training_roidb(imdb) output_dir = get_output_dir(imdb, None) log_dir = get_log_dir(imdb) print('Output will be saved to `{:s}`'.format(output_dir)) print('Logs will be saved to `{:s}`'.format(log_dir)) network = get_network('VGGnet_train') train_net(network, imdb, roidb, output_dir=output_dir, log_dir=log_dir, pretrained_model='data/pretrain/VGG_imagenet.npy', max_iters=int(cfg.TRAIN.max_steps), restore=cfg.TRAIN.restore)
if args.cfg_file is not None: cfg_from_file(args.cfg_file) if args.set_cfgs is not None: cfg_from_list(args.set_cfgs) print('Using config:') pprint.pprint(cfg) if not args.randomize: # fix the random seeds (numpy and caffe) for reproducibility np.random.seed(cfg.RNG_SEED) imdb = get_imdb(args.imdb_name) print 'Loaded dataset `{:s}` for training'.format(imdb.name) roidb = get_training_roidb(imdb) output_dir = get_output_dir(imdb, None) print 'Output will be saved to `{:s}`'.format(output_dir) device_name = '/gpu:{:d}'.format(args.gpu_id) print device_name network = get_network(args.network_name) print 'Use network `{:s}` in training'.format(args.network_name) train_net(network, imdb, roidb, output_dir, pretrained_model=args.pretrained_model, max_iters=args.max_iters)
from lib.datasets.factory import get_imdb from lib.networks.factory import get_network from lib.fast_rcnn.config import cfg if __name__ == '__main__': cfg_from_file('ctpn/text.yml') print('Using config:') pprint.pprint(cfg) imdb = get_imdb('voc_2007_trainval') print('Loaded dataset `{:s}` for training'.format(imdb.name)) roidb = get_training_roidb(imdb) output_dir = get_output_dir(imdb, None) log_dir = get_log_dir(imdb) print('Output will be saved to `{:s}`'.format(output_dir)) print('Logs will be saved to `{:s}`'.format(log_dir)) device_name = '/gpu:0' print(device_name) network = get_network('VGGnet_train') train_net(network, imdb, roidb, output_dir=output_dir, log_dir=log_dir, pretrained_model='data/pretrain/VGG_imagenet.npy', max_iters=180000, restore=bool(int(0)))
if args.set_cfgs is not None: cfg_from_list(args.set_cfgs) print('Using config:') pprint.pprint(cfg) if not args.randomize: # fix the random seeds (numpy and caffe) for reproducibility np.random.seed(cfg.RNG_SEED) imdb = get_imdb(args.imdb_name) print 'Loaded dataset `{:s}` for training'.format(imdb.name) roidb = get_training_roidb(imdb) output_dir = get_output_dir(imdb, None) log_dir = get_log_dir(imdb) print 'Output will be saved to `{:s}`'.format(output_dir) print 'Logs will be saved to `{:s}`'.format(log_dir) device_name = '/gpu:{:d}'.format(args.gpu_id) print device_name network = get_network(args.network_name) print 'Use network `{:s}` in training'.format(args.network_name) train_net(network, imdb, roidb, output_dir=output_dir, log_dir=log_dir, pretrained_model=args.pretrained_model, max_iters=args.max_iters, restore=bool(int(args.restore)))