Welcome new user! You can search existing questions and answers without registering, but please register to post new questions and receive answers.
Welcome to JeVois Tech Zone, where you can ask questions and receive answers from other members of the community.

How to recompile darknet yolo for yolov3?

+1 vote

I want to recompile Darknet Yolo to use the Yolov3 code. I've replaced the source in jevoisbase/Contrib/darknet with the V3 code and it looks like it's still using the old version. I also tried replacing the code in darknet-nnpack and that didn't help either. Is this the right way to go about doing this?

Also, when using jevois-daemon, where do I put the params.cfg file so I can use my custom config and weights?

asked Jul 5, 2018 in Programmer Questions by PeterQuinn (1,000 points)

1 Answer

+1 vote
The code in jevoisbase/Contrib/darknet is the original unmodified code, and it is pulled there in case you want to compile it on your desktop with powerful GPUs and then use it to train a new network.

The code that runs with jevois is in jevoisbase/Contrib/darknet-nnpack

Compilation is a bit complex, have a look at the darknet section in CMakeLists.txt of jevoisbase. This is because we either use the plain scalar backend (on host) or the nnpack-accelerated one (on platform).

When using jevois-daemon on host, the modules and config files are in /jevois/
answered Jul 10, 2018 by JeVois (39,960 points)
Thanks for your help.
I got the Yolov3 tagged files from darknet-nnpack and after making a few small changes to Yolo.C it now compiles. I recompiled and put it on the device and it runs, but it still fails with my v3 config files. In order to figure this out, I recompiled on my Ubunto box so I could test it with jevois-daemon. It seg faults with my changes, which is odd because it ran on the device.
What's the best way to debug this code?
I was thinking to load it all into a debugger like codeblocks. Got any recommendations?

I'm a novice when it comes to C/C++ so there's no surprise that I've messed something up.
Yes, it took us quite some work to get V2 working as well. I am not sure how well NNPACK is integrated with V3. To debug, I would recommend to start on the host and just run

gdb --args ./jevois-daemon --videomapping=XXX

where XXX is a mapping number that will lauch YOLO (you can get it by issuing a 'listmappings' to jevois-deamon when it is running).

Then you can do the same thing on the device using a USB to serial adapter cable. See here for instructions: http://jevois.org/doc/Debugging.html

in short:

create an empty file called 'login' in the BOOT partition of your microSD. JeVois will now just get you to a login prompt over the 4-pin serial port. Username is root, no password.

then vi /usr/bin/jevois.sh and look for gdb in there; comment out the line that launches jevois-daemon and uncomment the one that launches it in gdb

then run jevois.sh which will load the kernel modules and start jevois-daemon in gdb

type run in gdb and then use inventor or guvcview, etc on your host to trigger the module. Once you crash, type 'bt' in gdb for the backtrace.
Thanks for the quick answer. It's clearly failing in the code that I changed - so that's good news. Now to figure out the mysteries of memory allocation...
Ok. I have it running now with the Yolov2 config and weights. I'm running into a problem with Yolov3.cfg. I get an error when loading the network - symbol lookup error:/usr/lib/libjevoisbase.so.1.8.1:undefined symbol: make_yolo_layer
Yolov3 adds a new entry into the cfg file for a [Yolo] type layer, so I am guessing that this is what's causing the problem and I need to modify something to handle it. My question is - where is this code? I can't seem to find where it's getting this error from searching the Jevoisbase  repo.
Let me give it a shot. The code and pre-trained weights have been available now so we are due for an update to YOLO v3 in the mainline code. Hopefully we can post an update soon.
Quick follow up on this. I updated darnket-nnpack and all its dependencies. Yolo v3 compiles and runs on host, but crashes violently (bad memory corruption) on platform. The crash occurs during parsing of the network, even before we load the weights and start calling NNPACK-accelerated inference. I am instrumenting the network parsing code in darknet now to try to find the problem. Using the latest darknet (non-nnpack) gives the same results.
It's running for me on the platform with the default network and weights.  By the way, I tried a different fork that seemed to be more up to date: https://github.com/shizukachan/darknet-nnpack.
Yolov3 works great with the latest checkin. Thanks for upgrading it. It appears to be running much faster too.
yes, it gets to just under 1s/frame at 320x240. Now that code still has problems, see the patch file jevoisbase/Contrib/darknet-nnpack.patch

It is one example where adding debug instrumentation eliminated the bug. In this case, ignore the edits related to profiler (those are legit additions), then there was one bug when loading the weights (one field in the weight file is saved/loaded as size_t, but size_t is 8 bytes on x86_64 and 4 bytes on arm32), and then all the other changes are just adding a bunch of printf() statements during parsing of the network config. Somehow just adding those printf() eliminates the crash. So there is still some bad memory spillover somewhere in darknet-nnpack...