customvision_predict: Get predictions from a Custom Vision model

Description Usage Arguments Details See Also Examples

Description

Get predictions from a Custom Vision model

Usage

 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, ...)

Arguments

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.

Details

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:

See Also

train_model, publish_model, classification_service, object_detection_service

Examples

 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)

AzureVision documentation built on Jan. 13, 2021, 5:05 a.m.