【问题标题】:what is the correct way to reshape image segmentation model output from 2D (num of classes, num of pixels) to 3D channel last images将图像分割模型输出从 2D(类数,像素数)重塑为 3D 通道最后图像的正确方法是什么
【发布时间】:2019-05-06 13:52:07
【问题描述】:

我正在使用 keras 和 python 进行卫星图像分割。据我了解,要获得图像分割的(像素级)预测,模型将维度(-1,num_classes,height,width)的层重塑为(-1,num_classes,height*width)。然后应用激活函数,如 softmax 或 sigmoid。我的问题是如何在此步骤后以通道优先或通道最后的格式恢复图像? 示例代码

o = (Reshape((  num_classes , outputHeight*outputWidth)))(o)
o = (Permute((2, 1)))(o)
o = (Activation('softmax'))(o)

我已经尝试在最后添加以下层到模型中

o = (Reshape((outputHeight, outputWidth, num_classes)))(o)

这是正确的吗?这是否会以与原始相同的顺序重新定向图像像素? 另一种选择可能是在单个图像上使用以下代码。

array.reshape(height, width, num_classes)

我应该使用哪种方法获得像素级分割结果?

【问题讨论】:

    标签: python-3.x keras deep-learning image-segmentation


    【解决方案1】:

    不,如果您对图像分割感兴趣,您应该展平然后重塑您的张量。相反,请使用 完全卷积 模型,例如 U-Net。你可以在 github 上找到很多它的示例实现,例如here

    【讨论】:

    • 感谢@mrks。你的回答很有帮助,它彻底改变了我的输出
    猜你喜欢
    • 2015-10-18
    • 2017-10-15
    • 2020-08-17
    • 2020-05-04
    • 2016-09-05
    • 1970-01-01
    • 1970-01-01
    • 2017-06-24
    • 1970-01-01
    相关资源
    最近更新 更多