YOLOV5训练数据集过程中特殊问题记录

项目场景:

yolov5训练GX数据集


问题描述:

运行train.py

Traceback (most recent call last):
  File "/home/milk/yolov52/train.py", line 484, in 
    train(hyp, opt, device, tb_writer)
  File "/home/milk/yolov52/train.py", line 191, in train
    dataloader, dataset = create_dataloader(train_path, imgsz, batch_size, gs, opt, hyp=hyp, augment=True,
  File "/home/milk/y
Traceback (most recent call last):
  File "/home/milk/yolov52/train.py", line 484, in 
    train(hyp, opt, device, tb_writer)
  File "/home/milk/yolov52/train.py", line 191, in train
    dataloader, dataset = create_dataloader(train_path, imgsz, batch_size, gs, opt, hyp=hyp, augment=True,
  File "/home/milk/yolov52/utils/datasets.py", line 53, in create_dataloader
    dataset = LoadImagesAndLabels(path, imgsz, batch_size,
  File "/home/milk/yolov52/utils/datasets.py", line 381, in __init__
    assert (l >= 0).all(), 'negative labels: %s' % file
AssertionError: negative labels: /home/milk/yolov52/GX0/labels/train/1.txt


原因分析:

提示是出现了负标签,对比xml之后发现,只有这一个txt中出现如下情况

1.txt

2 1.6194444444444445 1.4135802469135803 -1.2416666666666667 -0.8320987654320987
0 2.3583333333333334 2.15679012345679 -2.7194444444444446 -2.3185185185185184
0 2.702777777777778 1.3222222222222222 -3.4083333333333337 -0.6493827160493827

2.txt

0 0.06041666666666667 0.32469135802469135 0.11527777777777778 0.15061728395061727
0 0.2777777777777778 0.0728395061728395 0.03888888888888889 0.08148148148148147

 在这里要注意txt中的类别和xml中是对应的


解决方案:

1. 查xml转txt原理,判断是否程序出问题

xml转txt时,在计算xmin、xmax、ymin、ymax部分会出现max值大于min,在进行旋转操作后max小于min-----位置互换,导致出现负值,修改生成标签部分代码,使得生成h部分为绝对值。数据增强尤其关注啊!!!

2. 暴力排除,直接删除

你可能感兴趣的:(深度学习,python,图像处理,ubuntu)