ソースを参照

完善 yolo7 dim7 格式输出文档

zhzhenqin 9 ヶ月 前
コミット
623c321a5e
4 ファイル変更54 行追加3 行削除
  1. 2 1
      .gitignore
  2. 35 1
      docs/YOLO模型训练.md
  3. 17 1
      docs/YOLO模型验证.md
  4. BIN
      docs/images/onnx-netron-graph.png

+ 2 - 1
.gitignore

@@ -25,4 +25,5 @@ runs
 datasets
 build
 dist
-logs
+logs
+models

+ 35 - 1
docs/YOLO模型训练.md

@@ -26,7 +26,7 @@ yolo train data=/home/jxft/datasets/hyd-action.yaml model=/home/jxft/datasets/yo
 yolo train data=/home/yiidata/datasets/hyd-action.yaml model=/home/yiidata/datasets/yolov8/yolov8n.pt epochs=10 lr0=0.01 device='0'
 
 # yolov7
-python train.py --weights=/home/yiidata/datasets/yolov7/yolov7.pt --data=/home/yiidata/datasets/hyd-action.yaml --img-size='640' --epochs=100 --batch-size=1 --device=0
+python train.py --weights=/home/yiidata/datasets/yolov7/yolov7.pt --data=/home/yiidata/datasets/hyd-action.yaml --img-size='640' --epochs=10 --batch-size=1 --device='0'
 # 导出为 NMS 输出结果为 7 的 onnx 模型
 python export.py --weights runs/train/exp/weights/best.pt  --grid --end2end --simplify --max-wh 640 
 ```
@@ -119,6 +119,40 @@ Linux 系统,删除 LD_LIBRARY_PATH 环境变量即可解决。
 unset LD_LIBRARY_PATH
 ```
 
+**_pickle.UnpicklingError: STACK_GLOBAL requires str** 
+
+_pickle.UnpicklingError: STACK_GLOBAL requires str 错误的原因是在数据集的 labels 文件夹中存在 .cache 文件。这些 .cache文件通常是之前训练过程中生成的缓存文件,导致在当前训练过程中出现反序列化错误。具体来说,这个错误通常是由于 .cache文件中的数据格式与当前环境不兼容,或者在序列化和反序列化过程中出现了问题。
+
+解决这个问题的方法即 删除数据集 labels 文件夹中的所有 .cache 文件。以下是详细的解决步骤:
+
+1. 定位 .cache 文件:首先,找到数据集文件夹中的 labels 文件夹。
+2. 删除 .cache 文件:删除 labels 文件夹中的所有 .cache 文件。如果可能,也检查 images 文件夹中是否存在 .cache 文件,并一并删除。
+3. 重新运行训练脚本:删除缓存文件后,重新运行训练脚本。
+
+
+**yolo7: TypeError: No loop matching the specified signature and casting was found for ufunc greater.**
+
+numpy 版本不兼容。先查看当前的 numpy 版本:`pip list`
+卸载当前 numpy 包: `pip uninstall numpy`。重新安装特定版本的numpy包(重装的是1.23.5版本的,如果该版本安装完,仍然不能解决报错,可以试试其他版本):
+
+```shell
+# yolo7
+pip install numpy==1.23.5
+# yolo8
+pip install numpy==1.26.4
+```
+
+**ImportError: cannot import name 'builder' from 'google.protobuf.internal'**
+
+protobuf 版本不兼容。先查看当前的 protobuf 版本:`pip list`
+
+```shell
+# yolo7
+pip install protobuf==3.20.3
+# yolo8
+pip install protobuf==3.19.6
+```
+
 ## 参考
 
 - https://blog.csdn.net/qq_32892383/article/details/136505299

+ 17 - 1
docs/YOLO模型验证.md

@@ -26,6 +26,7 @@ yolo export model=water_strean_model.pt format=onnx \
 --iou-thres 0.65 --conf-thres 0.25 --topk 100 --opset 16 \
 --sim --input-shape 1 3 640 640
 
+# yolo7
 python export-det.py --weights water_strean_model.pt \
 --iou-thres 0.65 --conf-thres 0.25 \
 --topk 100 --opset 16 --sim --input-shape 1 3 640 640 --device "0"
@@ -35,7 +36,22 @@ python export-det.py --weights water_strean_model.pt \
 --topk 100 --opset 16 --sim --input-shape 1 3 640 640 --device cpu
 ```
 
+## ONNX 模型验证
+
+找到导出的 onnx 模型,采用 netron 查看模型结构。
+
+```shell
+netron runs/train/exp6/weights/best.onnx --host 0.0.0.0
+```
+
+运行成功后,打开浏览器,访问 http://ip:8080 即可查看模型结构。
+
+![onnx-netron-graph](images/onnx-netron-graph.png)
+
 **注意:**
 
 (最新的yolo8改用默认GPU版的onnxruntime,要安装一下下面的库,否则ONNX转换会有警告)
-pip install onnxruntime-gpu -i https://pypi.tuna.tsinghua.edu.cn/simple
+
+```shell
+pip install onnxruntime-gpu -i https://pypi.tuna.tsinghua.edu.cn/simple
+```

BIN
docs/images/onnx-netron-graph.png