首页 > 解决方案 > Tensorflow/Keras - 从通道重新组装 RAW

问题描述

我在 RAW 图像 (RGGB) 中使用 tensorflow 训练 CNN。我的客户要求神经网络在没有任何后处理的情况下重新组装输出图像,因此不能对输出做任何事情。这是输入:

input_img = Input(shape=(None, None, 1), name='input') # 1 channel RAW image
separate = tf.stack([input_img[:, 0::2, 0::2, 0], 
                     input_img[:, 0::2, 1::2,0],
                     input_img[:, 1::2, 0::2, 0], 
                     input_img[:, 1::2, 1::2, 0]], axis=3) # separate in four channels and stack them in a single tensor
model = Conv2D(filters=filters, kernel_size=(3,3), strides=(1,1), padding='same')(separate) # from here there are several CNN layers and other stuff.

我的神经网络的输出如下:

# 4 channels representing RGGB

model = Conv2D(filters=4, kernel_size=(3,3), strides=(1,1), padding='same', activation="sigmoid")

我尝试使用 reshape 如下:

output = tf.keras.layers.Reshape((height, width, 1))(model)

但它没有用。在这种情况下,我如何对 RAW 图像进行巧妙的重塑,使其恢复到与输入相同的形状,并且每种颜色的位置都在正确的位置?

问候!

标签: tensorflowkerasconv-neural-networkrawrawimage

解决方案


推荐阅读