解决 NoneType‘ object has no attribute ‘astype’ 问题

简介: 解决 NoneType‘ object has no attribute ‘astype’ 问题

问题描述

在代码运行过程中报错:AttributeError: ‘NoneType‘ object has no attribute ‘astype‘。

解决方案

原因是读取数据集的时候,我的路径里面存在中文,把路径里的中文改成英文就可以了。

这也是因为cv2.imread函数的问题,使用PIL读取图像,能够成功读取图片,而cv2.imread只能读取非中文路径的图像。

opencv中opencv不接受non-ascii的路径,解决方法就是先用先用np.fromfile()读取为np.uint8格式,再使用cv2.imdecode()解码,如下:

参考:AttributeError: 'NoneType' object has no attribute 'astyp-CSDN博客

目录
相关文章
|
6月前
|
存储 JSON 数据格式
数据集加载时报错'dict' object has no attribute 'requests‘
数据集加载时报错'dict' object has no attribute 'requests‘
113 5
|
4月前
AttributeError: 'NoneType' object has no attribute 'to_capabilities'
AttributeError: 'NoneType' object has no attribute 'to_capabilities'
377 0
|
4月前
AttributeError ‘NoneType‘ object has no attribute ‘to_capabilities‘
AttributeError ‘NoneType‘ object has no attribute ‘to_capabilities‘
93 0
|
5月前
|
数据采集
运行爬虫时报错AttributeError—— 'str' object has no attribute 'capabilities'
运行爬虫时报错AttributeError—— 'str' object has no attribute 'capabilities'
255 0
|
5月前
'WebDriver' object has no attribute 'find_element_by_tag_name'
'WebDriver' object has no attribute 'find_element_by_tag_name'
118 0
|
6月前
|
Java
java判断Object对象是否为空demo
java判断Object对象是否为空demo
|
20天前
|
JavaScript
js 字符串String转对象Object
该代码示例展示了如何将一个以逗号分隔的字符串(`'1.2,2,3,4,5'`)转换为对象数组。通过使用`split(',')`分割字符串并`map(parseFloat)`处理每个元素,将字符串转换成浮点数数组,最终得到一个对象数组,其类型为`object`。
|
2月前
|
存储 设计模式 Python
Python中的类(Class)和对象(Object)
Python中的类(Class)和对象(Object)
30 0
|
2月前
|
存储 JavaScript
JS中Map对象与object的区别
JS中Map对象与object的区别
|
6月前
判断Object对象是否为空
判断Object对象是否为空