使用OpenCV部署全景驾驶感知网络YOLOP,可同时处理交通目标检测、可驾驶区域分割、车道线检测,三项视觉感知任务,包含C++和Python两种版本的程序实现。本套程序只依赖opencv库就可以运行, 从而彻底摆脱对任何深度学习框架的依赖。

Overview

YOLOP-opencv-dnn

使用OpenCV部署全景驾驶感知网络YOLOP,可同时处理交通目标检测、可驾驶区域分割、车道线检测,三项视觉感知任务,依然是包含C++和Python两种版本的程序实现

onnx文件从百度云盘下载,链接:https://pan.baidu.com/s/1A_9cldUHeY9GUle_HO4Crg 提取码:mf1x

C++版本的主程序文件是main.cpp,Python版本的主程序文件是main.py。把onnx文件下载到主程序文件所在目录后,就可以运行程序了。文件夹images 里含有若干张测试图片,来自于bdd100k自动驾驶数据集。

本套程序是在华中科技大学视觉团队在最近发布的项目https://github.com/hustvl/YOLOP 的基础上做的一个opencv推理部署程序,本套程序只依赖opencv库就可以运行, 从而彻底摆脱对任何深度学习框架的依赖。如果程序运行出错,那很有可能是您安装的opencv版本低了,这时升级opencv版本就能正常运行的。

此外,在本套程序里,还有一个export_onnx.py文件,它是生成onnx文件的程序。不过,export_onnx.py文件不能本套程序目录内运行的, 假如您想了解如何生成.onnx文件,需要把export_onnx.py文件拷贝到https://github.com/hustvl/YOLOP 的主目录里之后,并且修改lib/models/common.py里的代码, 这时运行export_onnx.py就可以生成onnx文件了。在lib/models/common.py里修改哪些代码,可以参见我的csdn博客文章 https://blog.csdn.net/nihate/article/details/112731327

Comments
  • OpenCV 4.5.5.62无法加载网络

    OpenCV 4.5.5.62无法加载网络

    [ERROR:[email protected]] global D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\onnx\onnx_importer.cpp (909) cv::dnn::dnn4_v20211220::ONNXImporter::handleNode DNN/ONNX: ERROR during processing node with 3 inputs and 1 outputs: [Clip]:(598) from domain='ai.onnx' Traceback (most recent call last): File "C:\Users\QIAWEI\OneDrive - DNV\Projects\YOLOP-opencv-dnn\main.py", line 150, in yolonet = yolop(confThreshold=args.confThreshold, nmsThreshold=args.nmsThreshold, objThreshold=args.objThreshold) File "C:\Users\QIAWEI\OneDrive - DNV\Projects\YOLOP-opencv-dnn\main.py", line 19, in init self.net = cv2.dnn.readNet('yolop.onnx') cv2.error: OpenCV(4.5.5) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\onnx\onnx_importer.cpp:928: error: (-2:Unspecified error) in function 'cv::dnn::dnn4_v20211220::ONNXImporter::handleNode'

    Node [[email protected]]:(598) parse error: OpenCV(4.5.5) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\onnx\onnx_importer.cpp:1613: error: (-2:Unspecified error) in function 'void __cdecl cv::dnn::dnn4_v20211220::ONNXImporter::parseClip(class cv::dnn::dnn4_v20211220::LayerParams &,const class opencv_onnx::NodeProto &)'

    (expected: 'node_proto.input_size() == 1'), where 'node_proto.input_size()' is 3 must be equal to '1' is 1

    opened by Qian-at-DNV 1
  • Added an english traduction for the README, updated export_onnx.py and added yolop.onnx directly in the repo

    Added an english traduction for the README, updated export_onnx.py and added yolop.onnx directly in the repo

    I updated export_onnx.py to have more comprehensible errors. I translated the readme in English. I added directly the yolop.onnx file in the repo as it is fairly lightweight.

    opened by LapinCodeur 0
  • 请问好像Python3.8.6运行有问题还是其它问题?

    请问好像Python3.8.6运行有问题还是其它问题?

    [ERROR:[email protected]] global D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\onnx\onnx_importer.cpp (909) cv::dnn::dnn4_v20211220::ONNXImporter::handleNode DNN/ONNX: ERROR during processing node with 3 inputs and 1 o utputs: [Clip]:(598) from domain='ai.onnx' Traceback (most recent call last): File "e:/MachineVision/OpenCV/_Python/YOLOP-opencv-dnn-traffic/main.py", line 152, in yolonet = yolop(confThreshold=args.confThreshold, nmsThreshold=args.nmsThreshold, objThreshold=args.objThreshold) File "e:/MachineVision/OpenCV/_Python/YOLOP-opencv-dnn-traffic/main.py", line 21, in init self.net = cv2.dnn.readNet(Path+'yolop.onnx') cv2.error: OpenCV(4.5.5) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\onnx\onnx_importer.cpp:928: error: (-2:Unspecified error) in function 'cv::dnn::dnn4_v20211220::ONNXImporter::handleNode'

    Node [[email protected]]:(598) parse error: OpenCV(4.5.5) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\onnx\onnx_importer.cpp:1613: error: (-2:Unspecified error) in function 'void __cdecl cv::dnn::dnn4_v2021122 0::ONNXImporter::parseClip(class cv::dnn::dnn4_v20211220::LayerParams &,const class opencv_onnx::NodeProto &)'

    (expected: 'node_proto.input_size() == 1'), where 'node_proto.input_size()' is 3 must be equal to '1' is 1

    opened by 13501714030 2
  • Interesting project but how's the latency you tested ?

    Interesting project but how's the latency you tested ?

    Thanks for the cpp work for YOLOP Just wonder it needs low-latency, high fps for the task such as autonomous driving. Could an onnx-model loaded through OpenCV use CUDA kernel?

    Have you test the latency for the inference time? Thanks !

    opened by Stephenfang51 0
  • OpenCV minimum version

    OpenCV minimum version

    Hi there, Thanks for your guys awesome tasks. But I met an issue while compiling through opencv. Which version your team using to build this repo?

    opencv/modules/dnn/src/onnx/onnx_importer.cpp:555: error: (-215:Assertion failed) blob.type() == 5 in function 'populateNet'

    opened by Takugo 4
Owner
深度学习算法工程师
null
用opencv的dnn模块做yolov5目标检测,包含C++和Python两个版本的程序

yolov5-dnn-cpp-py yolov5s,yolov5l,yolov5m,yolov5x的onnx文件在百度云盘下载, 链接:https://pan.baidu.com/s/1d67LUlOoPFQy0MV39gpJiw 提取码:bayj python版本的主程序是main_yolov5.

null 365 Jan 4, 2023