AttributeError: ‘NoneType‘ object has no attribute ‘shape‘

AttributeError: ‘NoneType‘ object has no attribute ‘shape‘,第1张

在运行训练文件时,出现了这样的问题:“AttributeError: ‘NoneType’ object has no attribute ‘shape’”。
原因: 1.图片不存在(路径不存在, 路径包含中文无法识别) 2.读取的图片内容和默认读取时参数匹配不匹配。(默认读取的是3通道的彩色图)例如读取到的图片是灰度图,就会返回None。3.当给出的路径不存在时, cv2.imread() 返回 None ,因此稍后将此 None 值视为 NumPy 数组时会发生错误。

有时可用 try except 语句跳过

 

eg:

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/942775.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-18
下一篇2022-05-18

发表评论

登录后才能评论

评论列表(0条)

    保存