代码拉取完成,页面将自动刷新
同步操作将从 zengfanlin/tensorflow_alexnet_classify 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import matplotlib.pyplot as plt
import tensorflow as tf
from alexnet import AlexNet
class_name = ['cat', 'dog']
def test_image(path_image, num_class, weights_path='Default'):
img_string = tf.read_file(path_image)
img_decoded = tf.image.decode_png(img_string, channels=3)
img_resized = tf.image.resize_images(img_decoded, [227, 227])
img_resized = tf.reshape(img_resized, shape=[1, 227, 227, 3])
model = AlexNet(img_resized, 0.5, 2, skip_layer='', weights_path=weights_path)
score = tf.nn.softmax(model.fc8)
max = tf.arg_max(score, 1)
saver = tf.train.Saver()
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
saver.restore(sess, "./tmp/checkpoints/model_epoch100.ckpt")
# score = model.fc8
print(sess.run(model.fc8))
prob = sess.run(max)[0]
plt.imshow(img_decoded.eval())
plt.title("Class:" + class_name[prob])
plt.show()
test_image('./validate/10.jpeg', num_class=2)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。