【YOLO问题记录】AttributeError: module ‘numpy‘ has no attribute ‘int‘.解决方案

在训练YOLO对象检测模型时,用户遇到了一个错误,即numpy模块缺少int属性。这个错误是由于numpy从1.20版本开始弃用了np.int别名。为解决此问题,用户需要将代码中的np.int替换为如np.int64或np.int32等特定精度类型,或者直接使用内置的int。更换numpy版本也是可行的解决方案,可以通过PyCharm的软件包管理器或命令行进行操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题:在训练YOLO模型的时候出现了以下报错:

AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

报错内容翻译:

AttributeError:模块“numpy”没有属性“int”。
`np.int` 是内置 `int` 的已弃用别名。 为避免在现有代码中出现此错误,请单独使用“int”。 这样做不会修改任何行为并且是安全的。 替换 `np.int` 时,您可能希望使用例如 `np.int64` 或 `np.int32` 来指定精度。 如果您想查看当前的使用情况,请查看发行说明链接以获取更多信息。
别名最初在 NumPy 1.20 中被弃用; 有关更多详细信息和指南,请参阅原始发行说明,网址为:
     https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

说白了又是numpy的版本的问题,在pycharm软件包管理里换一个版本

(换版本就行,方法无所谓,使用命令行也行)

 

参考博客:AttributeError: module numpy has no attribute int .报错解决方案

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值