[Darknet-off topic] Cannot load image "-dont_show" despite patch of images and opencv OK [closed]

asked 2020-04-06 07:15:01 -0600

Leprechault gravatar image

updated 2020-04-08 07:32:16 -0600

berak gravatar image

I'll like to know the explanation about the output error:

  105 conv     18  1 x 1 / 1    76 x  76 x 256   ->    76 x  76 x  18  0.053 BFLOPs
  106 yolo
Loading weights from backup/obj_100.weights...Done!
Cannot load image "-dont_show"
free(): invalid pointer

when a try to use the ./darknet detector test obj.data obj.cfg backup/obj_100.weights -dont_show -ext_output < data/train.txt > result.txt command. I check the train.txt and the image path is OK:

/home/fitlab1/Área de Trabalho/CNN4antsYOLO/darknet/sample_107.jpg

The opencv is OK too:

python3 -c "\
import cv2
print(cv2.__version__)"
4.2.0

and the prediction direct with the file image name using the command ./darknet detector train obj.data cfg/obj.cfg darknet53.conv.74 -map | tee log.txt work very well:

  105 conv     18  1 x 1 / 1    76 x  76 x 256   ->    76 x  76 x  18  0.053 BFLOPs
  106 yolo
Loading weights from darknet53.conv.74...obj
Done!

Is there some explanation for this error?

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by berak
close date 2020-04-08 07:37:15.244346

Comments

This is very confusing to me. The "-dont_show" flag is a command line flag for the yolo/darknet executable. How is this related to opencv?

And your command does not contain the path to the image - please check the documentation on how to use command line correctly..

holger gravatar imageholger ( 2020-04-08 06:46:15 -0600 )edit

I would like to close this as offtopic - as this is really not an opencv issue. If you have question on how to do inference on a yolo model with opencv - come back later.

holger gravatar imageholger ( 2020-04-08 06:48:15 -0600 )edit

The opencv is OK too:

no proof, python uses a different package than darknet

berak gravatar imageberak ( 2020-04-08 07:16:00 -0600 )edit

Thank @holger, but in the code -ext_output < data/train.txt > my *txt file with the path of images is inside de datadirectory. I don't know what's wrong I check the darknet documentation in (https://github.com/pjreddie/darknet).

Leprechault gravatar imageLeprechault ( 2020-04-08 07:16:55 -0600 )edit
1

Pardon me? The problem is in this line:

Cannot load image "-dont_show"

And the error is coming for the darknet/yolo executable. Python or opencv is not involved in this "problem". He should just pick the correct command line options. Yolo is not foolproof there(not best programmed imho).

And also

./darknet detector train obj.data cfg/obj.cfg darknet53.conv.74 -map | tee log.txt

This does not do inference/predictions - it trains a model. If it output a prediction - then only because its luck or you using debug output - you shouldn't use training(back propagation) to make predictions(inference)

You base command should look like this:

./darknet detector train obj.data cfg/obj.cfg darknet53.conv.74 myImage.jpg
holger gravatar imageholger ( 2020-04-08 07:29:23 -0600 )edit
1

Cannot load image "-dont_show"

it expected an image path where you gave it -dont_show .

please lookup how cmdline args are handeled in examples/darknet.c

berak gravatar imageberak ( 2020-04-08 07:34:27 -0600 )edit
1

@holger - beat me by a few seconds ;)

i would not say darknet is always off-topic (it's using opencv for gui and images)

but in this case - sure.

berak gravatar imageberak ( 2020-04-08 07:36:52 -0600 )edit

Berak you got the point :-) Just try out by adding flag one after the other to see where it breaks(i am not sure anymore - i do these things programatically). The command line handling is not intuitive/buggy/ not good documented imho.

holger gravatar imageholger ( 2020-04-08 07:37:17 -0600 )edit