YOLOv5训练步骤

YOLOv5训练步骤

git clone https://github.com/ultralytics/yolov5.git
cd yolov5
pip install -U -r requirements.txt
命令行运行:
python detect.py
支持视频的检测,包括本地摄像头、本地视频文件、m3u8播放地址和rtsp实时流,地址都是跟在参数–source后面:
本地摄像头使用的命令:
python detect.py --source 0
基于rtsp的网络摄像头使用的命令:
python detect.py --source “rtsp://user:password@192.168.1.100:554/cam/realmonitor?channel=1&subtype=1”

有多块显卡,可以选择具体使用哪块显示进行检测,0表示第一块,1表示第二块,cpu表示不使用gpu:python detect.py --device 0
查看 .py 的参数:python detect.py -h
指定权重:python detect.py --source inference/images/horses.jpg --weights weights/yolov5x.pt

利用yolo5训练自己的模型:
训练命令:
python train.py --img-size 640 --batch 13 --epochs 10 --data ‘/yolov5/data/data.yaml’ --cfg ‘/yolov5/models/yolov5s.yaml’ --weights weights/yolov5s.pt

python train.py --img 640 --batch 8 --epoch 100 --data data/data.yaml --cfg models/yolov5s.yaml --weights weights/yolov5s.pt --device ‘0’ # 0号GPU
验证命令:
python test.py --data data/data.yaml --weights runs/exp/weights/best.pt --augment
Augment=数据增强

测试命令:
单张图片测试:
python detect.py --weights runs/exp4/weights/best.pt --source inference/images/1.jpg --output inference/oneoutput/ --device 0

整个文件夹图片测试:
python detect.py --weights runs/exp4/weights/best.pt --source inference/test/ --device 0 --save-txt
图片目录检测:
python detect.py --source inference/test --weights runs/exp/weights/best.pt --output inference/muoutput --conf-thres 0.5
视频测试:
python detect.py --source inference/2.mp4 --weights runs/exp/weights/best.pt --output inference/oneoutput/ --device 0

优化:rate:学习率,默认为0.001,可以根据自己的训练情况调整,一般为0.01,0.003,0.001等

  • 2
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

欢天喜地小姐姐

你的鼓励将是我创作的最大动力

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

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

打赏作者

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

抵扣说明:

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

余额充值