0

我们使用 Roboflow 进行对象检测,使用 Yolov4 Pytorch 模型为我们的自定义数据集。在训练过程中,我们收到以下错误。

Traceback (most recent call last):
  File "./pytorch-YOLOv4/train.py", line 447, in <module>
    device=device, )
  File "./pytorch-YOLOv4/train.py", line 310, in train
    for i, batch in enumerate(train_loader):
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 345, in __next__
    data = self._next_data()
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 856, in _next_data
    return self._process_data(data)
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 881, in _process_data
    data.reraise()
  File "/usr/local/lib/python3.7/dist-packages/torch/_utils.py", line 394, in reraise
    raise self.exc_type(msg)
ValueError: Caught ValueError in DataLoader worker process 7.
Original Traceback (most recent call last):
  File "/content/pytorch-YOLOv4/dataset.py", line 382, in __getitem__
    out_bboxes1[:min(out_bboxes.shape[0], self.cfg.boxes)] = out_bboxes[:min(out_bboxes.shape[0], self.cfg.boxes)]
AttributeError: 'list' object has no attribute 'shape'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop
    data = fetcher.fetch(index)
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/content/pytorch-YOLOv4/dataset.py", line 385, in __getitem__
    out_bboxes1[:min(out_bboxes.shape[0], self.cfg.boxes)] = out_bboxes[:min(out_bboxes.shape[0], self.cfg.boxes)]
ValueError: could not broadcast input array from shape (0) into shape (0,5)
4

1 回答 1

0

我不知道你的参数信息,但日志说你的代码有问题:

out_bboxes1[:min(out_bboxes.shape[0], self.cfg.boxes)] \
    = out_bboxes[:min(out_bboxes.shape[0], self.cfg.boxes)]

第一个错误说您的参数out_bboxes没有属性“形状”,因为它是一个list对象。因此,您可以根据需要考虑更改其数据类型。

于 2021-10-29T11:43:52.390 回答