UserWarning: Palette images with Transparency expressed in bytes should be converted to RGBA images

简介: 本文提供了解决PIL库中"Palette images with Transparency"警告的方法,通过将图片转换为'RGB'模式来消除透明通道的问题。

UserWarning: Palette images with Transparency expressed in bytes should be converted to RGBA images

原因:有这一警告的原因在于,验证码的图片模式为RGBA,是无法分配调色盘给透明通道的。

解决方法:

运行如下代码:


import os
from PIL import Image
folder_path = 'D:\\大二实验课集合\\猫狗兔识别\\data_oppo\\train\\r'
extensions = []
index=0

for fldr in os.listdir(folder_path):
    sub_folder_path = os.path.join(folder_path, fldr)
    for filee in os.listdir(sub_folder_path):
        file_path = os.path.join(sub_folder_path, filee)
        print('** Path: {}  **'.format(file_path), end="\r", flush=True)
        print(file_path)
        im = Image.open(file_path)
        rgb_im = im.convert('RGB')

运行显示如下:
在这里插入图片描述
该程序会先打印遇到每一个图片名字。
然后在尝试去打开。如果报错了说明报错前面那个图片有问题,手动将其删掉即可。

如果遇到不断出现报错的情况,可能是报错延迟了。你删除前面五十个看看

相关文章
|
2月前
|
Ubuntu Linux Python
UserWarning: Glyph 27668 (\N{CJK UNIFIED IDEOGRAPH-6C14}) missing from current font.
UserWarning: Glyph 27668 (\N{CJK UNIFIED IDEOGRAPH-6C14}) missing from current font.
122 2
|
4月前
|
算法 光互联 计算机视觉
Locally Adaptive Color Correction for Underwater Image Dehazing and Matching
该文提出了一种新颖的水下图像处理方法,结合颜色转移和局部调整来校正颜色,以应对水下光照和散射造成的图像退化。传统颜色转移方法基于全局参数,不适应水下场景中颜色变化的局部性质。文章中,作者通过融合策略,利用光衰减水平估计来实现局部颜色校正。首先,通过暗通道先验恢复彩色补偿图像,然后估计光衰减图。接着,创建一个合成图像,该图像的统计特性代表高衰减区域,用于颜色转移。最后,通过加权融合初始图像和颜色转移图像,生成最终的颜色校正图像。这种方法旨在提高水下图像的对比度和颜色准确性,特别关注高衰减区域。
49 1
|
9月前
|
JavaScript
image-conversion
image-conversion
193 0
|
9月前
|
Java
image-comparison
image-comparison
78 0
|
11月前
|
计算机视觉
The specified pixels is not supported
The specified pixels is not supported
87 1
|
存储 API
sws_scale():bad dst image pointers
sws_scale():bad dst image pointers
254 0
sws_scale():bad dst image pointers
|
人工智能 编解码 自然语言处理
论文解读:Inpaint Anything: Segment Anything Meets Image Inpainting
论文解读:Inpaint Anything: Segment Anything Meets Image Inpainting
363 0
UserWarning: Glyph 28857 (\N{CJK UNIFIED IDEOGRAPH-70B9}) missing from current font. FigureCanvasA
UserWarning: Glyph 28857 (\N{CJK UNIFIED IDEOGRAPH-70B9}) missing from current font. FigureCanvasA
UserWarning: Glyph 28857 (\N{CJK UNIFIED IDEOGRAPH-70B9}) missing from current font. FigureCanvasA
成功解决ValueError: numpy.ufunc size changed, may indicate binary incompatibility. Expected 216 from C h
成功解决ValueError: numpy.ufunc size changed, may indicate binary incompatibility. Expected 216 from C h
成功解决ValueError: numpy.ufunc size changed, may indicate binary incompatibility. Expected 216 from C h
|
计算机视觉 Python
成功解决OpenCV Error: Assertion failed (ssize.width > 0 && ssize.height > 0) in cv::resize, file C:\proj
成功解决OpenCV Error: Assertion failed (ssize.width > 0 && ssize.height > 0) in cv::resize, file C:\proj