当前位置:   article > 正文

运行YOLOV5时numpy版本报错调试_yolov5 numpy版本

yolov5 numpy版本

今天在运行yolov5训练时报错:

  1. Traceback (most recent call last):
  2. File "/home/wh/projects/DenseNet_Demo/train_resnet.py", line 17, in <module>
  3. from torchtoolbox.transform import Cutout
  4. File "/home/wh/anaconda3/envs/pytorch39/lib/python3.9/site-packages/torchtoolbox/transform/__init__.py", line 5, in <module>
  5. from .autoaugment import *
  6. File "/home/wh/anaconda3/envs/pytorch39/lib/python3.9/site-packages/torchtoolbox/transform/autoaugment.py", line 194, in <module>
  7. Compose([Posterize(0.4, 8), Rotate(0.6, 9)]),
  8. File "/home/wh/anaconda3/envs/pytorch39/lib/python3.9/site-packages/torchtoolbox/transform/autoaugment.py", line 104, in __init__
  9. ranges = np.round(np.linspace(8, 4, 10), 0).astype(np.int)
  10. File "/home/wh/anaconda3/envs/pytorch39/lib/python3.9/site-packages/numpy/__init__.py", line 305, in __getattr__
  11. raise AttributeError(__former_attrs__[attr])
  12. AttributeError: module 'numpy' has no attribute 'int'.
  13. `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.
  14. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
  15. https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

报错原因:我安装的是numpy最新版本1.26.0,没有np.int

解决方法:安装较低版本的numpy

  1. pip uninstall numpy
  2. pip install numpy==1.20.0

这个方法可以解决此问题,但是其他模块比如pandas可能要求numpy的版本要大于1.22.4,然后再更改numpy的版本,改成1.22.4也有np.int

  1. pip uninstall numpy
  2. pip install numpy==1.22.4

不建议更改源码,因为可能会有更多的报错。

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/爱喝兽奶帝天荒/article/detail/904922
推荐阅读
相关标签
  

闽ICP备14008679号