Yolo C++ (with OpenCV3), OpenCL and CUDA

C++ Port of Darknet (of YOLO fame)

Submitted by prabindh on July/11/2017 - 13:35 / /

OpenCV3 failures when working with C based DL frameworks, like DeepNet (Made famous by YOLO - http://pjreddie.com/darknet/yolo/) is a common issue.
Here is the latest version of Darknet, ported to C++, fixing many coding bugs along the way. Work involved primarily encapsulation of APIs with C linkages, including undefined headers, bug fixes, typecasting various allocations to actual types, using correct Error detection types for CUBLAS, and finally, creating a C++ API (Arapaho).

For training with own dataset, and detection, refer to the updated README at,

https://github.com/prabindh/darknet/blob/master/README.md

Sample logs with the CPP port version below:
./darknet-cpp coco test cfg/tiny-coco.cfg tiny-coco.weights data/giraffe.jpg 0: Convolutional Layer: 448 x 448 x 3 image, 16 filters -> 448 x 448 x 16 image 1: Maxpool Layer: 448 x 448 x 16 image, 2 size, 2 stride 2: Convolutional Layer: 224 x 224 x 16 image, 32 filters -> 224 x 224 x 32 image 3: Maxpool Layer: 224 x 224 x 32 image, 2 size, 2 stride 4: Convolutional Layer: 112 x 112 x 32 image, 64 filters -> 112 x 112 x 64 image 5: Maxpool Layer: 112 x 112 x 64 image, 2 size, 2 stride 6: Convolutional Layer: 56 x 56 x 64 image, 128 filters -> 56 x 56 x 128 image 7: Maxpool Layer: 56 x 56 x 128 image, 2 size, 2 stride 8: Convolutional Layer: 28 x 28 x 128 image, 256 filters -> 28 x 28 x 256 image 9: Maxpool Layer: 28 x 28 x 256 image, 2 size, 2 stride 10: Convolutional Layer: 14 x 14 x 256 image, 512 filters -> 14 x 14 x 512 image 11: Maxpool Layer: 14 x 14 x 512 image, 2 size, 2 stride 12: Convolutional Layer: 7 x 7 x 512 image, 1024 filters -> 7 x 7 x 1024 image 13: Convolutional Layer: 7 x 7 x 1024 image, 256 filters -> 7 x 7 x 256 image 14: Connected Layer: 12544 inputs, 4655 outputs 15: Detection Layer forced: Using default '0' Loading weights from tiny-coco.weights...Done! data/giraffe.jpg: Predicted in 6.086653 seconds. giraffe: 49% zebra: 37%

Many forks are currently using this, interesting ones like https://github.com/mrzl/ofxDarknet (darknet neural network addon for openFrameworks), and interesting demonstrations of Multi-person detectors like https://www.youtube.com/watch?v=9cKLYVdExr0, and Bus detectors like in this from here, and Unified detection system for automatic, real-time, accurate animal detection in camera trap images from the arctic tundra

Other companies that have evaluated the fork at various times include envrmnt, vipl, nilu, duranc.

Special mention of the OpenCL fork at https://github.com/myestro/darknet/, gives about 1 fps with Yolo on a Mali GPU.

Prebuilt binaries of Yolov2 for inference on Tegra TK1 (with CUDNN enabled), and Yolov3 inference on x64/Windows/Linux is available in the repository at,

https://github.com/prabindh/yolo-bins


Forum Discussion:

Refer to the many threads on the C++ port, including this.
1. https://groups.google.com/forum/#!topic/darknet/4Hb159aZBbA
2. https://groups.google.com/forum/#!topic/darknet/bXDkfGwU3CE
3. https://groups.google.com/forum/#!topic/darknet/4Hb159aZBbA

And further blog posts,
1. https://covijn.com/2016/11/fixing-darknet-opencv3-make-error-convolution...

2. If Qt5 and OpenCV are involved, also refer to the work done at,
http://gpupowered.org/node/56 [Integrating Darknet/Yolo and OpenCV3, with Qt5]

3. Windows build is supported (ongoing) through the solution files at https://github.com/prabindh/darknet-cpp-windows