加载训练好的模型做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()
同问 我也遇到这样问题 无法解决