如何更改上午图像的通道尺寸?

时间:2018-09-08 18:21:03

标签: pytorch

假设我有shape = [x,y,z,21]的火炬张量,其中x = batch_size, y = image_width, z= image_height。上面的张量表示具有21个通道的一批图像。我应该如何将其转换为size = [ x,y,z,3 ]

1 个答案:

答案 0 :(得分:1)

[x,y,z,21]-> [x,y,z,1]-> [x,y,z,3]

对于细分结果预测,其大小为[x,y,z,21]

细分类别索引结果,大​​小为[x,y,z,1]

# for pytorch, the right format for image is [batch, channels, height, width]
# however your image format [batch, height, width, channels]
result=predicts.argmax(-1)

索引组合颜色图将为您提供帮助!查看voc color map的详细信息