加载训练好的模型做prediction 输入图片不同 为啥预测值相同呢

加载训练好的模型做prediction 然后更改输入input的图片 为啥预测值相同呢 是不会变的

def predict():    
    with tf.Graph().as_default() as g:
        classes = ['a', 'b', 'c', 'd', 'e', 'f', 'g']

        file = plt.imread('input.jpg')

        file = tf.cast(file, tf.float32)
        image = tf.image.per_image_standardization(file)         
        image = tf.reshape(image, [1,IMG_H,IMG_H,3])

        logits = vgg16.vgg16nn(image, N_CLASSES, IS_PRETRAIN)

        log_dir = './logs/train/'
        saver = tf.train.Saver()

        with tf.Session() as sess:
            ckpt = tf.train.get_checkpoint_state(log_dir)
            if ckpt and ckpt.model_checkpoint_path:
                global_step = ckpt.model_checkpoint_path.split('/')[-1].split('-')[-1]
                print global_step
                saver.restore(sess, ckpt.model_checkpoint_path)

                value=sess.run(tf.argmax(logits,1))
                print 'Prediction:',value               

            else:
                print('No checkpoint file found')
                return


if __name__=='__main__':
    predict()    
阅读 7.8k
2 个回答
新手上路,请多包涵

同问 我也遇到这样问题 无法解决

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进