如何利用Keras模型对图像进行预测?
我已经完成了训练过程,得到了.hdf5格式的模型 我使用的神经网络是暹罗卷积神经网络 验证时,预测图像是来自我的测试文件夹的随机图像。 我在测试时使用这个如何利用Keras模型对图像进行预测?,keras,siamese-network,Keras,Siamese Network,我已经完成了训练过程,得到了.hdf5格式的模型 我使用的神经网络是暹罗卷积神经网络 验证时,预测图像是来自我的测试文件夹的随机图像。 我在测试时使用这个 test_alphabets = glob('{}/TEST/*'.format(dataset_dirname)) testset={} for alph in test_alphabets: dirs = glob('{}/*'.format(alph)) alphabet = {} for dirname in
test_alphabets = glob('{}/TEST/*'.format(dataset_dirname))
testset={}
for alph in test_alphabets:
dirs = glob('{}/*'.format(alph))
alphabet = {}
for dirname in dirs:
alphabet[dirname] = glob('{}/*'.format(dirname))
testset[alph] = alphabet
然后,使用
display_validation_test(siamese_model1, testset)
结果是这样的
如何通过输入所需的图像,然后使用.h5模型显示相应的图像来执行测试过程
model.load_weights('your_weight_file.h5')加载权重
prediction=model.predict(图像)
在3号桥,你能解释一下吗?我不明白。。请帮助meLet's说,你有一个图像加载为numpy矩阵,形状为(128128,3),你需要告诉模型,预测时它是一个单一的图像。您必须将其重塑为(1128128,3),其中1显示批次维度(此处,批次大小为1)。这可以使用
image=np来完成。展开dims(0,image)