YOLO依赖opencv,所以需要在VS2017中配置opencv。YOLO使用的是COCO数据集,感兴趣的可以移步官网。
【配置opencv】属性表方式
新建opencv3410_release_x64.txt,粘贴如下内容后,改为opencv3410_release_x64.props。注意黄色部分自己的opencv路径
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ImportGroup Label="PropertySheets" /> <PropertyGroup Label="UserMacros" /> <PropertyGroup> <IncludePath>D:opencv3410uildinclude;D:opencv3410uildincludeopencv;D:opencv3410uildincludeopencv2;$(IncludePath)</IncludePath> <LibraryPath>D:opencv3410uildx64vc15lib;$(LibraryPath)</LibraryPath> </PropertyGroup> <ItemDefinitionGroup> <Link> <AdditionalDependencies>opencv_world3410.lib;%(AdditionalDependencies)</AdditionalDependencies> </Link> </ItemDefinitionGroup> <ItemGroup /> </Project>
【VS2017运行YOLOv4】
下载https://github.com/AlexeyAB/darknet后,解压。
修改darknet.vcxproj中cuda版本为自己安装的cuda版本,大概在55行、306行共计两处。
VS2017打开darknet.sln,如下图,添加opencv3410_release_x64.props,运行。在x64目录里会生成darknet.exe。
若报关于cuda的错误,把cuda安装目录
C:Program FilesNVIDIA GPU Computing ToolkitCUDAv10.1extrasvisual_studio_integrationMSBuildExtensions
里的4个文件拷贝到VS的安装目录
D:Program Files (x86)Microsoft Visual Studio2017EnterpriseCommon7IDEVCVCTargetsBuildCustomizations
【cmd执行darknet.exe】
下载已经训练好的权重文件yolov4.weights,地址:yolov4.weights(可能会比较慢)
在darknet.exe同目录下新建weights文件夹,用于存放权重文件yolov4.weights。
打开cmd,进入到darknet.exe所在的文件夹(其中dog.jpg可以换成自己的图片),输入:
darknet.exe detector test cfgcoco.data cfgyolov4.cfg .weightsyolov4.weights .datadog.jpg
【参考】
https://blog.csdn.net/qq_18483627/article/details/105861365
https://github.com/AlexeyAB/darknet#datasets 上一个链接是对此链接的中文解读,需下载的东西,此链接都有。