Learning Notes - DarkNet YoloV4 Object Detection Tutorial for Windows 10
Table of Contents:
- Introduction: (0:00)
- Prerequisite: (0:21)
- Download Darknet: (03:31)
- Copy cuDNN and OpenCV Files: (3:55)
- Build Darknet using Visual Studio: (4:50)
- Object Detection on Images: (8:53)
- Object Detection on Videos: (9:48)
- Object Detection on Webcams: (10:34)
Purpose: This is a tutorial on Installing DarkNet Yolov4 prepared by, and adopted from, TheCodingBug channel from YouTube. This learning notes is for my own guide for future reference and is shared for you who encounter a problem on installing DarkNet Yolov4 for Windows 10 using Nvidia CUDA GPU and OpenCV.
Steps:
- Building DarkNet
- Object Detection on Images
- Object Detection on Videos
- Object Detection on Webcam
- Anaconda — package manager for mutiple version of virtual environment for Python and associated packages
- Visual Studio – Integrated Development Environment (IDE) by Microsoft®
- CUDA — Computing Unified Device Architecture (NVIDIA® GPU computing device driver)
- CUDNN — CUDA® Deep Neural Network (NVIDIA®)
- OpenCV — Python/C++ library for Computer Vision machine learning
Download Anaconda Installer: anaconda.com/products/individual
then install it with default options.
Next, download Visual Studio Community 2019 16.7.2 – the Community Edition: https://visualstudio.microsoft.com/vs/community/
Then, run the installer:
Select Desktop development with C++
option for Studio Code C++ support
You may need to reboot your computer after installing Visual Studio.
Now download CUDA Toolkit 11.0 Update Downloads: developer.nvidia.com/cuda-11.0-update1-download-archive?target_os=Windows&target_arch=x86_64
Choose Windows
operating system for Select Target Platform
.
Choose CUDA Toolkit 11.0 Update 1 Downloads
:
Choose the following options:
- Operating System:
Windows
- Architecture:
x86_84
- Version:
10
- Installer Type:
exe (local)
Click Download cuDNN v8.0.5 (November 9th, 2020), for CUDA 11.0
to expand the driver list:
Click cuDNN Library for Windows (x86)
now the driver will be downloading.
Extract the driver file (.zip) you just downloaded:
Then copy the extracted files and folder inside cudnn-11.0-windows-x64-v8.0.5.39
to:
(C:) › Program Files › NVIDIA GPU Computing Toolkit › CUDA › v11.0 >
Here you will replace some files and folders with new ones:
bin
include
lib
NVIDIA_SLA_cuDNN_Support.txt
First, download Darknet from AlexeyAB/darknet
repository on GitHub (.zip format)
Then, create a folder name darknet
in your root directory C:\
Open this directory: C:/darknet/darknet-master/build/darknet/x64
Open new window: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1/bin/cudnn64_7.dll
Copy the cudnn64_7.dll
file to here: darknet › darknet-master › build › darknet › x64
From OpenCV_CUDA > build › install > x64 > vc16 > bin
, copy opencv_world440.dll
to darknet › darknet-master › build › darknet › x64
Inside darknet › darknet-master › build › darknet
, open darknet.vcxproj
file using code editor
Inside darknet.vcxproj
file, find CUDA 10
(ctrl+F) and change it to your CUDA version. For example: CUDA 10.1
Inside darknet › darknet-master › build › darknet
, open yolo_cpp_dil.vcxproj
file using code editor
Inside yolo_cpp_dil.vcxproj
file, find CUDA 10
(ctrl+F) and change it to your CUDA version. For example: CUDA 10.1
Open yolo_cpp_dil.vcxproj
file using Visual Studio
Click OK
Change the Debug
to Release
On the right side, right click on yolo_cpp.dll
Click Build
Once it is done without any error, close it.
Open darknet.sln
with Visual Studio
Change Debug
-> release
and Win32
-> x64
Right click on darknet.sln
, then click properties
Click C/C++
, go to Additional Include Directories
. Click the dropdown button and click <Edit...>
The display after clicking Edit
Go to OpenCV_CUDA › build > install > include
and copy the path
Copy and paste OpenCV_CUDA\build \instal/\include
path to the darknet.sln Additional Include Directories
Edit the Preprocessor Definitions
(optional) if you do not have a high end GPU: remove CUDNN_HALF
Go to CUDA C/C++
-> Device
-> Edit Code Generation
Remove compute_75,sm_75
Go to Linker
-> General
> Edit Additional Library Directories
Go to OpenCV_CUDA > build › install › x64 › vc16 › lib
and copy the path
Paste it to Linker -> General > Edit Additional Library Directories
Right click on darknet
and build
After finished without error, close the Visual Studio. You will find your darknet.exe
inside darknet › darknet-master › build › darknet › x64
Download YoloV4.weights
file
Copy the yolov4.weights
to here: darknet > darknet-master > build › darknet > x64
Also copy a video to test the model (for ex: japan.mp4
)
Open Anaconda prompt. Run: darknet.exe detector test cfg/coco.data cfg/yolov4.cfg yolov4. weights
Input image file name
This is the result
Predicting time needed
Run this command: darknet. exe detector demo cfg/coco.data cfg/yolov4.cfg yolov4.weights japan.mp4
This is the result:
The Average FPS: 13.5
Run this command: darknet.exe detector demo cfg/coco.data cfg/yolov4.cfg yolov4.weights-c 0
Thank you for reading the repository 🙏
Good luck! 💪
tag: #learning
#notes
#darknet
#yolov4
#object
#detection
#tutorial
#windows
#2021
#thecodingbugchannel
#youtube
#$$$$$