繁体   English   中英

将2D(类数,像素数)输出的图像分割模型重塑为3D通道最后一张图像的正确方法是什么

[英]what is the correct way to reshape image segmentation model output from 2D (num of classes, num of pixels) to 3D channel last images

我正在使用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)

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

不,如果你有兴趣的图像分割, 应该压平,然后重塑你的张量。 而是使用完全卷积模型,例如U-Net 您可以在github上找到很多示例实现,例如, 这里

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM