bnosac/image

Image.darknet:Cannot detect anything.

xlxlcyRuSReXxlxl opened this issue · 12 comments

After having installed image.darknet in R I tried to carry out the model using the weights trained on "coco", just copying the code and nothing else. That said, I gave input a very simple "object" to detect (it was a sweetie cat), but the output has been the following:
C:////*/cat.jpg: Predicted in 5.22000 seconds.
Boxes: 845 of which 0 above the threshold.
After that I have tried with some other images whose content were bottles, dogs, so I guess the model shouldn't have any problem to detect them correctly since the coco model provides the possibility to detect those labels.
I suppose that I am missing something critical. Any help?
Thanks in advance for your answers!

Lower the threshold, or get on Linux would be my advise as originally darknet was Linux-only.

Already tried lowering the threshold, but I got the same results. I will try to run that on Linux, as you suggest. Many thanks!

You might also want to take other trained models instead of tiny coco.
See ?image_darknet_model

Please make your example reproducible and make sure you use the correct network configuration, network weights and labels. See https://pjreddie.com/darknet/yolo/

Could you show me the right way to move forward please?
It's unlikely that i did wrong something since i just download the model, the weights and labels, and copied the code (even lowering the threshold) in the help.
By the way the imagine is attached below.

Thank you again !
cat1

You need to give code that can be run with copy-pasteing in the console, otherwise, I can not help you. Also make sure the model, weights, labels are correct. These can be downloaded from https://pjreddie.com/darknet/yolo/ (just below the video you'll find the model configuration (cfg files), the deep learning weights (.weights file) and the labels are either COCO or VOC (that is indicated in the Train column).

I used the code below :
library(devtools)
library(image.darknet)
f <- system.file(package="image.darknet", "include", "darknet", "data", "coco.names")
labels <- readLines(f)
download.file(url = "http://pjreddie.com/media/files/tiny-yolo.weights", destfile = weights)
weights <- file.path(system.file(package="image.darknet", "models"), "tiny-yolo.weights")
yolo_tiny_coco <- image_darknet_model(type = 'detect',
model = "tiny-yolo.cfg",
weights = system.file(package="image.darknet", "models", "tiny-yolo.weights"),
labels = labels)
yolo_tiny_coco
x<-image_darknet_detect("C:/Users/Ciro1/Desktop/immagini/cat.jpg",yolo_tiny_coco)
While the output has been the following:
C:/Users/Ciro1/Desktop/immagini/cat.jpg: Predicted in 31.884000 seconds.
Boxes: 845 of which 0 above the threshold.

I tried also lowering the threshold but I got the same results, as I told you before. What do you suggest?

Can you make sure you I can run this in a clean R session from my side.

Yes, I am sure. Once I have downloaded the models,labels and weights, that's the entire code I used.

Your example is not reproducible. You need to provide code that I can just copy-paste in my console and which will work without errors. Currently your code contains errors when run from a clean session.

I don't know what to do more than this, I am struggling to understand what I am doing wrong, but it looks impossible.
Don't know if it depends from the fact that I am using Windows, but actually I can't use Linux and furthemore I don't see any reasons why it shouldn't work on Windows.
I also had a look also to the code which is on ?image_darknet_model , and it's just like mine.

after struggling so long, I decided to install linux and magically it worked, so the code was not wrong. No idea about the reasons why it happens, but that is
By the way thanks for your help!