image_darknet_detect {image.darknet}R Documentation

Object detection with YOLO v2 (You only look once)

Description

Object detection with YOLO v2 (You only look once)

Usage

image_darknet_detect(file, object, threshold = 0.3, hier_threshold = 0.5)

Arguments

file

character string with the full path to the image file

object

an object of class darknet_model as returned by image_darknet_model

threshold

numeric, detection threshold

hier_threshold

numeric, detection threshold

Value

invisible(), a file called predictions.png is created in the working directory showing the objects found

References

https://pjreddie.com/publications

See Also

image_darknet_model

Examples

##
## 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)

[Package image.darknet version 0.1.0 Index]