image_darknet_detect {image.darknet} | R Documentation |
Object detection with YOLO v2 (You only look once)
image_darknet_detect(file, object, threshold = 0.3, hier_threshold = 0.5)
file |
character string with the full path to the image file |
object |
an object of class |
threshold |
numeric, detection threshold |
hier_threshold |
numeric, detection threshold |
invisible(), a file called predictions.png is created in the working directory showing the objects found
https://pjreddie.com/publications
## ## Define the model ## 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")) yolo_tiny_voc ## ## Find objects inside the image ## f <- system.file("include", "darknet", "data", "dog.jpg", package="image.darknet") x <- image_darknet_detect(file = f, object = yolo_tiny_voc) ## Not run: ## For other models, see ?image_darknet_model ## trained on COCO weights <- file.path(system.file(package="image.darknet", "models"), "yolo.weights") download.file(url = "http://pjreddie.com/media/files/yolo.weights", destfile = weights) yolo_coco <- image_darknet_model(type = 'detect', model = "yolo.cfg", weights = system.file(package="image.darknet", "models", "yolo.weights"), labels = system.file(package="image.darknet", "include", "darknet", "data", "coco.names")) yolo_coco f <- system.file("include", "darknet", "data", "dog.jpg", package="image.darknet") x <- image_darknet_detect(file = f, object = yolo_coco) ## End(Not run)