利用Pillow进行图像resize操作,结果报错:
File "C:\Users\yafux\Anaconda3\envs\cu80_py36_tf140\lib\site-packages\PIL\Image.py", line 1869, in resize
message + " Use " + ", ".join(filters[:-1]) + " or " + filters[-1]
ValueError: Unknown resampling filter (107). Use Image.NEAREST (0), Image.LANCZOS (1), Image.BILINEAR (2), Image.BICUBIC (3), Image.BOX (4) or Image.HAMMING (5)
resize函数调用的写法不正确,错误的写法如下所示:
img = np.array(Image.fromarray(cropped).resize(img_size, img_size))
上面的写法少了一对括号,正确的写法应该是:
img = np.array(Image.fromarray(cropped).resize((img_size, img_size)))
至此,问题得到解决。