【问题记录】AttributeError: module ‘numpy‘ has no attribute ‘bool‘

服务器上运行代码报错:

/opt/conda/envs/clrnet/lib/python3.8/site-packages/imgaug-0.4.0-py3.8.egg/imgaug/augmenters/meta.py:3368: FutureWarning: In the future np.bool will be defined as the corresponding NumPy scalar.
augmenter_active = np.zeros((nb_rows, len(self)), dtype=np.bool)
/opt/conda/envs/clrnet/lib/python3.8/site-packages/imgaug-0.4.0-py3.8.egg/imgaug/augmenters/meta.py:3368: FutureWarning: In the future np.bool will be defined as the corresponding NumPy scalar.
augmenter_active = np.zeros((nb_rows, len(self)), dtype=np.bool)
/opt/conda/envs/clrnet/lib/python3.8/site-packages/imgaug-0.4.0-py3.8.egg/imgaug/augmenters/meta.py:3368: FutureWarning: In the future np.bool will be defined as the corresponding NumPy scalar.
augmenter_active = np.zeros((nb_rows, len(self)), dtype=np.bool)
/opt/conda/envs/clrnet/lib/python3.8/site-packages/imgaug-0.4.0-py3.8.egg/imgaug/augmenters/meta.py:3368: FutureWarning: In the future np.bool will be defined as the corresponding NumPy scalar.
augmenter_active = np.zeros((nb_rows, len(self)), dtype=np.bool)
Traceback (most recent call last):
File “main.py”, line 75, in
main()
File “main.py”, line 39, in main
runner.train()
File “/root/CLRNet-main/CLRNet-main/clrnet/engine/runner.py”, line 92, in train
self.train_epoch(epoch, train_loader)
File “/root/CLRNet-main/CLRNet-main/clrnet/engine/runner.py”, line 54, in train_epoch
for i, data in enumerate(train_loader):
File “/opt/conda/envs/clrnet/lib/python3.8/site-packages/torch/utils/data/dataloader.py”, line 517, in next
data = self._next_data()
File “/opt/conda/envs/clrnet/lib/python3.8/site-packages/torch/utils/data/dataloader.py”, line 1199, in _next_data
return self._process_data(data)
File “/opt/conda/envs/clrnet/lib/python3.8/site-packages/torch/utils/data/dataloader.py”, line 1225, in process_data
data.reraise()
File "/opt/conda/envs/clrnet/lib/python3.8/site-packages/torch/utils.py", line 429, in reraise
raise self.exc_type(msg)
AttributeError: Caught AttributeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/opt/conda/envs/clrnet/lib/python3.8/site-packages/torch/utils/data/utils/worker.py", line 202, in worker_loop
data = fetcher.fetch(index)
File "/opt/conda/envs/clrnet/lib/python3.8/site-packages/torch/utils/data/utils/fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/opt/conda/envs/clrnet/lib/python3.8/site-packages/torch/utils/data/utils/fetch.py", line 44, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File “/root/CLRNet-main/CLRNet-main/clrnet/datasets/base_dataset.py”, line 61, in getitem
sample = self.processes(sample)
File “/root/CLRNet-main/CLRNet-main/clrnet/datasets/process/process.py”, line 37, in call
data = t(data)
File “/root/CLRNet-main/CLRNet-main/clrnet/datasets/process/generate_lane_line.py”, line 188, in call
img, line_strings, seg = self.transform(
File “/opt/conda/envs/clrnet/lib/python3.8/site-packages/imgaug-0.4.0-py3.8.egg/imgaug/augmenters/meta.py”, line 2008, in call
return self.augment(*args, **kwargs)
File “/opt/conda/envs/clrnet/lib/python3.8/site-packages/imgaug-0.4.0-py3.8.egg/imgaug/augmenters/meta.py”, line 1979, in augment
batch_aug = self.augment_batch
(batch, hooks=hooks)
File “/opt/conda/envs/clrnet/lib/python3.8/site-packages/imgaug-0.4.0-py3.8.egg/imgaug/augmenters/meta.py”, line 641, in augment_batch

batch_inaug = self.augment_batch(
File “/opt/conda/envs/clrnet/lib/python3.8/site-packages/imgaug-0.4.0-py3.8.egg/imgaug/augmenters/meta.py”, line 3124, in augment_batch
batch = self[index].augment_batch
(
File “/opt/conda/envs/clrnet/lib/python3.8/site-packages/imgaug-0.4.0-py3.8.egg/imgaug/augmenters/meta.py”, line 641, in augment_batch

batch_inaug = self.augment_batch(
File “/opt/conda/envs/clrnet/lib/python3.8/site-packages/imgaug-0.4.0-py3.8.egg/imgaug/augmenters/meta.py”, line 3633, in augment_batch
batch_sub = augmenters.augment_batch
(
File “/opt/conda/envs/clrnet/lib/python3.8/site-packages/imgaug-0.4.0-py3.8.egg/imgaug/augmenters/meta.py”, line 641, in augment_batch

batch_inaug = self.augment_batch(
File “/opt/conda/envs/clrnet/lib/python3.8/site-packages/imgaug-0.4.0-py3.8.egg/imgaug/augmenters/meta.py”, line 3395, in augment_batch
augmenter_active = self._get_augmenter_active(batch.nb_rows,
File “/opt/conda/envs/clrnet/lib/python3.8/site-packages/imgaug-0.4.0-py3.8.egg/imgaug/augmenters/meta.py”, line 3368, in _get_augmenter_active
augmenter_active = np.zeros((nb_rows, len(self)), dtype=np.bool)
File “/opt/conda/envs/clrnet/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
/opt/conda/envs/clrnet/lib/python3.8/site-packages/imgaug-0.4.0-py3.8.egg/imgaug/augmenters/meta.py:3368: FutureWarning: In the future np.bool will be defined as the corresponding NumPy scalar.
augmenter_active = np.zeros((nb_rows, len(self)), dtype=np.bool)
/opt/conda/envs/clrnet/lib/python3.8/site-packages/imgaug-0.4.0-py3.8.egg/imgaug/augmenters/meta.py:3368: FutureWarning: In the future np.bool will be defined as the corresponding NumPy scalar.
augmenter_active = np.zeros((nb_rows, len(self)), dtype=np.bool)

报错一长串,就是说:这个错误是由于 numpy 库的一个变化导致的,具体来说,它指出 np.bool 已经被弃用,而应该使用内置的 bool 类型。

要解决这个问题,你可以尝试在你的代码中找到并替换所有的 np.bool,将其替换为 bool。你可以使用文本编辑器的查找和替换功能来执行这个操作。

但是我现在文件很多,一个个去改变形式不现实,可以用更换numpy版本。

numpy在1.24版本中放弃了bool的使用,将代码中np.bool改为np.bool_

或者将numpy版本降为1.23.1也可。(1.23.2也可以)

pip install numpy==1.23.1
  • 24
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

超好的小白

没体验过打赏,能让我体验一次吗

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值