Computer Vision Object Detection in R with YOLO Pre-trained Models
[This article was first published on r-bloggers on Programming with R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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)
To leave a comment for the author, please follow the link and comment on their blog: r-bloggers on Programming with R.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.