首页 > 解决方案 > Can't convert Pillow Image to numpy array or to RGB mode

问题描述

I'm trying to load a Dataset of PNGs. The PNGs are stored in "L" mode (8bit per pixel monochrome).

  1. When trying to convert them with image.convert('RGB'), I get the following error:
Traceback (most recent call last):
  File "C:\Users\Saman\AppData\Local\Programs\Python\Python38\lib\site-packages\PIL\ImageFile.py", line 180, in load
    seek = self.load_seek
AttributeError: 'PngImageFile' object has no attribute 'load_seek'
  1. If I leave that step out and convert them to a numpy array directly with np.array(image), I get a numpy array with dtype=object and length 1, with the only Pillow Image object as its content.

标签: pythonnumpypytorchpython-imaging-library

解决方案


推荐阅读