bennetthardwick / darknet.js

A NodeJS wrapper of pjreddie's darknet / yolo.
65 stars 27 forks source link

Performance #27

Closed viper86it closed 4 years ago

viper86it commented 5 years ago

First of all thank you for your hard work!!!!

Let's talk about performance: I did some tests and on my hardware (Nvidia Jetson Nano) performance are quite low.

If I use Darknet (AlexeyAB) in order to open an IP camera with RTSP protocol I'm able to reach 13-15 FPS but if I do the same with your wrapper, using opencv4nodejs to grep RTSP data, I get only 5.5 FPS.

Darknet run command: ./darknet detector demo ./cfg/coco.data ./cfg/yolov2-tiny.cfg ./yolov2-tiny.weights "rtsp://admin:Password@X.X.X.X:554"

In order to understand if the difference is Darknet fork, I also tested Darknet (pjreddie) opening webcam and the result is always 13-15 FPS. Testing your wrapper with a MP4 video file doesn't change... 4-5 FPS.

Have you any suggestion how to reach darknet performace? I will reach at least 13-15 fps in my project.

PS: I compiled both Darknet with GPU and CUDNN support.

Thanks

bennetthardwick commented 5 years ago

At the moment there's nothing you can really do for performance without diving into the source code. This library was originally based off the darknet python wrapper which I imagine would have similar performance issues. The code that you're using to do the test lives here and a lot of optimization like multi-threading as well native OpenCV, where as Darknet.js has to get images as JavaScript objects and then turn them back into images in C++.

I did notice however that in that demo.c file the set_batch_network option is used, which I didn't even know about. In darknet@2.0.15 I've added that as an option in the config, just pass { batch: true } to enable it. I didn't notice any speed improvements, but I also wasn't detecting on video.

bennetthardwick commented 4 years ago

Feel free to re-open this if there's any other performance problems you run into.