AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.71k stars 7.96k forks source link

There is a way to predict on a batch of images? #6250

Open rafael-junio opened 4 years ago

rafael-junio commented 4 years ago

In Keras we can return predictions for a single batch of samples. Bellow is the commented section of the predict_on_batch function on keras/engine/training.py. There is something like this implemented in AlexeyAB darknet? I found this https://github.com/vincentgong7/VG_AlexeyAB_darknet/blob/master/src/detector.c. But it's seens that it only create a list and predict on one image per time. `

Arguments:
    x: Input data. It could be:
      - A Numpy array (or array-like), or a list of arrays
        (in case the model has multiple inputs).
      - A TensorFlow tensor, or a list of tensors
        (in case the model has multiple inputs).
      - A `tf.data` dataset.

Returns:
    Numpy array(s) of predictions.`
KacperPaszkowski commented 4 years ago

As far as I know there is function in OpenCV dnn module that allows that.

stephanecharette commented 4 years ago

There is also DarkHelp, where you can use parameters like --json to get the results as a JSON object after it looks at a batch of images: https://www.ccoderun.ca/DarkHelp/api/ShellScripting.html

YCAyca commented 4 years ago

Actually the repo of vincentgog work fine. I dont know if he changed something though. You can reach my repo forked from VG with some additional features : https://github.com/YCAyca/YCA_VG_AlexeyAB_darknet . All you need to do is to download and build the project then use the command darknet_no_gpu.exe detector batch .... explained in "General Usage" section.

saraswat40 commented 3 years ago

@stephanecharette I am trying to build DarkHelp on ubuntu 20.04 but it gives me this error: [ 25%] Building CXX object src-lib/CMakeFiles/dh.dir/DarkHelp.cpp.o /home/saraswat/Downloads/darknet3/darkhelp-1.1.2-3079-Source/src-lib/DarkHelp.cpp: In member function ‘virtual void DarkHelp::reset()’: /home/saraswat/Downloads/darknet3/darkhelp-1.1.2-3079-Source/src-lib/DarkHelp.cpp:176:3: error: ‘free_network’ was not declared in this scope free_network(nw); ^~~~ /home/saraswat/Downloads/darknet3/darkhelp-1.1.2-3079-Source/src-lib/DarkHelp.cpp:176:3: note: suggested alternative: ‘load_network’ free_network(nw); ^~~~ load_network make[2]: [src-lib/CMakeFiles/dh.dir/build.make:82: src-lib/CMakeFiles/dh.dir/DarkHelp.cpp.o] Error 1 make[1]: [CMakeFiles/Makefile2:155: src-lib/CMakeFiles/dh.dir/all] Error 2 make: *** [Makefile:171: all] Error 2

Can you let me know what I missed? I have zero experience with C++ unfortunately.

stephanecharette commented 3 years ago

If your version of Darknet doesn't have the free_network() API call, then it is very out-of-date. I suggest you do a git pull in your darknet directory and rebuild.

stephanecharette commented 3 years ago

Looking at the repo, AlexeyAB exposed the free_network() API 11 months ago:

489ea7fd (AlexeyAB              2020-01-01 21:38:06 +0300  997) LIB_API void free_network(network net);

So your version of Darknet must be older than that. Or there is something wrong with what you think you built.

If you continue to have trouble, you can also come ask for help in the DarkHelp channel on the Darknet/YOLO discord: https://discord.gg/zSq8rtW

saraswat40 commented 3 years ago

Hello, Yes my darknet version is old. I will update it. Many thanks for responding.