
Last chance! 50% off unlimited learning
Sale ends in
Get predictions from a Custom Vision model
# S3 method for customvision_model
predict(object, images, type = c("class", "prob", "list"), ...)# S3 method for classification_service
predict(object, images, type = c("class",
"prob", "list"), save_result = FALSE, ...)
# S3 method for object_detection_service
predict(object, images, type = c("class",
"prob", "list"), save_result = FALSE, ...)
A Custom Vision object from which to get predictions. See 'Details' below.
The images for which to get predictions.
The type of prediction: either class membership (the default), the class probabilities, or a list containing all information returned by the prediction endpoint.
Further arguments passed to lower-level functions; not used.
For the predictive service methods, whether to store the predictions on the server for future use.
AzureVision defines prediction methods for both Custom Vision model training objects (of class customvision_model
) and prediction services (classification_service
and object_detection_service
). The method for model training objects calls the "quick test" endpoint, and is meant only for testing purposes.
The prediction endpoints accept a single image per request, so supplying multiple images to these functions will call the endpoints multiple times, in sequence. The images can be specified as:
A vector of local filenames. All common image file formats are supported.
A vector of publicly accessible URLs.
A raw vector, or a list of raw vectors, holding the binary contents of the image files.
train_model
, publish_model
, classification_service
, object_detection_service
# NOT RUN {
# predicting with the training endpoint
endp <- customvision_training_endpoint(url="endpoint_url", key="key")
myproj <- get_project(endp, "myproject")
mod <- get_model(myproj)
predict(mod, "testimage.jpg")
predict(mod, "https://mysite.example.com/testimage.jpg", type="prob")
imgraw <- readBin("testimage.jpg", "raw", file.size("testimage.jpg"))
predict(mod, imgraw, type="list")
# predicting with the prediction endpoint
# you'll need either the project object or the ID
proj_id <- myproj$project$id
pred_endp <- customvision_prediction_endpoint(url="endpoint_url", key="pred_key")
pred_svc <- classification_service(pred_endp, proj_id, "iteration1")
predict(pred_svc, "testimage.jpg")
# }
Run the code above in your browser using DataLab