上述改完还是出现了报错Traceback (most recent call last): File "C:\Users\Administrator\Desktop\Yolodone\train.py", line 543, in <module> train(hyp, opt, device, tb_writer) File "C:\Users\Administrator\Desktop\Yolodone\train.py", line 189, in train dataloader, dataset = create_dataloader(train_path, imgsz, batch_size, gs, opt, File "C:\Users\Administrator\Desktop\Yolodone\utils\datasets.py", line 63, in create_dataloader dataset = LoadImagesAndLabels(path, imgsz, batch_size, File "C:\Users\Administrator\Desktop\Yolodone\utils\datasets.py", line 411, in __init__ bi = np.floor(np.arange(n) / batch_size).astype(np.int) # batch index File "C:\ProgramData\Anaconda3\envs\pytorch1\lib\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
时间: 2023-12-02 18:04:01 浏览: 70
这个错误是因为在最新版本的numpy中,`np.int`被弃用了,并且在你的代码中仍然在使用它。为了解决这个问题,你需要将代码中所有使用`np.int`的地方替换为`int`。
你可以尝试在`datasets.py`文件的第411行,将`np.int`替换为`int`。例如:
```python
bi = np.floor(np.arange(n) / batch_size).astype(int) # batch index
```
同样,在其他文件中也需要进行相同的更改。
如果你的代码中有其他地方也使用了`np.int`,你需要在所有这些地方进行相应的更改。
完成更改后,重新运行代码,应该就不会再出现该错误了。
相关问题
python报错traceback_运行脚本报错:Traceback (most recent call last):
这个错误信息是Python提供的一种追踪错误的方式,它会显示出导致程序崩溃的代码位置和调用顺序。在这个错误信息中,最后一行会显示出引发错误的代码位置,前面的行会显示出调用该代码的函数调用栈。
要解决这个问题,你可以仔细阅读错误信息,找到最后一行显示的代码位置,然后检查该位置可能存在的问题。常见的错误包括语法错误、变量未定义、模块导入错误、函数调用错误等等。
如果你能提供更多的错误信息和相关的代码,我可以帮你更具体地分析问题并提供解决方案。
Traceback ( most recent call last ) :File " C:/python/kfc.py " , line 8
Traceback (most recent call last): File "C:/python/kfc.py", line 8
这是Python中的错误追踪信息,通常在程序出现错误时会显示。它告诉我们在哪个文件的哪一行出现了错误。
具体来说,"Traceback (most recent call last)" 表示错误追踪的开始,它告诉我们下面的信息是最近一次调用的错误。
"File "C:/python/kfc.py", line 8" 表示错误发生在文件 "C:/python/kfc.py" 的第8行。
如果你想解决这个错误,可以打开 "C:/python/kfc.py" 文件,并检查第8行的代码,看看是否有语法错误或逻辑错误。