赞
踩
今天在运行yolov5训练时报错:
- Traceback (most recent call last):
- File "/home/wh/projects/DenseNet_Demo/train_resnet.py", line 17, in <module>
- from torchtoolbox.transform import Cutout
- File "/home/wh/anaconda3/envs/pytorch39/lib/python3.9/site-packages/torchtoolbox/transform/__init__.py", line 5, in <module>
- from .autoaugment import *
- File "/home/wh/anaconda3/envs/pytorch39/lib/python3.9/site-packages/torchtoolbox/transform/autoaugment.py", line 194, in <module>
- Compose([Posterize(0.4, 8), Rotate(0.6, 9)]),
- File "/home/wh/anaconda3/envs/pytorch39/lib/python3.9/site-packages/torchtoolbox/transform/autoaugment.py", line 104, in __init__
- ranges = np.round(np.linspace(8, 4, 10), 0).astype(np.int)
- File "/home/wh/anaconda3/envs/pytorch39/lib/python3.9/site-packages/numpy/__init__.py", line 305, in __getattr__
- raise AttributeError(__former_attrs__[attr])
- 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
报错原因:我安装的是numpy最新版本1.26.0,没有np.int
解决方法:安装较低版本的numpy
- pip uninstall numpy
- pip install numpy==1.20.0
这个方法可以解决此问题,但是其他模块比如pandas可能要求numpy的版本要大于1.22.4,然后再更改numpy的版本,改成1.22.4也有np.int
- pip uninstall numpy
- pip install numpy==1.22.4
不建议更改源码,因为可能会有更多的报错。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。