pytorch - 如何更改图像的通道尺寸?
问题描述
假设我有带有shape = [x,y,z,21]
where的火炬张量x = batch_size, y = image_width, z= image_height
。上面的张量表示具有 21 个通道的一批图像。我应该如何将其转换为size = [ x,y,z,3 ]
?
解决方案
[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 颜色图以获取详细信息
推荐阅读
- amazon-web-services - paho mqtt C) make -> 未定义的引用
- tensorflow - 在 TensorFlow 中使用批次实现 zigzag flatten NxN 张量
- bash - 如何使用 jq 添加连续数字以获取输出
- python - 绘制中断/断轴,x 轴上有间隙,表示比例跳跃
- python-3.x - TypeError: unhashable type: 'dict', data = {name: {user_details}}
- mysql - Mysql 中的 autocommit 和 JDBC 中的 AutoCommit 的关系
- python - 在 python 中使用 UDP 协议向系统发送命令
- python - /usr/local/bin/conver 在 imagemagic for movie.py 上找不到错误
- r - 对保持不同类型首次出现的原始相对位置的数据进行排序
- java - 如何找到二叉树的直径?