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