hank-ai / darknet

Darknet/YOLO object detection framework
https://darknetcv.ai/
Apache License 2.0
215 stars 32 forks source link

Darknet detector test interprets flags as image argument #62

Open StijnPruijssers opened 1 month ago

StijnPruijssers commented 1 month ago

I have successfully trained a test model with the repo. However, I want to evaluate my test set with the 'darknet detector test' command on a batch of images from the file test.txt.

Previously on a earlier version of the AlexeyAB fork I used a command like this which worked fine: darknet detector test obj.data cfg\detector_test.cfg modelWeights\detector_test_best.weights -ext_output -dont_show -out result.json < test.txt

However, now this results in the following error:

Error location: C:\src\darknet\src-lib\image_opencv.cpp, load_image_mat_cv(), line #72 Error message: failed to load image file "result.json" Thread #62760: main darknet thread Version v2.0-190-g3c9722d5 built on May 1 2024 16:56:45

Funnily enough, if I use the command that writes to a text version it does work. The working command looks like this: darknet detector test obj.data cfg\detector_test.cfg modelWeights\detector_test_best.weights -dont_show -ext_output < test.txt > result.txt

The results show up in results.txt but the same problem with the .json comes up when I try to add the -thresh or -iou_thresh flag to test performance with different values. If I use this command:

darknet detector test obj.data cfg\detector_test.cfg modelWeights\detector_test_best.weights -thresh 0.75 -dont_show -ext_output < test.txt > result.txt

It does not work and gives the same type of error as with the .json command:

Errno 2: No such file or directory Error location: C:\src\darknet\src-lib\image_opencv.cpp, load_image_mat_cv(), line #72 Error message: failed to load image file "0.75"

I have tried all commands with absolute paths and relative paths and flags in different order but functionality remains the same. At this moment I'm not sure why the .json or the threshold flags are interpreted as the image argument in the command.

I am running darknet on windows 11. With the following output of the darknet --version command:

Darknet v2.0-190-g3c9722d5 CUDA runtime version 11080 (v11.8), driver version 12000 (v12.0) cuDNN version 11080 (v8.9.6), use of half-size floats is ENABLED => 0: NVIDIA RTX 2000 Ada Generation Laptop GPU [#8.9], 8.0 GiB OpenCV v4.8.0

pete-machine commented 1 month ago

First, thank you Hank-ai for the great work your are doing!

I want to add a +1 on this issue. I noticed the same issue on linux/ubuntu when saving results to json.

The issue is reproducible with the default yolo4 model and weights:

wget https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v3_optimal/yolov4.weights
./build/src-cli/darknet detector test cfg/coco.data cfg/yolov4.cfg yolov4.weights -ext_output -dont_show -out result.json artwork/dog.jpg

I have checked and can confirmed that the same command works on the "AlexeyAB" version of darknet.