python - 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).
- 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'
- If I leave that step out and convert them to a numpy array directly with
np.array(image)
, I get a numpy array withdtype=object
and length 1, with the only Pillow Image object as its content.
解决方案
推荐阅读
- ios - 在 SwiftUI 中为每个实例使用双向绑定的实时数据更改
- algorithm - 寻找模式算法的名称
- django - Django __init__ 函数后如何传递字段属性
- aws-lambda - 基于分支在无服务器上选择不同的区域
- python - 如何检查列表中一行的任何部分是否包含另一个列表的整行?PYTHON
- mysql - 限制 MySQL 中的计数查询?
- .net-assembly - RoslynPad:无法加载文件或程序集异常
- swift - 通过带有加法和减法计数器的视图控制器传递整数值
- python - 如何防止出现此 KeyboardInterrupt 错误?
- c++ - getline 不打印输入?