In this R Tutorial, We’ll learn how to perform a very popular Computer Vision task which is Object Detection in R with YOLO (pre-trained Models). For this we’re going to use the image.darknet
package from https://github.com/bnosac. The good thing about this package is that it doesn’t require neither reticulate nor Python. It’s ported from the native C
code and hence the performance is good.
Video Walkthrough
Please Subscribe to the channel for more Data Science (with R) videos
Code
#devtools::install_github("bnosac/image", subdir = "image.darknet", build_vignettes = TRUE)
library(image.darknet)
#If required, Set new working directory where the final predictions imaged with bounding box will be saved
#setwd(paste0(getwd(),"/projects/"))
#Define Model - here it is Tiny Yolo
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"))
#Image Detection
x <- image_darknet_detect(file = "tinyyolo_in_R/google-car.png",
object = yolo_tiny_voc,
threshold = 0.19)