Description Usage Arguments Details See Also Examples
Get predictions from a Custom Vision model
1 2 3 4 5 6 7 8 9 10 | ## S3 method for class 'customvision_model'
predict(object, images, type = c("class", "prob", "list"), ...)
## S3 method for class 'classification_service'
predict(object, images, type = c("class",
"prob", "list"), save_result = FALSE, ...)
## S3 method for class 'object_detection_service'
predict(object, images, type = c("class",
"prob", "list"), save_result = FALSE, ...)
|
object |
A Custom Vision object from which to get predictions. See 'Details' below. |
images |
The images for which to get predictions. |
type |
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. |
save_result |
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## 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")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.