Пример #1
0
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)
Пример #2
0
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)
Пример #3
0
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)
Пример #4
0
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)
Пример #5
0
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)
Пример #6
0
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)
Пример #7
0
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)
Пример #8
0
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)
Пример #9
0
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)
Пример #10
0
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)
Пример #11
0
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)
Пример #12
0
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)
Пример #13
0
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'
Пример #14
0
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: