コード例 #1
0
    test_prototxt = ""
    test_model = ""
    cfg_file = ""
    CLASSES = []

    # set compute_mode
    if args.cpu_mode:
        test_net.set_mode('cpu')
    else:
        test_net.set_mode('gpu', args.gpu_id)
    # set solver prototxt
    if args.prototxt is not None:
        test_prototxt = args.prototxt
    #set model
    if args.test_model is not None:
        test_model = args.test_model
    #set cfg file
    if args.cfg_file is not None:
        cfg_file = args.cfg_file

    else:
        raise Exception('Please give the proto txt!')

    if args.classes_name is not None:
        CLASSES = aux_tools.get_classes(args.classes_name)
    else:
        raise  Exception('Please give the classes name txt!')

    test_net.test(CLASSES, cfg_file, test_prototxt, test_model,
                  args.comp_mode, args.max_per_image, args.vis, args.imdb_name, args.set_cfgs)
コード例 #2
0
    else:
        raise Exception('Please give the network file!')

    if args.net_weights is not None:
        net_weights = args.net_weights
    else:
        raise Exception('Please give the weight file!')

    # set cfg_file
    if args.cfg_file is not None:
        cfg_file = args.cfg_file
    else:
        raise Exception('Please give the configure file!')

    if args.classes_name is not None:
        CLASSES.extend(aux_tools.get_classes(args.classes_name))
    else:
        raise Exception('Please give the classes name txt!')

    aux_tools.change_test_prototxt(net_pt, len(CLASSES))
    aux_tools.change_test_prototxt(net_pt_svd, len(CLASSES))
    output_pt, output_weight = aux_tools.gen_merged_model(net_pt, net_weights)
    aux_tools.compress_net(output_pt, net_pt_svd, output_weight)
    #remove template files
    os.remove(output_pt)
    os.remove(output_weight)
    #copy cfg file
    # output directory
    out_dir = os.path.dirname(net_pt_svd)
    #configure file basename
    cfg_name = os.path.basename(cfg_file)
コード例 #3
0
cfg_file = osp.join(this_dir, '..', 'model', 'voc2007_comp', 'test.yml')
net_pt = osp.join(this_dir, '..', 'model', 'voc2007_comp', 'test.pt')
net_weight = osp.join(this_dir, '..', 'model', 'voc2007_comp', 'test.model')
classes_path = osp.join(this_dir, '..', 'model', 'voc2007_comp',
                        'classes_name.txt')

import socket

HOST = 'localhost'
#HOST = '192.168.3.148'
PORT = 8001

if "__main__" == __name__:

    CLASSES = ['__background__']
    CLASSES.extend(aux_tools.get_classes(classes_path))
    sku_id = (str(ind).zfill(7) for ind in range(len(CLASSES)))
    sku_code_dist = dict(zip(CLASSES, sku_id))
    try:
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        print("create socket succ!")
        #setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        sock.bind((HOST, PORT))
        print("bind socket succ!")

        sock.listen(5)
        print("listen succ!")
        # set mode
        easy_detect.set_mode('gpu', 0)
        easy_detect.change_test_prototxt(net_pt, len(CLASSES))
        #load model, just load once, or else it will be very slow