【发布时间】:2018-06-06 11:13:54
【问题描述】:
到目前为止,我已经创建了 2 个模型,它采用 2 个不同的训练数据集并比较这 2 个数据集,并通过调用我在训练模型后获得的模型权重来给出结果输出。现在我想拼接/重叠 2 个图像(例如:model1 训练数据集的图像 1 和 model2 训练数据集的图像 1 的 frame1)。
我的意思是从两个图像中获取 RGB 通道,将其组合并保存为单个图像。我可以创建 6 个通道(RGB+RGB),但我不知道如何将它们组合为一个并保存。
这是调用 2 个模型权重并进行预测的代码。
model1 = create_model()
model1.load_weights('model1.h5')
print ('model1 loaded successfully')
model2 = create_model()
model2.load_weights('model2.h5')
print ('model2 loaded successfully')
import numpy as np
from keras.preprocessing import image
i = 1
while (i < 11):
test_image1 = image.load_img('dataset/test_set/'+str(i)+'.jpg',
target_size = (64, 64))
test_image2 = image.load_img('dataset2/test_set/'+str(i)+'.jpg',
target_size = (64, 64))
test_image1 = image.img_to_array(test_image1)
test_image2 = image.img_to_array(test_image2)
test_image1 = np.expand_dims(test_image1, axis = 0)
test_image2 = np.expand_dims(test_image2, axis = 0)
result = model1.predict(test_image1)
print ("result1=", result)
result2 = model2.predict(test_image2)
print ("result2=", result2)
【问题讨论】:
标签: python tensorflow keras