print(image.shape) AttributeError: 'NoneType' object has no attribute 'shape'
时间: 2023-08-16 16:08:58 浏览: 100
这个错误提示显示 'NoneType' object has no attribute 'shape',意味着你的图像对象是None,没有shape属性。这通常是由于读取图像时出现了错误导致的。 你提供的代码中,你读取了一张名为"2007_000027.jpg"的图像,但是没有提供完整的图像路径。请确保你提供了正确的图像路径。 您可以尝试使用绝对路径来读取图像,例如:
img = cv2.imread("D:/数据集/VOC2012/JPEGImages/2007_000027.jpg")
此外,还需要确保图像文件存在,文件名拼写正确,并且路径中的斜杠是正确的(在Windows系统中使用反斜杠)。 请检查这些问题,然后再次尝试运行代码。<em>1</em><em>2</em><em>3</em>
#### 引用[.reference_title]
- *1* [cv2问题:AttributeError: ‘NoneType‘ object has no attribute ‘shape‘及CV2显示、保存图片](https://blog.csdn.net/qq_38230414/article/details/127045473)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item]
- *2* [报错AttributeError: ‘NoneType‘ object has no attribute ‘shape](https://blog.csdn.net/weixin_62884045/article/details/129519893)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item]
- *3* [在Linux系统下img.shape报错AttributeError: 'NoneType' object has no attribute 'shape'](https://blog.csdn.net/qq_34317565/article/details/90672928)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item]
[ .reference_list ]
阅读全文