KeyError: ((1, 1, 1280), '|u1') while using PIL's Image.fromarray - PIL
问题 I have this code: from PIL import Image import numpy as np img = Image.open('img.jpg') Image.fromarray(np.array([[np.mean(i, axis=1).astype(int).tolist()]*len(i) for i in np.array(img).tolist()]).astype('uint8')).show() And I am trying to modify the pixels of the image in PIL, however when I run it it gives an error as follows: KeyError: ((1, 1, 1280), '|u1') Not just that, it also outputs a second error as follows: TypeError: Cannot handle this data type Is there a way to overcome this? P.S.