ERROR | Corrupt JPEG data: 111 extraneous bytes before marker 0xd9...
问题描述
Corrupt JPEG data: 1 extraneous bytes before marker 0xdb
libpng warning: iCCP: known incorrect sRGB profile
Premature end of JPEG file
Premature end of JPEG file
Premature end of JPEG file
Premature end of JPEG file
使用opencv(python)读取图片时,报如上错误,据说是因为图片破损。try_except未能捕获该警告。该部分代码如下:
img = cv2.imread(img_path)
if img is None:
img = np.zeros(shape=(224, 224, 3), dtype=np.uint8)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
img = Image.fromarray(img)
解决方案
使用PIL的读取函数。修改如下:
img = None
try:
img = Image.open(img_path).convert("RGB") #1
except:
pass
if img is None:
img = np.zeros(shape=(224, 224, 3), dtype=np.uint8)
img = Image.fromarray(img)
其中#1处添加.convert("RGB"),因为数据集含有RGBA(png)或者灰度图片,所有要进行类型转换。
如遇到如下警告,可使用warnings(warnings.filterwarnings(“ignore”))忽略。
PIL Palette images with Transparency expressed in bytes should be converted
————————————————
版权声明:本文为CSDN博主「lsh呵呵」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/nima1994/article/details/102560730
ERROR | Corrupt JPEG data: 111 extraneous bytes before marker 0xd9...相关推荐
- imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Corrupt JPEG data: 1 extraneous bytes be
imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Corrupt JPEG data: 1 extraneous bytes be ...
- Corrupt JPEG data: 2 extraneous bytes before marker 0x
参考:http://www.voidcn.com/article/p-dusgpwtd-bpv.html cv2.imread(absolute_path) 有时会报错: Corrupt JPEG d ...
- 【Qt】QPixmap加载图片报错:Corrupt JPEG data: premature end of data segment Didn‘t expect more than one scan
1.问题描述 在使用QPixmap加载图片时失败,错误信息如下 Corrupt JPEG data: premature end of data segment Didn't expect more ...
- Corrupt JPEG data: premature end of data segment
在跑 LSTR 的效果时 , 用 tusimple数据集(1280720)正常,换成自集的数据集(12801080),出现 Corrupt JPEG data: premature end of da ...
- UserWarning: Possibly corrupt EXIF data.
文章目录 前言 一.Exif是什么? 二.出现问题警告 三.问题分析 四.解决方法 前言 既然看到了这篇博客,那说明你用的数据集出毛病了,让我猜一猜,用的肯定是SUN397场景数据集吧?什么?不是?那 ...
- 成功解决Python中导出图片出现错误SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position
成功解决Python中导出图片出现错误SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position ...
- Python读取文件时,出现SyntaxError: (unicode error) ‘unicodeescape‘ codec can‘t decode bytes in position 2-3
简短代码如下: import pandas as pd url = 'C:\Users\lic\Desktop\data\mp\1.csv' df = pd.read_csv(url) print(d ...
- FlowableException: Error initialising dmn data model报错问题
flowable war包启动失败,报错Caused by: org.flowable.common.engine.api.FlowableException: Error initialising ...
- Php Fatal error: Allowed memory size of 33554432 bytes exhausted 的解决办法
Php Fatal error: Allowed memory size of 33554432 bytes exhausted 的解决办法 在 php.ini 配置文档里面,默认的memory_li ...
- SyntaxError: (unicode error) ‘unicodeescape‘ codec can‘t decode bytes in positio n 131-135: truncate
python报错 SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in positio n 131-135: ...
最新文章
- 一张膜能把电信运营商挡在手机支付门外吗?
- [置顶] Jquery为单选框checkbox绑定单击事件
- elementui 弹窗 显示详细信息_ElementUI中el-table双击单元格事件并获取指定列的值和弹窗显示详细信息...
- 【文末有奖】华为云“网红”语言Python课程来啦!
- java重div获取下拉框值_获取下拉框的value和值
- Spring Cloud Hystrix 进行服务熔断设置时,报错找不到对应的服务熔断方法
- Akka边学边写(3)-- ByteString介绍
- Dart入门—控制流程与其他
- Ajax异步请求PHP服务器,无阻塞响应的解决方案
- 基于Python的飞机大战游戏系统设计与实现
- 十进制和二进制相互转换
- oracle odi 资料档案库访问期间出现未分类的异常错误,ODI11g问题汇总
- Linux系统中VCS、Dve Verdi的使用
- Docker架构简介 命令详解
- 使用tensorboard出现:“couldn‘t build proto file into descriptor pool!”的解决方法
- jquery 垂直无限轮播
- calendar控件使用 extjs_ExtJs定制日历控件——自动加载更新(日历控件显示)
- 用python做flash动画_将Flash应用于Python项目
- 【项目分享】无线充电项目!!!
- bat脚本-指定程序列表选择运行