Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
predict doc
Browse files Browse the repository at this point in the history
  • Loading branch information
hongooi73 committed Oct 8, 2019
1 parent 224d124 commit a30bcd5
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 2 deletions.
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ S3method(delete_customvision_project,customvision_project)
S3method(delete_customvision_project,customvision_training_endpoint)
S3method(delete_model,customvision_model)
S3method(delete_model,customvision_project)
S3method(predict,classification_service)
S3method(predict,customvision_model)
S3method(predict,object_detection_service)
S3method(print,customvision_model)
S3method(print,customvision_project)
S3method(summary,customvision_model)
Expand All @@ -17,6 +20,7 @@ export(analyze)
export(area_of_interest)
export(call_cognitive_endpoint)
export(categorize)
export(classification_service)
export(cognitive_endpoint)
export(computervision_endpoint)
export(create_classification_project)
Expand All @@ -38,6 +42,7 @@ export(list_images)
export(list_models)
export(list_tags)
export(make_thumbnail)
export(object_detection_service)
export(publish_model)
export(read_text)
export(remove_images)
Expand Down
43 changes: 43 additions & 0 deletions R/customvision_predict.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
#' Get predictions from a Custom Vision model
#'
#' @param object A Custom Vision object from which to get predictions. See 'Details' below.
#' @param images The images for which to get predictions.
#' @param type The type of prediction: either class membership (the default), the class probabilities, or a list containing all information returned by the prediction endpoint.
#' @param save_result For the predictive service methods, whether to store the predictions on the server for future use.
#' @param ... Further arguments passed to lower-level functions; not used.
#' @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:
#' - 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.
#' @seealso
#' [`train_model`], [`publish_model`], [`classification_service`], [`object_detection_service`]
#' @aliases predict
#' @rdname customvision_predict
#' @export
predict.customvision_model <- function(object, images, type=c("class", "prob", "list"), ...)
{
type <- match.arg(type)
Expand All @@ -16,13 +35,17 @@ predict.customvision_model <- function(object, images, type=c("class", "prob", "
}


#' @rdname customvision_predict
#' @export
predict.classification_service <- function(object, images, type=c("class", "prob", "list"), save_result=FALSE, ...)
{
type <- match.arg(type)
customvision_predict_internal(object, images, type, save_result, verb="classify")
}


#' @rdname customvision_predict
#' @export
predict.object_detection_service <- function(object, images, type=c("class", "prob", "list"), save_result=FALSE, ...)
{
type <- match.arg(type)
Expand All @@ -48,6 +71,24 @@ customvision_predict_internal <- function(object, images, type, save_result, ver
}


#' Connect to a Custom Vision predictive service
#'
#' @param endpoint A prediction endpoint object, of class `customvision_prediction_endpoint`.
#' @param project The project underlying this predictive service. Can be either an object of class `customvision_project`, or a string giving the ID of the project.
#' @param name The published name of the service.
#' @details
#' These functions are handles to a predictive service that was previously published from a trained model. They have `predict` methods defined for them.
#' @return
#' An object of class `classification_service` or `object_detection_service`, as appropriate. These are subclasses of `customvision_predictive_service`.
#' @seealso
#' [`customvision_prediction_endpoint`], [`customvision_project`]
#'
#' [`predict.classification_service`], [`predict.object_detection_service`]
#'
#' [`train_model`], [`publish_model`]
#' @aliases customvision_predictive_service
#' @rdname customvision_predictive_service
#' @export
classification_service <- function(endpoint, project, name)
{
if(inherits(project, "classification_project"))
Expand All @@ -62,6 +103,8 @@ classification_service <- function(endpoint, project, name)
}


#' @rdname customvision_predictive_service
#' @export
object_detection_service <- function(endpoint, project, name)
{
if(inherits(project, "object_detection_project"))
Expand Down
2 changes: 1 addition & 1 deletion R/customvision_training.R
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ summary.customvision_model <- function(object, ...)
#' @details
#' Publishing a model makes it available to clients as a predictive service. Each iteration of the model can be published separately.
#' @seealso
#' [`train_model`], [`get_model`]
#' [`train_model`], [`get_model`], [`customvision_predictive_service`], [`predict.classification_service`], [`predict.object_detection_service`]
#' @rdname customvision_publish
#' @export
publish_model <- function(model, name, prediction_resource)
Expand Down
45 changes: 45 additions & 0 deletions man/customvision_predict.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions man/customvision_predictive_service.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/customvision_publish.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a30bcd5

Please sign in to comment.