PASCAL-VOC2012数据集及其增强版本的处理问题
数据集及其增强版本的处理问题
本篇主要总结语义分割处理PASCAL-VOC2012数据集以及遇到的问题(
本篇主要总结语义分割处理
0))
数据集以及遇到的问题(axis 2 is out of bounds for array of dimension
处理数据集主要参考该博客
https://blog.csdn.net/pangyunsheng/article/details/87360238
在将原始pascal voc 2012数据集中label的三通道RGB图像,转化为8-bit的灰度png图像时使用官方代码时
`
def convert_from_color_segmentation(arr_3d):
arr_2d = np.zeros((arr_3d.shape[0], arr_3d.shape[1]), dtype=np.uint8)
palette = pascal_palette()
for c, i in palette.items():
m = np.all(arr_3d == np.array(c).reshape(1, 1, 3), axis=2)
arr_2d[m] = i
return arr_2d`
出现‘axis 2 is out of bounds for array of dimension 0’报错
仔细研究后发现应该是numpy版本不对,尝试python3.7+numpy1.14/1.15以及python3.7+numpy1.15版本后无果,感兴趣的
朋友可以继续降低版本尝试
直接将for循环的代码改为为
# print(arr_3d.shape)
a = np.array(c).reshape(1, 1, 3)
a = np.repeat(a, arr_3d.shape[0], axis=0)
a = np.repeat(a, arr_3d.shape[1], axis=1)
# print(arr_3d[:,:,:3].shape)
m = np.all(arr_3d[:,:,:3]==a, axis=2)
arr_2d[m] = i
运行成功 灰度图生成正确
希望对以后使用该数据集的朋友有所帮助
数据集下载是在一个网盘下载的懒得找连接了有需要的可以评论- –
煮猪猪
原创文章 2获赞 1访问量 35
关注
私信
展开阅读全文
作者:煮猪猪