- League of Legends Object Detection Images and Labels
- Trained YOLOv3 model weights
- YOLOv3 .cfg file
- YOLOv3 .data file
- PPO Model
- Windows
- Clone darknet for windows into current directory
- CMake >= 3.8 for modern CUDA support: https://cmake.org/download/
- CUDA 10.0: https://developer.nvidia.com/cuda-toolkit-archive (on Linux do Post-installation Actions)
- OpenCV >= 2.4: use your preferred package manager (brew, apt), build from source using vcpkg or download from OpenCV official site (on Windows set system variable
OpenCV_DIR
=C:\opencv\build
- where are theinclude
andx64
folders image) - cuDNN >= 7.0 for CUDA 10.0 https://developer.nvidia.com/rdp/cudnn-archive (on Linux copy
cudnn.h
,libcudnn.so
... as desribed here https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#installlinux-tar , on Windows copycudnn.h
,cudnn64_7.dll
,cudnn64_7.lib
as desribed here https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#installwindows ) - GPU with CC >= 3.0: https://en.wikipedia.org/wiki/CUDA#GPUs_supported
- on Linux GCC or Clang, on Windows MSVC 2015/2017/2019 https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community
Compiling on Windows by using Cmake-GUI
as on this IMAGE: Configure -> Optional platform for generator (Set: x64) -> Finish -> Generate -> Open Project -> x64 & Release -> Build -> Build solution
Compiling on Linux by using command make
(or alternative way by using command: cmake . && make
)
If you have already installed Visual Studio 2015/2017/2019, CUDA > 10.0, cuDNN > 7.0, OpenCV > 2.4, then compile Darknet by using C:\Program Files\CMake\bin\cmake-gui.exe
as on this IMAGE: Configure -> Optional platform for generator (Set: x64) -> Finish -> Generate -> Open Project -> x64 & Release -> Build -> Build solution
Otherwise, follow these steps:
-
Install or update Visual Studio to at least version 2017, making sure to have it fully patched (run again the installer if not sure to automatically update to latest version). If you need to install from scratch, download VS from here: Visual Studio Community
-
Install CUDA and cuDNN
-
Install
git
andcmake
. Make sure they are on the Path at least for the current account -
Install vcpkg and try to install a test library to make sure everything is working, for example
vcpkg install opengl
-
Define an environment variables,
VCPKG_ROOT
, pointing to the install path ofvcpkg
-
Define another environment variable, with name
VCPKG_DEFAULT_TRIPLET
and valuex64-windows
-
Open Powershell and type these commands:
PS \> cd $env:VCPKG_ROOT
PS Code\vcpkg> .\vcpkg install pthreads opencv[ffmpeg] #replace with opencv[cuda,ffmpeg] in case you want to use cuda-accelerated openCV
- Open Powershell, go to the
darknet
folder and build with the command.\build.ps1
. If you want to use Visual Studio, you will find two custom solutions created for you by CMake after the build, one inbuild_win_debug
and the other inbuild_win_release
, containing all the appropriate config flags for your system.
- on Linux - set
LIBSO=1
in theMakefile
and domake
- on Windows - compile
build\darknet\yolo_cpp_dll.sln
orbuild\darknet\yolo_cpp_dll_no_gpu.sln
solution
There are 2 APIs:
-
C API: https://github.com/AlexeyAB/darknet/blob/master/include/darknet.h
- Python examples using the C API::
-
C++ API: https://github.com/AlexeyAB/darknet/blob/master/include/yolo_v2_class.hpp
- C++ example that uses C++ API: https://github.com/AlexeyAB/darknet/blob/master/src/yolo_console_dll.cpp
-
To compile Yolo as C++ DLL-file
yolo_cpp_dll.dll
- open the solutionbuild\darknet\yolo_cpp_dll.sln
, set x64 and Release, and do the: Build -> Build yolo_cpp_dll- You should have installed CUDA 10.0
- To use cuDNN do: (right click on project) -> properties -> C/C++ -> Preprocessor -> Preprocessor Definitions, and add at the beginning of line:
CUDNN;
-
To use Yolo as DLL-file in your C++ console application - open the solution
build\darknet\yolo_console_dll.sln
, set x64 and Release, and do the: Build -> Build yolo_console_dll-
you can run your console application from Windows Explorer
build\darknet\x64\yolo_console_dll.exe
use this command:yolo_console_dll.exe data/coco.names yolov3.cfg yolov3.weights test.mp4
-
after launching your console application and entering the image file name - you will see info for each object:
<obj_id> <left_x> <top_y> <width> <height> <probability>
-
to use simple OpenCV-GUI you should uncomment line
//#define OPENCV
inyolo_console_dll.cpp
-file: link -
you can see source code of simple example for detection on the video file: link
-
yolo_cpp_dll.dll
-API: link
struct bbox_t {
unsigned int x, y, w, h; // (x,y) - top-left corner, (w, h) - width & height of bounded box
float prob; // confidence - probability that the object was found correctly
unsigned int obj_id; // class of object - from range [0, classes-1]
unsigned int track_id; // tracking id for video (0 - untracked, 1 - inf - tracked object)
unsigned int frames_counter;// counter of frames on which the object was detected
};
class Detector {
public:
Detector(std::string cfg_filename, std::string weight_filename, int gpu_id = 0);
~Detector();
std::vector<bbox_t> detect(std::string image_filename, float thresh = 0.2, bool use_mean = false);
std::vector<bbox_t> detect(image_t img, float thresh = 0.2, bool use_mean = false);
static image_t load_image(std::string image_filename);
static void free_image(image_t m);
#ifdef OPENCV
std::vector<bbox_t> detect(cv::Mat mat, float thresh = 0.2, bool use_mean = false);
std::shared_ptr<image_t> mat_to_image_resize(cv::Mat mat) const;
#endif
};