在自定义数据集上使用 roboflow 对象检测 Yolov4 pytorch 模型时出现值错误
Posted
技术标签:
【中文标题】在自定义数据集上使用 roboflow 对象检测 Yolov4 pytorch 模型时出现值错误【英文标题】:Value error while using roboflow object detection Yolov4 pytorch model on custom dataset 【发布时间】:2021-12-13 19:43:48 【问题描述】:我们使用 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)
【问题讨论】:
那么...到目前为止,您尝试过什么解决方法?似乎您应该将一些列表转换为 numpy 数组 【参考方案1】:我不知道你的参数信息,但是日志说你的代码有问题:
out_bboxes1[:min(out_bboxes.shape[0], self.cfg.boxes)] \
= out_bboxes[:min(out_bboxes.shape[0], self.cfg.boxes)]
第一个错误说你的参数out_bboxes
没有属性'shape',因为它是一个list
对象。所以你可以考虑根据需要改变它的数据类型。
【讨论】:
以上是关于在自定义数据集上使用 roboflow 对象检测 Yolov4 pytorch 模型时出现值错误的主要内容,如果未能解决你的问题,请参考以下文章
获取 InvalidArgumentError:NewRandomAccessFile 在自定义图像数据集上使用 tf.data 时无法创建/打开
如何在 tensorflow 对象检测 API 中使用“忽略”类?
在自定义数据集上训练 tensorflow attention-ocr 的管道是啥?