image_darknet_classify {image.darknet}R Documentation

Image classification with deep learning models AlexNet, Darknet, VGG-16, Extraction (GoogleNet) and Darknet19

Description

Image classification with deep learning models AlexNet, Darknet, VGG-16, Extraction (GoogleNet) and Darknet19.

Usage

image_darknet_classify(file, object, top = 5L)

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

top

integer indicating to return the top classifications only. Defaults to 5.

Value

a list with elements

See Also

image_darknet_model

Examples

##
## Define the model
##
model <- system.file(package="image.darknet", "include", "darknet", "cfg", "tiny.cfg")
weights <- system.file(package="image.darknet", "models", "tiny.weights")
f <- system.file(package="image.darknet", "include", "darknet", "data", "imagenet.shortnames.list")
labels <- readLines(f)
darknet_tiny <- image_darknet_model(type = 'classify', 
                                    model = model, weights = weights, labels = labels)

##
## Classify new images alongside the model
##
f <- system.file("include", "darknet", "data", "dog.jpg", package="image.darknet")
x <- image_darknet_classify(file = f, object = darknet_tiny)
x

f <- system.file("include", "darknet", "data", "eagle.jpg", package="image.darknet")
image_darknet_classify(file = f, object = darknet_tiny)

## Not run: 
## For other models, see ?image_darknet_model

## darknet19
weights <- file.path(system.file(package="image.darknet", "models"), "darknet19.weights")
download.file(url = "http://pjreddie.com/media/files/darknet19.weights", destfile = weights)
model <- system.file(package="image.darknet", "include", "darknet", "cfg", "darknet19.cfg")

darknet19 <- image_darknet_model(type = 'classify', 
                                 model = model, weights = weights, labels = labels)
image_darknet_classify(file = f, object = darknet19)

## End(Not run)

[Package image.darknet version 0.1.0 Index]