Exemplo n.º 1
0
    if args.cfg_file is not None:
        cfg_from_file(args.cfg_file)

    print('Using config:')
    pprint.pprint(cfg)

    # while not os.path.exists(args.model) and args.wait:
    #     print('Waiting for {} to exist...'.format(args.model))
    #     time.sleep(1000)

    weights_filename = os.path.splitext(os.path.basename(args.model))[0]

    imdb = get_imdb(args.imdb_name)
    imdb.competition_mode(args.comp_mode)

    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)

    cfg.GPU_ID = args.gpu_id

    # start a session
    saver = tf.train.Saver()
    sess = tf.Session(config=tf.ConfigProto(allow_soft_placement=True))
    saver.restore(sess, args.model)
    print('Loading model weights from {:s}').format(args.model)

    test_net(sess, network, imdb, weights_filename)
Exemplo n.º 2
0
    if args.cfg_file is not None:
        cfg_from_file(args.cfg_file)

    print('Using config:')
    pprint.pprint(cfg)

    while not os.path.exists(args.model) and args.wait:
        print('Waiting for {} to exist...'.format(args.model))
        time.sleep(10)

    weights_filename = os.path.splitext(os.path.basename(args.model))[0]

    imdb = get_imdb(args.imdb_name)
    imdb.competition_mode(args.comp_mode)

    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)

    cfg.GPU_ID = args.gpu_id

    # start a session
    saver = tf.train.Saver()
    sess = tf.Session(config=tf.ConfigProto(allow_soft_placement=True))
    saver.restore(sess, args.model)
    print('Loading model weights from {:s}').format(args.model)

    test_net(sess, network, imdb, weights_filename, vis=args.vis)
Exemplo n.º 3
0
                        dest='imdb_name',
                        choices=['caltech_test', 'caltech_train'],
                        default='caltech_test',
                        type=str)
    parser.add_argument('--network',
                        dest='network_name',
                        choices=['VGGnet_test', 'MSnet_test'],
                        default='VGGnet_test')
    parser.add_argument('--vis', action='store_true')
    if len(sys.argv) == 1:
        parser.print_help()
    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)
    weights_filename = os.path.splitext(os.path.basename(args.model))[0]
    imdb = get_imdb(args.imdb_name)
    print 'Use device /gpu:0'
    network = get_network(args.network_name)
    print 'Use network `{:s}` in training'.format(args.network_name)
    saver = tf.train.Saver()
    sess = tf.Session(config=tf.ConfigProto(allow_soft_placement=True))
    saver.restore(sess, args.model)
    print('Loading model weights from {:s}').format(args.model)
    test_net(sess, network, imdb, weights_filename, vis=args.vis, thresh=0.05)
Exemplo n.º 4
0
    while not os.path.exists(args.model) and args.wait:
        print(('Waiting for {} to exist...'.format(args.model)))
        time.sleep(1000)

    weights_filename = os.path.splitext(os.path.basename(args.model))[0]

    imdb = get_imdb(args.imdb_name)
    imdb.competition_mode(args.comp_mode)

    device_name = '/gpu:{:d}'.format(args.gpu_id)
    print(device_name)
    with tf.device(device_name):
        network = get_network(args.network_name)
    print(('Use network `{:s}` in training'.format(args.network_name)))

    cfg.GPU_ID = args.gpu_id
    # import os
    # os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"   # see issue #152
    # os.environ["CUDA_VISIBLE_DEVICES"]=str(args.gpu_id)
    # start a session
    saver = tf.train.Saver()
    c = tf.ConfigProto(allow_soft_placement=True)
    c.gpu_options.visible_device_list = str(args.gpu_id)
    sess = tf.Session(config=c)
    saver.restore(sess, tf.train.latest_checkpoint(args.model))
    print((('Loading model weights from {:s}').format(args.model)))

    test_net(sess, network, imdb, weights_filename, thresh=0.7)
    # load_test_net(sess, network, imdb, weights_filename)
Exemplo n.º 5
0
    if args.cfg_file is not None:
        cfg_from_file(args.cfg_file)

    print('Using config:')
    pprint.pprint(cfg)

    while not os.path.exists(args.model + '.index') and args.wait:
        print('Waiting for {} to exist...'.format(args.model))
        time.sleep(1000)

    weights_filename = os.path.splitext(os.path.basename(args.model))[0]

    imdb = get_imdb(args.imdb_name)
    imdb.competition_mode(args.comp_mode)

    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)

    cfg.GPU_ID = args.gpu_id

    # start a session
    saver = tf.train.Saver()
    sess = tf.Session(config=tf.ConfigProto(allow_soft_placement=True))
    saver.restore(sess, args.model)
    print ('Loading model weights from {:s}').format(args.model)

    test_net(sess, network, imdb, weights_filename, output_dir=args.output_dir)
Exemplo n.º 6
0
    if args.cfg_file is not None:
        cfg_from_file(args.cfg_file)

    print('Using config:')
    pprint.pprint(cfg)

    while not os.path.exists(args.model) and args.wait:
        print('Waiting for {} to exist...'.format(args.model))
        time.sleep(1000)

    weights_filename = os.path.splitext(os.path.basename(args.model))[0]

    imdb = get_imdb(args.imdb_name)
    imdb.competition_mode(args.comp_mode)

    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)

    cfg.GPU_ID = args.gpu_id

    # start a session
    saver = tf.train.Saver()
    sess = tf.Session(config=tf.ConfigProto(allow_soft_placement=True))
    saver.restore(sess, args.model)
    print ('Loading model weights from {:s}').format(args.model)

    test_net(sess, network, imdb, weights_filename)