VS2017运行YOLOv4

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:\opencv3410\build\include;D:\opencv3410\build\include\opencv;D:\opencv3410\build\include\opencv2;$(IncludePath)</IncludePath>
    <LibraryPath>D:\opencv3410\build\x64\vc15\lib;$(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 Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\extras\visual_studio_integration\MSBuildExtensions

里的4个文件拷贝到VS的安装目录

D:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\BuildCustomizations

【cmd执行darknet.exe】

下载已经训练好的权重文件yolov4.weights,地址:yolov4.weights(可能会比较慢)

在darknet.exe同目录下新建weights文件夹,用于存放权重文件yolov4.weights。

打开cmd,进入到darknet.exe所在的文件夹(其中dog.jpg可以换成自己的图片),输入:

darknet.exe detector test cfg\coco.data cfg\yolov4.cfg .\weights\yolov4.weights .\data\dog.jpg

【参考】

https://blog.csdn.net/qq_18483627/article/details/105861365 

https://github.com/AlexeyAB/darknet#datasets 上一个链接是对此链接的中文解读,需下载的东西,此链接都有。

posted @ 2020-05-11 16:24  夕西行  阅读(2212)  评论(0编辑  收藏  举报