args = parse_args() arg_net = args.network_name train_datset_name = args.train_dataset_name # 测试数据集名称 val_dataset_name = args.val_dataset_name # 验证数据集名称 set_cfgs = [ 'ANCHOR_SCALES', '[8,16,32]', 'ANCHOR_RATIOS', '[0.5,1,2]', 'TRAIN.STEPSIZE', '[50000]', ] project_path = os.path.abspath('.') pre_train_weight = project_path + "/data/pre_train_weight/" + arg_net + ".ckpt" cfg_from_file(project_path + "/experiments/cfgs/" + arg_net + ".yml") #载入参数配置 cfg_from_list(set_cfgs) #修改参数配置 print('Using config:') pprint.pprint(cfg) # roidb:所有训练图片的gt_boxes # imdb:训练数据集的相关信息:包括类别列表,所有的图片名称的索引,数据集名称等等 imdb, roidb = combined_roidb("gridsum_car_train") print(roidb[0]['boxes']) print(roidb[0]) print('{:d} roidb entries'.format(len(roidb))) # output directory where the models are saved output_dir = get_output_dir(imdb, "") print('Output will be saved to `{:s}`'.format(output_dir)) # tensorboard directory where the summaries are saved during training tb_dir = get_output_tb_dir(imdb, "")
roidb.extend(r) tmp = get_imdb(imdb_names.split('+')[1]) imdb = lib.datasets.imdb.imdb(imdb_names, tmp.classes) else: imdb = get_imdb(imdb_names) return imdb, roidb if __name__ == '__main__': args = parse_args() print('Called with args:') print(args) 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) np.random.seed(cfg.RNG_SEED) # train set imdb, roidb = combined_roidb(args.imdb_name) print('{:d} roidb entries'.format(len(roidb))) # output directory where the models are saved output_dir = get_output_dir(imdb, args.tag) print('Output will be saved to `{:s}`'.format(output_dir))
if __name__ == '__main__': args = parse_args() test_dataset_name = args.test_dataset_name #测试数据集名称 set_cfgs = [ 'ANCHOR_SCALES', '[8,16,32]', 'ANCHOR_RATIOS', '[0.5,1,2]', 'TRAIN.STEPSIZE', '[50000]' ] project_path = os.path.abspath('.') #测试迭代训练好的参数路径 test_iter_weight_path = os.path.join( project_path, "output", args.network_name, args.train_dataset_name, args.network_name + "_faster_rcnn_iter_" + args.iter_number + ".ckpt") cfg_from_file(project_path + "/experiments/cfgs/" + args.network_name + ".yml") # 载入参数配置 cfg_from_list(set_cfgs) #修改参数配置 print('Using config:') pprint.pprint(cfg) # if has model, get the name from it # if does not, then just use the initialization weights filename = 'default/' + args.network_name imdb = get_imdb(test_dataset_name) #配置Session参数 tfconfig = tf.ConfigProto(allow_soft_placement=True) tfconfig.gpu_options.allow_growth = True # init session