开源!适用于Win和Linux平台的YOLO4和YOLO3( 五 )

How to compile (custom):【开源!适用于Win和Linux平台的YOLO4和YOLO3】Also, you can to create your own darknet.sln & darknet.vcxproj, this example for CUDA 9.1 and OpenCV 3.0
Then add to your created project:

  • (right click on project) -> properties -> C/C++ -> General -> Additional Include Directories, put here:
C:opencv_3.0opencvbuildinclude;....3rdpartyinclude;%(AdditionalIncludeDirectories);$(CudaToolkitIncludeDir);$(CUDNN)include
  • (right click on project) -> Build dependecies -> Build Customizations -> set check on CUDA 9.1 or what version you have - for example as here: http://devblogs.nvidia.com/parallelforall/wp-content/uploads/2015/01/VS2013-R-5.jpg
  • add to project:all .c filesall .cu filesfile http_stream.cpp from src directoryfile darknet.h from include directory
  • (right click on project) -> properties -> Linker -> General -> Additional Library Directories, put here:
C:opencv_3.0opencvbuild\x64vc14lib;$(CUDA_PATH)lib$(PlatformName);$(CUDNN)lib\x64;%(AdditionalLibraryDirectories)
  • (right click on project) -> properties -> Linker -> Input -> Additional dependecies, put here:
....3rdpartylib\x64pthreadVC2.lib;cublas.lib;curand.lib;cudart.lib;cudnn.lib;%(AdditionalDependencies)
  • (right click on project) -> properties -> C/C++ -> Preprocessor -> Preprocessor Definitions
OPENCV;_TIMESPEC_DEFINED;_CRT_SECURE_NO_WARNINGS;_CRT_RAND_S;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
  • compile to .exe (X64 & Release) and put .dll-s near with .exe: https://hsto.org/webt/uh/fk/-e/uhfk-eb0q-hwd9hsxhrikbokd6u.jpegpthreadVC2.dll, pthreadGC2.dll from 3rdpartydll\x64cusolver64_91.dll, curand64_91.dll, cudart64_91.dll, cublas64_91.dll - 91 for CUDA 9.1 or your version, from C:Program FilesNVIDIA GPU Computing ToolkitCUDAv9.1binFor OpenCV 3.2: opencv_world320.dll and opencv_ffmpeg320_64.dll from C:opencv_3.0opencvbuild\x64vc14binFor OpenCV 2.4.13: opencv_core2413.dll, opencv_highgui2413.dll and opencv_ffmpeg2413_64.dll from C:opencv_2.4.13opencvbuild\x64vc14bin
How to train with multi-GPU:
  1. Train it first on 1 GPU for like 1000 iterations: darknet.exe detector train cfg/coco.data cfg/yolov4.cfg yolov4.conv.137
  2. Then stop and by using partially-trained model /backup/yolov4_1000.weights run training with multigpu (up to 4 GPUs): darknet.exe detector train cfg/coco.data cfg/yolov4.cfg /backup/yolov4_1000.weights -gpus 0,1,2,3
If you get a Nan, then for some datasets better to decrease learning rate, for 4 GPUs set learning_rate = 0,00065 (i.e. learning_rate = 0.00261 / GPUs). In this case also increase 4x times burn_in = in your cfg-file. I.e. use burn_in = 4000 instead of 1000.
https://groups.google.com/d/msg/darknet/NbJqonJBTSY/Te5PfIpuCAAJ
How to train (to detect your custom objects):(to train old Yolo v2 yolov2-voc.cfg, yolov2-tiny-voc.cfg, yolo-voc.cfg, yolo-voc.2.0.cfg, ... click by the link)
Training Yolo v4 (and v3):
  1. For training cfg/yolov4-custom.cfg download the pre-trained weights-file (162 MB): yolov4.conv.137 (Google drive mirror yolov4.conv.137 )
  2. Create file yolo-obj.cfg with the same content as in yolov4-custom.cfg (or copy yolov4-custom.cfg to yolo-obj.cfg) and: