Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session Crash #7

Open
keithhurley opened this issue Jan 11, 2018 · 9 comments
Open

Session Crash #7

keithhurley opened this issue Jan 11, 2018 · 9 comments

Comments

@keithhurley
Copy link

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)
}
`

@georoen
Copy link

georoen commented Dec 25, 2018

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!

@jwijffels
Copy link
Contributor

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!

@georoen
Copy link

georoen commented Dec 29, 2018

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

@contefranz
Copy link

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 )

screen shot 2019-02-21 at 12 34 28

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

@jwijffels
Copy link
Contributor

I'm going to look into it at the end of March.

@Gasp34
Copy link

Gasp34 commented Sep 19, 2019

Hi !
Any news ? I can't open yolov3.weights too

@georoen
Copy link

georoen commented Sep 20, 2019

Hi @Gasp34,

If you want to experiment with yolov3.weights you can check out my pull-request #10.

It however does not fix this issue #7, which is due insufficient ram management.

Best

@emoro
Copy link

emoro commented Jan 29, 2021

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

@mishahublog
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants