深度学习与Web计算机视觉入门
1. 深度学习基础与Keras库
1.1 图像预测示例
在深度学习中,我们可以使用代码对图像进行预测。以下是一个示例代码,用于加载图像并进行预测:
x = graph.get_tensor_by_name('myInput:0')
model = graph.get_tensor_by_name('myOutput:0')
output = sess.run(model, {x: [test_digit_0, test_digit_1, test_digit_2, test_digit_3]})
print("predicted labels: {}".format(np.argmax(output, axis=1)))
这里的 test_digit_0 、 test_digit_1 、 test_digit_2 和 test_digit_3 是四张分别包含一个数字的图像。为了加载这些图像,我们使用 load_digit() 函数:
def load_digit(image_name):
"""Loads a digit and pre-process in order to have the proper format"""
gray = cv2.imread(image_name, cv2.IMRE
超级会员免费看
订阅专栏 解锁全文


被折叠的 条评论
为什么被折叠?



