【问题标题】:how can i train a model with 2 images stitched/overlap together?我如何训练一个将 2 张图像拼接/重叠在一起的模型?
【发布时间】: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


    【解决方案1】:

    感谢您的回复,但我得到了我真正想要的。使用 opencv

    img= cv2.addweighted(image1,0.7,image2,0.3,0)

    将两个图像叠加在一起。

    【讨论】:

    • 上面添加了两个不同权重的图像,称为图像混合:(0.7*image1 + 0.3*image2)+0。
    • 是的,很快我就发现它将频道保持为 3 而不是 6。我想要这样的东西,这样做但也使频道从 3 变为 6
    猜你喜欢
    • 2020-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-15
    • 2012-06-25
    相关资源
    最近更新 更多