if not os.path.isfile(tfmodel + '.meta'):
        print(tfmodel)
        raise IOError(
            ('{:s} not found.\nDid you download the proper networks from '
             'our server and place them properly?').format(tfmodel + '.meta'))

    # set config
    tfconfig = tf.ConfigProto(allow_soft_placement=True)
    tfconfig.gpu_options.allow_growth = True

    # init session
    sess = tf.Session(config=tfconfig)
    # load network
    if demonet == 'vgg16':
        net = vgg16(batch_size=1)
    # elif demonet == 'res101':
    # net = resnetv1(batch_size=1, num_layers=101)
    else:
        raise NotImplementedError

    n_classes = len(CLASSES)
    # create the structure of the net having a certain shape (which depends on the number of classes)
    net.create_architecture(sess,
                            "TEST",
                            2,
                            tag='default',
                            anchor_scales=[8, 16, 32])
    saver = tf.train.Saver()
    saver.restore(sess, tfmodel)
示例#2
0
    # 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
    sess = tf.Session(config=tfconfig)
    # load network
    if args.network_name == 'vgg16':
        net = vgg16()
    elif args.network_name == 'res50':
        net = resnetv1(num_layers=50)
    elif args.network_name == 'res101':
        net = resnetv1(num_layers=101)
    elif args.network_name == 'res152':
        net = resnetv1(num_layers=152)
    elif args.network_name == 'mobile':
        net = mobilenetv1()
    else:
        raise NotImplementedError
    # load model
    net.create_architecture("TEST",
                            imdb.num_classes,
                            tag='default',
                            anchor_scales=cfg.ANCHOR_SCALES,