相关疑难解决方法(0)

类型错误:无法处理 PIL Image 中的数据类型

我有一个大小为 (4,3,224,224) 的 Pytorch 张量。当我尝试将第一个张量转换为 Image 对象时,它说:

TypeError: Cannot handle this data type
Run Code Online (Sandbox Code Playgroud)

我运行了以下命令:

img = Image.fromarray(data[0][i].numpy().astype(np.uint8))
Run Code Online (Sandbox Code Playgroud)

其中 data 是 Pytorch 张量

我尝试了其他解决方案,但找不到任何解决方案。

请建议!!

python numpy image-processing python-imaging-library pytorch

2
推荐指数
1
解决办法
6121
查看次数