image_class icon indicating copy to clipboard operation
image_class copied to clipboard

训练时报错:AttributeError: 'NoneType' object has no attribute 'shape'

Open Wangyy-moya opened this issue 5 years ago • 3 comments

训练时,报下面的错误,请问怎么解决?

Traceback (most recent call last): File "train.py", line 174, in main() File "train.py", line 170, in main train.start_train() File "train.py", line 148, in start_train X_train, X_test, y_train, y_test=self.load_data() File "train.py", line 55, in load_data _, w, h = img.shape[::-1] AttributeError: 'NoneType' object has no attribute 'shape'

Wangyy-moya avatar Aug 13 '20 04:08 Wangyy-moya

试了几个模型训练,都是报这个错,图像路径正确的,每次读取训练照片的进度条也不一样 image 最高一次到96%就断掉

Wangyy-moya avatar Aug 13 '20 04:08 Wangyy-moya

我解决了

我出错的原因是数据集中有的照片没有进行转码,只是更改了后缀,所以在模型加载的时候会报错,用PIL工具将所有的jpg图片转换成为jpg图片就可以了(png格式的照片也是这样操作)。

Wangyy-moya avatar Aug 13 '20 06:08 Wangyy-moya

嗯嗯,好的

------------------ 原始邮件 ------------------ 发件人: "tslgithub/image_class" <[email protected]>; 发送时间: 2020年8月13日(星期四) 下午2:14 收件人: "tslgithub/image_class"<[email protected]>; 抄送: "Subscribed"<[email protected]>; 主题: Re: [tslgithub/image_class] 训练时报错:AttributeError: 'NoneType' object has no attribute 'shape' (#23)

我解决了

我出错的原因是数据集中有的照片没有进行转码,只是更改了后缀,所以在模型加载的时候会报错,用PIL工具将所有的jpg图片转换成为jpg图片就可以了(png格式的照片也是这样操作)。

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

itismeJH avatar Aug 13 '20 06:08 itismeJH