【YOLO问题】AttributeError: module ‘numpy‘ has no attribute ‘int‘.`np.int` was a deprecated alias.......

 在pycharm运行yoloV5中的train.py时遇到

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. ~~~The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:

问题分析:

        显然这里报错提示你要将 'np:int' 改为 'int' ,但是应该在哪里该这里并没有提示,我们先找到

Traceback (most recent call last):

..............

        寻找其中有没有关于 'np:int' 的追踪,我找到了

  File "F:\depth_study\a_little_concerningcode\yolov5-6.0\yolov5-6.0\utils\datasets.py", line 445, in __init__
    bi = np.floor(np.arange(n) / batch_size).astype(np.int)  # batch index
                                                                              ^^^^^^

        然后点击地址(F:\depth_study\a_little_concerningcode\yolov5-6.0\yolov5-6.0\utils\datasets.py),可以发现问题所在

bi = np.floor(np.arange(n) / batch_size).astype(np.int) # batch index

         将其改为

bi = np.floor(np.arange(n) / batch_size).astype(int) # batch index

        问题就可以解决! 

  • 11
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
06/06/2023-16:31:47] [TRT] [I] [MemUsageChange] TensorRT-managed allocation in IExecutionContext creation: CPU +0, GPU +0, now: CPU 0, GPU 0 (MiB) /home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/tensorrt/__init__.py:166: FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar. bool: np.bool, Traceback (most recent call last): File "/home/sniper/anaconda3/envs/labelme/bin/yolo", line 8, in <module> sys.exit(entrypoint()) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/ultralytics/yolo/cfg/__init__.py", line 398, in entrypoint getattr(model, mode)(**overrides) # default args from model File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(*args, **kwargs) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/ultralytics/yolo/engine/model.py", line 302, in val validator(model=self.model) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(*args, **kwargs) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/ultralytics/yolo/engine/validator.py", line 114, in __call__ model = AutoBackend(model, device=self.device, dnn=self.args.dnn, data=self.args.data, fp16=self.args.half) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/ultralytics/nn/autobackend.py", line 174, in __init__ dtype = trt.nptype(model.get_binding_dtype(i)) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/tensorrt/__init__.py", line 166, in nptype bool: np.bool, File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/numpy/__init__.py", line 305, in __getattr__ raise AttributeError(__former_attrs__[attr]) AttributeError: module 'numpy' has no attribute 'bool'. `np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here. 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 如何修复
06-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值