小编yuh*_*tao的帖子

类型错误:无法处理此数据类型:(1, 1, 3), <f4

temp_image 是 (600, 600, 3) 值从 0 到 1。

def pro_process(temp_img, input_size):
    img = np.asarray(temp_img).astype('float32')
    img = np.array(Image.fromarray(img).resize((input_size, input_size)).convert(3))
    return img
Run Code Online (Sandbox Code Playgroud)

它给出了以下错误:

Traceback (most recent call last):
  File "S:\Program Files\Python36\lib\site-packages\PIL\Image.py", line 2681, in fromarray
    mode, rawmode = _fromarray_typemap[typekey]
KeyError: ((1, 1, 3), '<f4')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "H:\OneDrive\synchronization code\Developing collection\Python\MNet_DeepCDR-master\mnet_deep_cdr_ide\run\Step_3_MNet_test.py", line 56, in <module>
    temp_img = pro_process(Disc_flat, CDRSeg_size)
  File "S:\Program Files\Python36\lib\site-packages\mnet_deep_cdr\mnet_utils.py", line 18, in pro_process
    img = np.array(Image.fromarray(img).resize((input_size, input_size)).convert(3)) …
Run Code Online (Sandbox Code Playgroud)

python-imaging-library

12
推荐指数
3
解决办法
3万
查看次数

标签 统计

python-imaging-library ×1