TypeError: Cannot handle this data type: (1, 1, 512), <i2

目录

    • 报错信息
    • 解决

报错信息

TypeError: Cannot handle this data type: (1, 1, 512),

解决

  • out_image为灰度图片
  • 需要转换通道
    if out_image.shape[0]==3:
    	out_image=(np.transpose(out_image(1,2,0))+1)/2.0*255.0
    elif out_image.shape[0]==1:
    	out_image=(out_image[0]+1)/2.0*255.0 
    # 操作后会变黑色,再加一行代码
    out_image=np.uint8(out_image*255)
    img_orig=Image.fromarray(out_image)
    img_orig.save(file_name)
    

参考链接
https://blog.csdn.net/u014546828/article/details/109297257

你可能感兴趣的:(报错,python,开发语言)