Compile and use YOLO v3 under win10

Deployment environment: win10 + CUDA 10.0 + vs2017 + opencv 3.4.0 

Code version is  https://github.com/AlexeyAB/darknet  

1, the initial preparation

  (1) Download the code

  (2) ensure that the VS2017 installed VC ++ v140 toolset, if not installed, open the Visual Studio Installer - modify - select c ++ find vc ++ v140 shown in the following figure on the right

  

2, modify the project file

  (1) If the environment is not CUDA10.0 (installed CUDA9.0, etc.), text editor, open  darknet.vcxproj   search CUDA 10.0 words, a total of two (CUDA 10.0 and middle spaces) will  CUDA 10.0   into your installation CUDA version such as (CUDA 9.0)

  (2) If the CUDA 9.0, also need   ; compute_75, sm_75    replaced    ; compute_70, sm_70  

3, project configuration

  (1) Open darknet.sln (GPU does not modify the open front darknet_no_gpu.sln also modify vcxproj of project file without the GPU), first open the project here will be prompted to redirect windows sdk selection 10.0, platform toolset choose not to upgrade    

                

  (2) setup release X64

    

  (3) Right-click darknet - Properties

     a) determine the platform toolset V140

      

      b)设置VC++目录(包含目录和库目录),分别设置为 OpenCV 的 安装目录  中的

        C:\opencv\opencv\build\include

        C:\opencv\opencv\build\include\opencv

        C:\opencv\opencv\build\include\opencv2

        和 C:\opencv\opencv\build\x64\vc14

        

      c) 设置链接器 

        链接器——输入——附加依赖项 点开后  直接添加  C:\opencv\opencv\build\x64\vc14 目录中的 lib 文件的名称 (这里是 opencv_world340.lib )

      

      d)分别点击应用和确定

4、开始编译

  (1)darknet项目右击 生成 

  (2)将 C:\opencv\opencv\build\x64\vc14 目录下的 opencv_ffmpeg340_64.dll  和  opencv_world340.dll 复制到  darknet-master\build\darknet\x64  目录下

  (3)几种编译报错的 解决方法

    a )MSB8036 The Windows SDK version 8.1 was not found. 

     解决方法: 这是由于目标版本问题,右击项目 —— 常规——将目标版本选中有的那个(这里是10.0.17763.0)

                        

    b ) MSB4019 未找到导入的项目“***Microsoft.Cpp\v4.0\V140\BuildCustomizations\CUDA 10.0.targets”。请确认 <Import> 声明中的路径正确,且磁盘上存在该文件。 darknet \darknet-master\build\darknet\darknet.vcxproj 301

      解决方法:将 NVIDIA GPU Computing Toolkit\CUDA\v10.0\extras\visual_studio_integration\MSBuildExtensions  文件夹 中的所有文件 复制到 C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140\BuildCustomizations 中重新编译即可

    c ) opencv2/core/core.hpp : No such file or directory 

      解决方法:右击项目 —— 将配置改成 release  平台改成 x64 

         

 

5 使用测试

     在源码页面下载yolov3的 yolov3.weights 也可以自己下载其他权重测试

    

    进入 darknet-master\build\darknet\x64  目录 打开命令行 输入  ./darknet.exe detector test cfg/coco.data cfg/yolov3.cfg yolov3.weights -thresh 0.25

    然后输入图片路径即可检测图片      ( -thresh 0.25  代表检测阈值,概率高于0.25的画框

    

 

      其他 检测命令  

    检测视频 ./darknet.exe detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights -thresh 0.25 test.MP4

       检测网络像头: ./darknet.exe detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights -thresh 0.25 相机网络地址

    其他检测可参照 github 网址

Guess you like

Origin www.cnblogs.com/Assist/p/11002517.html
Recommended