File "/root/miniconda3/lib/python3.8/site-packages/torch/_utils.py", line 428, in reraise raise self.exc_type(msg) AssertionError: Caught AssertionError in DataLoader worker process 0. Original Traceback (most recent call last): File "/root/miniconda3/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 198, in _worker_loop data = fetcher.fetch(index) File "/root/miniconda3/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 "/root/miniconda3/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp> data = [self.dataset[idx] for idx in possibly_batched_index] File "/root/autodl-tmp/project/tools/../lib/datasets/kitti_rcnn_dataset.py", line 234, in __getitem__ return self.get_rpn_sample(index) File "/root/autodl-tmp/project/tools/../lib/datasets/kitti_rcnn_dataset.py", line 252, in get_rpn_sample pts_lidar = self.get_lidar(sample_id) File "/root/autodl-tmp/project/tools/../lib/datasets/kitti_dataset.py", line 43, in get_lidar assert os.path.exists(lidar_file) AssertionError eval: 39%|█████████████████████████████▍ | 44/112 [00:06<00:09, 6.96it/s, mode=TEST, recall=0/0, rpn_iou=0]
时间: 2023-09-20 08:07:18 浏览: 807
这是一个AssertionError异常,通常是由于断言(assert)语句失败导致的异常。在这段代码中,断言语句`assert os.path.exists(lidar_file)`检查lidar_file是否存在,如果不存在,则会抛出这个异常。你需要检查lidar_file的路径是否正确,以及文件是否存在。如果文件确实不存在,你需要找到原因并解决。如果文件存在,那么你需要检查代码中是否有其他问题。另外,根据错误信息,这个异常可能是在DataLoader的worker进程中发生的,你需要在主进程中捕获这个异常并处理。你可以在主进程中加入try-except语句来捕获这个异常,并在except语句中进行处理。
相关问题
Traceback (most recent call last): File "eval.py", line 302, in <module> save_depth() File "eval.py", line 111, in save_depth for batch_idx, sample in enumerate(TestImgLoader): File "/root/miniconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 517, in next data = self._next_data() File "/root/miniconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1199, in _next_data return self._process_data(data) File "/root/miniconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1225, in _process_data data.reraise() File "/root/miniconda3/lib/python3.8/site-packages/torch/_utils.py", line 429, in reraise raise self.exc_type(msg) AssertionError: Caught AssertionError in DataLoader worker process 0. Original Traceback (
这个错误也是出现在使用PyTorch的DataLoader时,在一个worker进程中抛出了AssertionError。它可能是由于数据集中有不符合预期的数据导致的。你可以检查一下数据集中的数据是否都符合预期,并且考虑使用try-except语句来捕获AssertionError,以便更好地处理异常情况。此外,你也可以考虑增加一些调试信息,例如打印出当前正在处理的数据的信息,以便更好地排查问题。
TypeError: Caught TypeError in DataLoader worker process 0. Original Traceback (most recent call last): File "/root/miniconda3/envs/py38/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop data = fetcher.fetch(index) File "/root/miniconda3/envs/py38/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/root/miniconda3/envs/py38/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in <listcomp> data = [self.dataset[idx] for idx in possibly_batched_index] File "/root/ConvNeXt/my_dataset.py", line 40, in __getitem__ img = self.transform(a) File "/root/miniconda3/envs/py38/lib/python3.8/site-packages/torchvision/transforms/transforms.py", line 95, in __call__ img = t(img) File "/root/miniconda3/envs/py38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, **kwargs) File "/root/miniconda3/envs/py38/lib/python3.8/site-packages/torchvision/transforms/transforms.py", line 952, in forward i, j, h, w = self.get_params(img, self.scale, self.ratio) File "/root/miniconda3/envs/py38/lib/python3.8/site-packages/torchvision/transforms/transforms.py", line 913, in get_params width, height = F.get_image_size(img) File "/root/miniconda3/envs/py38/lib/python3.8/site-packages/torchvision/transforms/functional.py", line 76, in get_image_size return F_pil.get_image_size(img) File "/root/miniconda3/envs/py38/lib/python3.8/site-packages/torchvision/transforms/functional_pil.py", line 27, in get_image_size raise TypeError(f"Unexpected type {type(img)}") TypeError: Unexpected type <class 'numpy.ndarray'>
这个错误是由于在 DataLoader 的 worker 进程中,数据集中的某个样本在进行 transform 时出现了错误。具体来说,是由于 get_image_size 函数期望的 PIL.Image 对象被传入了一个 numpy 数组。你可以检查一下数据集中的这个样本,看看是否正确加载,并且检查一下 transform 中是否使用了正确的数据类型。
阅读全文