【Yolov5】ValueError: all the input array dimensions for the concatenation axis must match exactly ..

本文解决在使用np.concatenate处理dataset.labels时出现的ValueError错误。该问题源于一张图片标签为空导致的维度不匹配。解决方法为移除含有空标签的图片。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Scanning labels data_train/2/labels.cache (2960 found, 0 missing, 1 empty, 0 duplicate, for 2961 images): 2961it [00:00, 12423.43it/s]
Traceback (most recent call last):
  File "train.py", line 461, in <module>
    train(hyp, opt, device, tb_writer)
  File "train.py", line 173, in train
    mlc = np.concatenate(dataset.labels, 0)[:, 0].max() 
  File "<__array_function__ internals>", line 5, in concatenate
ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 5 and the array at index 1 has size 6

使用 np.concatenate 拼接dataset.labels 的时候,要求每一张图的标签不能为空,否则会报出上述dimension问题

2960 found, 0 missing, 1 empty, 0 duplicate, for 2961 image

1 empty 即表示其中有一个张图片中标签为空,将空标签的图片剔除即可

 

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

二十四桥下一句

您的鼓励是我最大的创作动力

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

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

打赏作者

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

抵扣说明:

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

余额充值