yolov5训练失败总结

yolov5训练失败总结


版本原因:

在进行训练时,出现如下报错:

UserWarning: Detected call of lr_scheduler.step() before optimizer.step(). In PyTorch 1.1.0 and later, you should call them in the opposite order: optimizer.step() before lr_scheduler.step(). Failure to do this will result in PyTorch skipping the first value of the learning rate schedule.

解决方法:

  1. 将版本更换为1.0类 网页:将版本更换为1.0类

  2. 按报错说明修改代码 网页:按报错说明修改代码


数据集原因:

在使用将xml格式转换成txt格式时,忘记将所有对应的名字添加上去,导致txt格式错误,如下图:

classes = ["red","yellow","green"];//漏写
classes = ["red","yellow","green","turn_left","turn_right","stop"]//完整形式

路径问题:

在训练时涉及一些路径,因为路径不正确导致训练出错:

train.py:
在这里插入图片描述
data/red_light.yaml:
yolov5训练失败总结_第1张图片

预测时:

detect.py:
在这里插入图片描述
数据模型不能随便填,不然即使之前的训练没有问题,也没法预测出结果

你可能感兴趣的:(深度学习,python,pytorch)