服务器上运行代码报错:
/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 futurenp.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 futurenp.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 futurenp.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 builtinbool
. To avoid this error in existing code, usebool
by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, usenp.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 futurenp.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 futurenp.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