Session Crash
keithhurley opened this issue · 9 comments
I have been trying to use the image.darknet library as part of a looping process to process multiple files. It appears that doing so causes a crash of the R session. It happens using a fresh download of the library on multiple computers. On each computer, the crash consistantly happens, but happens at a different number of images. For example, on one computer the R session crashes on processing the fourth file. On another, it is always after the 18th file. This happens if the detect is called as part of a loop, a foreach package loop, or just a run-on of detect calls in the script. Here is a reproducible example that works on any computer I seem to run it on.
`
devtools::install_github("bnosac/image", subdir = "image.darknet", build_vignettes = TRUE)
library(image.darknet)
labels<-system.file(package="image.darknet", "include", "darknet", "data", "voc.names")
labels<-readLines(labels)
yolo_tiny_voc<-image_darknet_model(
type="detect",
model="tiny-yolo-voc.cfg",
weights=system.file(package="image.darknet", "models", "tiny-yolo-voc.weights"),
labels=labels)
f <- system.file("include", "darknet", "data", "dog.jpg", package="image.darknet")
for (i in 1:50){
print(i)
image_darknet_detect(file=f, object=yolo_tiny_voc, threshold=0.03)
}
`
Hi @keithhurley,
I can reproduce your problem. I think it is the cache running full. Using the system monitor, you can see an increment being loaded every iteration. As soon as the hardware limitations are exceeded, the R session dies.
@jwijffels do you have an idea how to fix this? I'm working on a pull request coming up for you, including the latest YOLO version and models. However, as the increment is proportional to size of the network, deploying yolov3.weights (248MB) reaches the hardware limitations very fast.
I guess it has something to do with freeing up some variables before returning the number of detected objects into R, but can not tell exactly, as I am not into C.. Simply calling gc()
in R does not have any effect...
Till this issue is closed, restarting the R session is the only option to free up your system resources again.
Thank you very much,
best xmas wishes!
I can confirm the issue. I'll normally work on this in February as I need the function in March for a client. If you have a pull request on yolo v3, would be great!
Hi @jwijffels: As I understand C pointers a little more. Isn't it possible to return the pointer of the cached network with image_darknet_model()
(i.e. in a list slot)? Then image_darknet_detect()
could reload the network. In that case deploying yolo on a list of images (e.g. with lapply)
would be much faster, too. Right?
Best wishes, Jeroen
Hi,
unfortunately I can confirm the the bug is still here. I am using a MacBook Pro (2016) but the session crashes as soon as I lunch the function image_darknet_detect()
. The code is the following:
library( image.darknet )
yolo_tiny_voc <- image_darknet_model( type = "detect",
model = "tiny-yolo-voc.cfg",
weights = system.file( package = "image.darknet",
"models",
"tiny-yolo-voc.weights" ),
labels = system.file( package = "image.darknet",
"include", "darknet",
"data", "voc.names" ) )
Here it crashes and there is nothing I can do about it!
x <- image_darknet_detect( file = "~/Downloads/Baker_Street.jpg",
object = yolo_tiny_voc,
threshold = 0.19 )
This is the current session:
> sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.2
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] image.darknet_0.1.0
loaded via a namespace (and not attached):
[1] compiler_3.5.2 tools_3.5.2
Any suggestions from the authors on how to solve this?
Thanks
I'm going to look into it at the end of March.
Hi !
Any news ? I can't open yolov3.weights too
I was having the same problem and it seems that image_darknet_detect
does not understand the ~
folder. So I changed to
x <- image_darknet_detect(file = "/Users/myuser/Downloads/car.png", object = yolo_tiny_voc, threshold = 0.19)
and it works
I was having the same problem and it seems that
image_darknet_detect
does not understand the~
folder. So I changed to
x <- image_darknet_detect(file = "/Users/myuser/Downloads/car.png", object = yolo_tiny_voc, threshold = 0.19)
and it works
it works