Yolov5 安裝和使用

@zgcwkj  2023年08月06日

分類:

代碼 其它 

Yolov5 安裝和使用(機器學習筆記

特別說明

本文不涉及算法等內容,僅是使用。

視頻

我也是從這裏看到素材准備和訓練的過程
B站:https://www.bilibili.com/video/BV1dF411i7d7

yolov5

倉庫
https://github.com/ultralytics/yolov5

安裝引用
pip install -r requirements.txt

數據標記工具 labelImg

https://github.com/heartexlabs/labelImg

啟動(切換為 yolo 模式)
.\labelImg 文件夾路徑 標簽文本
例如:
labelImg .\images\ .\tag.txt

數據訓練

分類
python classify.py

訓練
python train.py --data ./test/test.yaml --weights yolov5s.pt --img 640 --epochs 200 --batch-size 16

測試圖片
python detect.py --weights ./best.pt --source ./223.png

測試視頻
python detect.py --weights ./best.pt --source ./223.mp4 --view-img

模型轉換

python export.py --weights yolov5s.pt --img 640 --batch 1 --opset 9 --optimize --simplify

安裝驅動
# CPU
pip install -r requirements.txt coremltools onnx onnx-simplifier onnxruntime openvino-dev tensorflow-cpu
# GPU
pip install -r requirements.txt coremltools onnx onnx-simplifier onnxruntime-gpu openvino-dev tensorflow

指定格式 onnx
python export.py --weights yolov5s.pt --img 640 --batch 1 --opset 9 --optimize --simplify --include onnx
python export.py --weights yolov5m6.pt --img 1280 --batch 1 --opset 9 --optimize --simplify --include onnx


評論已關閉

Top