openvino+linux(Ubuntu)+python+YOLOv5+pytorch

openvino在linux上配合yolov5的使用  python版本 pytorch

目录

openvino在linux上配合yolov5的使用  python版本

1、流程:

2、预测代码更改:

3、主要参考文章

4.报错踩坑集合

4.1  mportError: libpython3.9.so.1.0: cannot open shared object file: No such file or directory

4.2  QObject::moveToThread: Current thread (0xb7f210) is not the object's thread (0x188cc30). Cannot move to target thread (0xb7f210)

4.2.1  ERROR: Could not install packages due to an OSError: [Errno 2] 没有那个文件或目录: '/home/amov/anaconda3/envs/yolov5/lib/python3.9/site-packages/PyQt5-5.15.7.dist-info/METADATA'

4.3    [ WARN:0@0.868] global /io/opencv/modules/videoio/src/cap_v4l.cpp (889) open VIDEOIO(V4L2:/dev/video0): can't open camera by index 未解决

4.4    Cannot find reference 'inference_engine' in 'imported module openvino

4.5    DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here. Deprecated in NumPy 1.20; for more details and guidance: NumPy 1.20.0 Release Notes — NumPy v1.24.dev0 Manual (Type.boolean, np.bool),

4.6 Failed to create plugin /home/amov/anaconda3/envs/yolov5/lib/python3.9/site-packages/openvino/libs/libopenvino_intel_gpu_plugin.so for device GPU

4.7    infer_request_handle=exec_net.start_async(request_id=request_id,inputs={input_layer: blob})   File "ie_api.pyx", line 1105, in openvino.inference_engine.ie_api.ExecutableNetwork.start_async ValueError: Incorrect request_id specified!


1、流程:

训练YOLOv5模型-----转化pt文件为onnx-----转化为xml+bin-----放入预测代码中

2、预测代码更改:

1.CPU、GPU的调动选择 

 2.模型路径

 3.名称类型(要预测的种类)

 4.异步模式是否开启(如果使用MP4文件记得改0为mp4路径并且关闭异步模式)

  3、主要参考文章

【pytorch】将yolov5模型通过openVINO2022部署至生产环境(一):python版本+异步模式_颢师傅的博客-CSDN博客_python yolov5 部署

   pt文件转化直接使用命令 没有使用代码 

​​​​​​https://blog.csdn.net/zhou_438/article/details/112846704  这篇文中的这个也是可以的

这篇文中的这个也是可以的

4.报错踩坑集合

4.1  mportError: libpython3.9.so.1.0: cannot open shared object file: No such file or directory

OpenVINO: export failure: libpython3.9.so.1.0: cannot open shared object file: No such file or direc_高精度计算机视觉的博客-CSDN博客 做了 好像没什么用

Error: “ImportError: libpython3.9.so.1.0: Cannot Open Shared...

官方解决方案

https://blog.csdn.net/sunmingyang1987/article/details/104816336?ops_request_misc=&request_id=&biz_id=102&utm_term=ImportError:%20libpython3.9.so.1&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-3-104816336.142^v46^pc_rank_34_default_3&spm=1018.2226.3001.4187https://blog.csdn.net/sunmingyang1987/article/details/104816336?ops_request_misc=&request_id=&biz_id=102&utm_term=ImportError:%20libpython3.9.so.1&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-3-104816336.142%5Ev46%5Epc_rank_34_default_3&spm=1018.2226.3001.4187

https://blog.csdn.net/sunmingyang1987/article/details/104816336?ops_request_misc=&request_id=&biz_id=102&utm_term=ImportError:%20libpython3.9.so.1&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-3-104816336.142^v46^pc_rank_34_default_3&spm=1018.2226.3001.4187https://blog.csdn.net/sunmingyang1987/article/details/104816336?ops_request_misc=&request_id=&biz_id=102&utm_term=ImportError:%20libpython3.9.so.1&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-3-104816336.142%5Ev46%5Epc_rank_34_default_3&spm=1018.2226.3001.4187

这两条是有用的

4.2  QObject::moveToThread: Current thread (0xb7f210) is not the object's thread (0x188cc30). Cannot move to target thread (0xb7f210)

https://blog.csdn.net/m0_59496782/article/details/122833159?ops_request_misc=&request_id=&biz_id=102&utm_term=QObject::moveToThread:%20Current&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-0-122833159.142^v47^pc_rank_34_default_2,201^v2^control&spm=1018.2226.3001.4187https://blog.csdn.net/m0_59496782/article/details/122833159?ops_request_misc=&request_id=&biz_id=102&utm_term=QObject::moveToThread:%20Current&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-0-122833159.142%5Ev47%5Epc_rank_34_default_2,201%5Ev2%5Econtrol&spm=1018.2226.3001.4187

https://blog.csdn.net/ZHUO__zhuo/article/details/124183843?ops_request_misc=&request_id=&biz_id=102&utm_term=QObject::moveToThread:%20Current&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-4-124183843.142^v47^pc_rank_34_default_2,201^v2^control&spm=1018.2226.3001.4187https://blog.csdn.net/ZHUO__zhuo/article/details/124183843?ops_request_misc=&request_id=&biz_id=102&utm_term=QObject::moveToThread:%20Current&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-4-124183843.142%5Ev47%5Epc_rank_34_default_2,201%5Ev2%5Econtrol&spm=1018.2226.3001.4187

文二中方法一可行 注意要先换pip、conda源,不然真的慢。清华源有时候会有问题,可以多加两个。

解决方案:QObject::moveToThread: Current thread (***) is not the object‘s thread_江南蜡笔小新的博客-CSDN博客

重装时同时降低了opencv-python版本,小于等于安装的opencv版本

https://blog.csdn.net/qq_43619461/article/details/121784848?ops_request_misc=&request_id=&biz_id=102&utm_term=QObject::moveToThread:%20Current&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-9-121784848.142^v47^pc_rank_34_default_2,201^v2^control&spm=1018.2226.3001.4187https://blog.csdn.net/qq_43619461/article/details/121784848?ops_request_misc=&request_id=&biz_id=102&utm_term=QObject::moveToThread:%20Current&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-9-121784848.142%5Ev47%5Epc_rank_34_default_2,201%5Ev2%5Econtrol&spm=1018.2226.3001.4187

这篇文章中推荐降python。网上主流就是降opencv/重装pyqt、opencv-python。降python之后很多要重新配置,很麻烦。

4.2.1  ERROR: Could not install packages due to an OSError: [Errno 2] 没有那个文件或目录: '/home/amov/anaconda3/envs/yolov5/lib/python3.9/site-packages/PyQt5-5.15.7.dist-info/METADATA'

为重装中遇到问题 已解决

ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: ‘c:\\users_Wizard Wangjiang的博客-CSDN博客 

ERROR: Could not install packages due to an OSError: [ Errno 2] No such file or directory: ***_每天只睡23小时的博客-CSDN博客 理论上这个也行 我是直都删了装过

4.3    [ WARN:0@0.868] global /io/opencv/modules/videoio/src/cap_v4l.cpp (889) open VIDEOIO(V4L2:/dev/video0): can't open camera by index 未解决

https://blog.csdn.net/DSK_981029/article/details/111143231?ops_request_misc=&request_id=&biz_id=102&utm_term=%5B%20WARN:0@0.868%5D%20global%20/io/ope&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-6-111143231.142^v47^pc_rank_34_default_2,201^v2^control&spm=1018.2226.3001.4187https://blog.csdn.net/DSK_981029/article/details/111143231?ops_request_misc=&request_id=&biz_id=102&utm_term=%5B%20WARN:0@0.868%5D%20global%20/io/ope&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-6-111143231.142%5Ev47%5Epc_rank_34_default_2,201%5Ev2%5Econtrol&spm=1018.2226.3001.4187

https://blog.csdn.net/weixin_29523195/article/details/111984371?ops_request_misc=&request_id=&biz_id=102&utm_term=%5B%20WARN:0@0.868%5D%20global%20/io/ope&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-7-111984371.142^v47^pc_rank_34_default_2,201^v2^control&spm=1018.2226.3001.4187https://blog.csdn.net/weixin_29523195/article/details/111984371?ops_request_misc=&request_id=&biz_id=102&utm_term=%5B%20WARN:0@0.868%5D%20global%20/io/ope&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-7-111984371.142%5Ev47%5Epc_rank_34_default_2,201%5Ev2%5Econtrol&spm=1018.2226.3001.4187

也尝试过给摄像头加权限。应当是程序问题。YOLOv5可以正常调用摄像头进行检测 

之后就不用摄像头了干脆 把输入源改成了视频

https://blog.csdn.net/u011888840/article/details/106146285/?ops_request_misc=&request_id=&biz_id=102&utm_term=%5B%20WARN:0@0.868%5D%20global%20/io/ope&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-0-106146285.142^v47^pc_rank_34_default_2,201^v2^control&spm=1018.2226.3001.4187https://blog.csdn.net/u011888840/article/details/106146285/?ops_request_misc=&request_id=&biz_id=102&utm_term=%5B%20WARN:0@0.868%5D%20global%20/io/ope&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-0-106146285.142%5Ev47%5Epc_rank_34_default_2,201%5Ev2%5Econtrol&spm=1018.2226.3001.4187

4.4    Cannot find reference 'inference_engine' in 'imported module openvino

调用SDK的时候一直报错,代码编译不通过 无法import openvino.inference /runtime

最后解决是更改了文件名称 原来叫openvino,改成openvino111就跑通了

python 绝对路径 import_米饭的白色的博客-CSDN博客_import 绝对路径 尝试过绝对路径import 可能操作不正确 没起作用 理论上应该起作用的

还有说法是把openvino移动到YOLOv5根目录下。链接中方法理论上是可以的,但是我没什么用

使用OpenVINO遇到No name 'IENetwork' in module 'openvino.inference_engine'解决_Einstellung的博客-CSDN博客

4.5    DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here. Deprecated in NumPy 1.20; for more details and guidance: NumPy 1.20.0 Release Notes — NumPy v1.24.dev0 Manual (Type.boolean, np.bool),

无害警告

4.6 Failed to create plugin /home/amov/anaconda3/envs/yolov5/lib/python3.9/site-packages/openvino/libs/libopenvino_intel_gpu_plugin.so for device GPU

[CLDNN ERROR]. clGetPlatformIDs error -1001同时出现这个

理论上是因为显卡及其驱动问题 导致的 但是因为在openvino中本来就可以不使用GPU

把GPU的调用去掉就好了

https://blog.csdn.net/ssyy5233225/article/details/103363835?ops_request_misc=&request_id=&biz_id=102&utm_term=RuntimeError:%20Failed%20to%20create&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-1-103363835.142^v46^pc_rank_34_default_3&spm=1018.2226.3001.4187https://blog.csdn.net/ssyy5233225/article/details/103363835?ops_request_misc=&request_id=&biz_id=102&utm_term=RuntimeError:%20Failed%20to%20create&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-1-103363835.142%5Ev46%5Epc_rank_34_default_3&spm=1018.2226.3001.4187

Error: Failed to Create Plugin, Invalid Vendor Type 官方文档

4.7    infer_request_handle=exec_net.start_async(request_id=request_id,inputs={input_layer: blob})   File "ie_api.pyx", line 1105, in openvino.inference_engine.ie_api.ExecutableNetwork.start_async ValueError: Incorrect request_id specified!

代码bug 在开启异步模式的时候 定义帧号码出现了问题 解决方法是关闭了异步模式 (视频也不能调用异步模式),把异步的全部改成false

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值