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')

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

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

相关文章
|
7月前
GEE错误——Layer error: Image.connectedPixelCount: Segment size calculation on floating point bands is n
GEE错误——Layer error: Image.connectedPixelCount: Segment size calculation on floating point bands is n
84 0
|
5月前
|
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.
253 2
|
7月前
Should pass resolved color instead of resource id here: getResources().getColor(R.color.brown)
Should pass resolved color instead of resource id here: getResources().getColor(R.color.brown)
58 6
|
7月前
|
算法 光互联 计算机视觉
Locally Adaptive Color Correction for Underwater Image Dehazing and Matching
该文提出了一种新颖的水下图像处理方法,结合颜色转移和局部调整来校正颜色,以应对水下光照和散射造成的图像退化。传统颜色转移方法基于全局参数,不适应水下场景中颜色变化的局部性质。文章中,作者通过融合策略,利用光衰减水平估计来实现局部颜色校正。首先,通过暗通道先验恢复彩色补偿图像,然后估计光衰减图。接着,创建一个合成图像,该图像的统计特性代表高衰减区域,用于颜色转移。最后,通过加权融合初始图像和颜色转移图像,生成最终的颜色校正图像。这种方法旨在提高水下图像的对比度和颜色准确性,特别关注高衰减区域。
91 1
|
JavaScript
image-conversion
image-conversion
226 0
|
Java
image-comparison
image-comparison
108 0
|
人工智能 编解码 自然语言处理
论文解读:Inpaint Anything: Segment Anything Meets Image Inpainting
论文解读:Inpaint Anything: Segment Anything Meets Image Inpainting
448 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
|
JSON 数据格式
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
543 0
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em