转换图片格式的时候,出现错误:TypeError: Cannot handle this data type: (1, 1), <i8
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
Traceback (most recent call last): File "/Users/mcj/opt/anaconda3/envs/py3/lib/python3.6/site-packages/PIL/Image.py", line 2714, in fromarray mode, rawmode = _fromarray_typemap[typekey] KeyError: ((1, 1), '<i8') During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/mcj/.nutstore/.nutstore/荔枝面条/07 学习资料/07 代码/PycharmProject/算法集合/将图片转为矩阵/imgtomatrix.py", line 27, in <module> loadImage() File "/Users/mcj/.nutstore/.nutstore/荔枝面条/07 学习资料/07 代码/PycharmProject/算法集合/将图片转为矩阵/imgtomatrix.py", line 22, in loadImage new_im = Image.fromarray(data) File "/Users/mcj/opt/anaconda3/envs/py3/lib/python3.6/site-packages/PIL/Image.py", line 2716, in fromarray raise TypeError("Cannot handle this data type: %s, %s" % typekey) TypeError: Cannot handle this data type: (1, 1), <i8 进程已结束,退出代码 1 |
解决如下:
将:new_im = Image.fromarray(data)
改为:new_im = Image.fromarray(np.uint8(data))


![[mcj]Ubuntu16.04安装NVIDIA驱动+CUDA10.1+cudnn7.5.0附详细步骤-马春杰杰](https://ypyssl.machunjie.com/machunjie/20210408222433.png_machunjie.png)


最新评论
牛牛牛
同样
站长您好,亚马逊云咨询推广资源,望建立联系,可邮件,谢谢。
换友情链接吗?
看你的站做的挺不错的
恭喜!!太强了,硕博连读啊
雁过留毛,人过留名。
看不懂但大受震撼