def main(): """Sets up all the configurations for apollocaffe, and ReInspect and runs the trainer.""" parser = apollocaffe.base_parser() parser.add_argument('--config', required=True) args = parser.parse_args() config = json.load(open(args.config, 'r')) if args.weights is not None: config["solver"]["weights"] = args.weights apollocaffe.set_random_seed(config["solver"]["random_seed"]) apollocaffe.set_device(args.gpu) apollocaffe.set_cpp_loglevel(args.loglevel) net = apollocaffe.ApolloNet() image_mean = load_image_mean_from_binproto(config['data']["idl_mean"]) fake_input_en = {"image": np.zeros((1, 3, 227, 227))} forward(net, fake_input_en, deploy=True) if config["solver"]["weights"]: net.load(config["solver"]["weights"]) else: raise Exception('weights file is not provided!') run_socket(net, 13502, image_mean)
def main(): parser = apollocaffe.base_parser() parser.add_argument("--config", required=True) args = parser.parse_args() config = json.load(open(args.config, 'r')) apollocaffe.set_random_seed(config["solver"]["random_seed"]) apollocaffe.set_device(args.gpu) apollocaffe.set_cpp_loglevel(args.loglevel) train(config)
def main(): parser = apollocaffe.base_parser() parser.add_argument("--config", required=True) args = parser.parse_args() config = json.load(open(args.config, 'r')) apollocaffe.set_random_seed(config["solver"]["random_seed"]) apollocaffe.set_device(args.gpu) apollocaffe.set_cpp_loglevel(args.loglevel) evaluate(config)
def main(): parser = apollocaffe.base_parser() parser.add_argument("--config", required=True) args = parser.parse_args() config = json.load(open(args.config, 'r')) apollocaffe.set_random_seed(config["solver"]["random_seed"]) apollocaffe.set_device(args.gpu) apollocaffe.set_cpp_loglevel(args.loglevel) list_add=data_root+'list_all_test.txt' list_crop_add=data_root+'list_det_crop_align_filled.txt' feat_add=data_root+'feat1.txt' train_gt=np.loadtxt(list_add, dtype={'names': ('name', ), 'formats': ('S200', )}) train_crop_gt=np.loadtxt(list_crop_add, dtype={'names': ('name', 'label'), 'formats': ('S200', 'i4')}) train_feat=np.loadtxt(feat_add) train_feat_list=[] train_label_list=[] assert(len(train_crop_gt)==train_feat.shape[0]) im_list=train_crop_gt['name']; for k in xrange(len(im_list)): im_list[k]=im_list[k].split('/')[-1][0:-7] im_list_uniq=list(set(im_list)) for s in im_list_uniq: idx=s==train_crop_gt['name'] feat=train_feat[idx,:] train_feat_list.append(feat) train_label_list.append(s) feat_add2=data_root+'feat2.txt' train_feat2=np.loadtxt(feat_add2)#.reshape((-1,1)) train_feat_list2=[] assert(len(train_crop_gt)==train_feat2.shape[0]) for s in im_list_uniq: idx=s==im_list feat2=train_feat2[idx,:] train_feat_list2.append(feat2) holistic_feat_add=data_root+'feat_centrist_test_d1024.txt' holistic_feat=np.loadtxt(holistic_feat_add) scene_feat_list=[] for k,s in enumerate(im_list_uniq): idx=s.split('/')[-1]==train_gt['name'] assert(idx.sum()==1) scene_feat_list.append(holistic_feat[idx,:]) test_data={'feats': train_feat_list, 'feats2': train_feat_list2, 'labels': train_label_list, 'scene_feats': scene_feat_list, 'current_idx': 0} evaluate(config, test_data)
def main(): """Sets up all the configurations for apollocaffe, and ReInspect and runs the test.""" parser = apollocaffe.base_parser() parser.add_argument('--config', required=True) args = parser.parse_args() config = json.load(open(args.config, 'r')) print ("Test config file is " + config["data"]["test_idl"] ) apollocaffe.set_random_seed(config["solver"]["random_seed"]) apollocaffe.set_device(0) # gpu test(config)
def main(): """Sets up all the configurations for apollocaffe, and ReInspect and runs the test.""" parser = apollocaffe.base_parser() parser.add_argument('--config', required=True) args = parser.parse_args() config = json.load(open(args.config, 'r')) print("Test config file is " + config["data"]["test_idl"]) apollocaffe.set_random_seed(config["solver"]["random_seed"]) apollocaffe.set_device(0) # gpu test(config)
def main(): parser = apollocaffe.base_parser() parser.add_argument('--config', required=True) args = parser.parse_args() config = json.load(open(args.config, 'r')) if args.weights is not None: config["solver"]["weights"] = args.weights config["solver"]["start_iter"] = args.start_iter apollocaffe.set_random_seed(config["solver"]["random_seed"]) apollocaffe.set_device(args.gpu) apollocaffe.set_cpp_loglevel(args.loglevel) train(config)
def main(): parser = apollocaffe.base_parser() parser.add_argument("--config", required=True) args = parser.parse_args() config = json.load(open(args.config, "r")) if args.weights is not None: config["solver"]["weights"] = args.weights config["solver"]["start_iter"] = args.start_iter apollocaffe.set_random_seed(config["solver"]["random_seed"]) apollocaffe.set_device(args.gpu) apollocaffe.set_cpp_loglevel(args.loglevel) train(config)
def main(): """Sets up all the configurations for apollocaffe, and ReInspect and runs the trainer.""" parser = apollocaffe.base_parser() parser.add_argument('--config', required=True) args = parser.parse_args() config = json.load(open(args.config, 'r')) if args.weights is not None: config["solver"]["weights"] = args.weights apollocaffe.set_random_seed(config["solver"]["random_seed"]) apollocaffe.set_device(args.gpu) apollocaffe.set_cpp_loglevel(args.loglevel) deploy(config)
def main(): """Sets up all the configurations for apollocaffe, and ReInspect and runs the trainer.""" parser = apollocaffe.base_parser() parser.add_argument('--config', required=True) args = parser.parse_args() config = json.load(open(args.config, 'r')) if args.weights is not None: config["solver"]["weights"] = args.weights config["solver"]["start_iter"] = args.start_iter apollocaffe.set_random_seed(config["solver"]["random_seed"]) apollocaffe.set_device(args.gpu) apollocaffe.set_cpp_loglevel(args.loglevel) train(config)
def main(): """Sets up all the configurations for apollocaffe, and ReInspect and runs the trainer.""" parser = apollocaffe.base_parser() parser.add_argument('--config', required=True) args = parser.parse_args() config = json.load(open(args.config, 'r')) if args.weights is not None: config["solver"]["weights"] = args.weights config["solver"]["start_iter"] = args.start_iter apollocaffe.set_random_seed(config["solver"]["random_seed"]) apollocaffe.set_device(args.gpu) apollocaffe.set_cpp_loglevel(args.loglevel) print json.dumps(config['solver'], indent=4, sort_keys=True) print json.dumps(config['MMD'], indent=4, sort_keys=True) train(config)
def main(): """Sets up all the configurations for apollocaffe, and ReInspect and runs the trainer.""" parser = apollocaffe.base_parser() parser.add_argument('--datasize', required=True) parser.add_argument('--batchsize', required=True) parser.add_argument('--numIter', required=True) args = parser.parse_args() # config = json.load(open(args.config, 'r')) # if args.weights is not None: # config["solver"]["weights"] = args.weights # config["solver"]["start_iter"] = args.start_iter # apollocaffe.set_random_seed(config["solver"]["random_seed"]) apollocaffe.set_device(args.gpu) datasize = int(args.datasize) batchsize = int(args.batchsize) numIter = int(args.numIter) # apollocaffe.set_cpp_loglevel(args.loglevel) train(datasize, batchsize, numIter)
import os import json import apollocaffe from apollocaffe.layers import (Concat, Dropout, LstmUnit, InnerProduct, NumpyData, Softmax, SoftmaxWithLoss, Wordvec) batch_size = 32 vocab_size = 256 zero_symbol = vocab_size - 1 dimension = 250 base_lr = 0.15 clip_gradients = 10 i_temperature = 1.5 parser = apollocaffe.base_parser() parser.add_argument('--data_source', type=str) args = parser.parse_args() apollocaffe.set_device(args.gpu) apollocaffe.set_random_seed(0) def get_data(): if args.data_source: data_source = args.data_source else: data_source = '%s/reddit_ml.txt' % os.path.dirname( os.path.realpath(__file__)) if not os.path.exists(data_source): raise IOError( 'You must download the data with ./examples/apollocaffe/char_model/get_char.sh'
import os import json import apollocaffe from apollocaffe.layers import (Concat, Dropout, LstmUnit, InnerProduct, NumpyData, Softmax, SoftmaxWithLoss, Wordvec) batch_size = 32 vocab_size = 256 zero_symbol = vocab_size - 1 dimension = 250 base_lr = 0.15 clip_gradients = 10 i_temperature = 1.5 parser = apollocaffe.base_parser() parser.add_argument('--data_source', type=str) args = parser.parse_args() apollocaffe.set_device(args.gpu) apollocaffe.set_random_seed(0) def get_data(): if args.data_source: data_source = args.data_source else: data_source = '%s/reddit_ml.txt' % os.path.dirname(os.path.realpath(__file__)) if not os.path.exists(data_source): raise IOError('You must download the data with ./examples/apollocaffe/char_model/get_char.sh') epoch = 0 while True: