Constructor
new PredictionServiceClient(optionsopt, gaxInstanceopt)
Construct an instance of PredictionServiceClient.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
The configuration object. The options accepted by the constructor are described in detail in this document. The common options are: Properties
|
||||||||||||||||||||||||||||||||||||||||||||||||
gaxInstance |
gax |
<optional> |
loaded instance of |
Members
apiEndpoint
The DNS address for this API service - same as servicePath(), exists for compatibility reasons.
port
The port for this API service.
scopes
The scopes needed to make gRPC calls for every method defined in this service.
servicePath
The DNS address for this API service.
Methods
annotationSpecPath(project, location, dataset, annotation_spec) → {string}
Return a fully-qualified annotationSpec resource name string.
Parameters:
Name | Type | Description |
---|---|---|
project |
string | |
location |
string | |
dataset |
string | |
annotation_spec |
string |
Returns:
Type | Description |
---|---|
string |
Resource name string. |
(async) checkBatchPredictProgress(name) → {Promise}
Check the status of the long running operation returned by batchPredict()
.
Parameters:
Name | Type | Description |
---|---|---|
name |
String |
The operation name that will be passed. |
Returns:
Type | Description |
---|---|
Promise |
|
Example
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Name of the model requested to serve the batch prediction.
*/
// const name = 'abc123'
/**
* Required. The input configuration for batch prediction.
*/
// const inputConfig = {}
/**
* Required. The Configuration specifying where output predictions should
* be written.
*/
// const outputConfig = {}
/**
* Additional domain-specific parameters for the predictions, any string must
* be up to 25000 characters long.
* AutoML Natural Language Classification
* `score_threshold`
* : (float) A value from 0.0 to 1.0. When the model
* makes predictions for a text snippet, it will only produce results
* that have at least this confidence score. The default is 0.5.
* AutoML Vision Classification
* `score_threshold`
* : (float) A value from 0.0 to 1.0. When the model
* makes predictions for an image, it will only produce results that
* have at least this confidence score. The default is 0.5.
* AutoML Vision Object Detection
* `score_threshold`
* : (float) When Model detects objects on the image,
* it will only produce bounding boxes which have at least this
* confidence score. Value in 0 to 1 range, default is 0.5.
* `max_bounding_box_count`
* : (int64) The maximum number of bounding
* boxes returned per image. The default is 100, the
* number of bounding boxes returned might be limited by the server.
* AutoML Video Intelligence Classification
* `score_threshold`
* : (float) A value from 0.0 to 1.0. When the model
* makes predictions for a video, it will only produce results that
* have at least this confidence score. The default is 0.5.
* `segment_classification`
* : (boolean) Set to true to request
* segment-level classification. AutoML Video Intelligence returns
* labels and their confidence scores for the entire segment of the
* video that user specified in the request configuration.
* The default is true.
* `shot_classification`
* : (boolean) Set to true to request shot-level
* classification. AutoML Video Intelligence determines the boundaries
* for each camera shot in the entire segment of the video that user
* specified in the request configuration. AutoML Video Intelligence
* then returns labels and their confidence scores for each detected
* shot, along with the start and end time of the shot.
* The default is false.
* WARNING: Model evaluation is not done for this classification type,
* the quality of it depends on training data, but there are no metrics
* provided to describe that quality.
* `1s_interval_classification`
* : (boolean) Set to true to request
* classification for a video at one-second intervals. AutoML Video
* Intelligence returns labels and their confidence scores for each
* second of the entire segment of the video that user specified in the
* request configuration. The default is false.
* WARNING: Model evaluation is not done for this classification
* type, the quality of it depends on training data, but there are no
* metrics provided to describe that quality.
* AutoML Video Intelligence Object Tracking
* `score_threshold`
* : (float) When Model detects objects on video frames,
* it will only produce bounding boxes which have at least this
* confidence score. Value in 0 to 1 range, default is 0.5.
* `max_bounding_box_count`
* : (int64) The maximum number of bounding
* boxes returned per image. The default is 100, the
* number of bounding boxes returned might be limited by the server.
* `min_bounding_box_size`
* : (float) Only bounding boxes with shortest edge
* at least that long as a relative value of video frame size are
* returned. Value in 0 to 1 range. Default is 0.
*/
// const params = [1,2,3,4]
// Imports the Automl library
const {PredictionServiceClient} = require('@google-cloud/automl').v1;
// Instantiates a client
const automlClient = new PredictionServiceClient();
async function callBatchPredict() {
// Construct request
const request = {
name,
inputConfig,
outputConfig,
};
// Run request
const [operation] = await automlClient.batchPredict(request);
const [response] = await operation.promise();
console.log(response);
}
callBatchPredict();
close() → {Promise}
Terminate the gRPC channel and close the client.
The client will no longer be usable and all future behavior is undefined.
Returns:
Type | Description |
---|---|
Promise |
A promise that resolves when the client is closed. |
datasetPath(project, location, dataset) → {string}
Return a fully-qualified dataset resource name string.
Parameters:
Name | Type | Description |
---|---|---|
project |
string | |
location |
string | |
dataset |
string |
Returns:
Type | Description |
---|---|
string |
Resource name string. |
getProjectId() → {Promise}
Return the project ID used by this class.
Returns:
Type | Description |
---|---|
Promise |
A promise that resolves to string containing the project ID. |
initialize() → {Promise}
Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.
You can await on this method if you want to make sure the client is initialized.
Returns:
Type | Description |
---|---|
Promise |
A promise that resolves to an authenticated service stub. |
matchAnnotationSpecFromAnnotationSpecName(annotationSpecName) → {string}
Parse the annotation_spec from AnnotationSpec resource.
Parameters:
Name | Type | Description |
---|---|---|
annotationSpecName |
string |
A fully-qualified path representing AnnotationSpec resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the annotation_spec. |
matchDatasetFromAnnotationSpecName(annotationSpecName) → {string}
Parse the dataset from AnnotationSpec resource.
Parameters:
Name | Type | Description |
---|---|---|
annotationSpecName |
string |
A fully-qualified path representing AnnotationSpec resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the dataset. |
matchDatasetFromDatasetName(datasetName) → {string}
Parse the dataset from Dataset resource.
Parameters:
Name | Type | Description |
---|---|---|
datasetName |
string |
A fully-qualified path representing Dataset resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the dataset. |
matchLocationFromAnnotationSpecName(annotationSpecName) → {string}
Parse the location from AnnotationSpec resource.
Parameters:
Name | Type | Description |
---|---|---|
annotationSpecName |
string |
A fully-qualified path representing AnnotationSpec resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the location. |
matchLocationFromDatasetName(datasetName) → {string}
Parse the location from Dataset resource.
Parameters:
Name | Type | Description |
---|---|---|
datasetName |
string |
A fully-qualified path representing Dataset resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the location. |
matchLocationFromModelEvaluationName(modelEvaluationName) → {string}
Parse the location from ModelEvaluation resource.
Parameters:
Name | Type | Description |
---|---|---|
modelEvaluationName |
string |
A fully-qualified path representing ModelEvaluation resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the location. |
matchLocationFromModelName(modelName) → {string}
Parse the location from Model resource.
Parameters:
Name | Type | Description |
---|---|---|
modelName |
string |
A fully-qualified path representing Model resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the location. |
matchModelEvaluationFromModelEvaluationName(modelEvaluationName) → {string}
Parse the model_evaluation from ModelEvaluation resource.
Parameters:
Name | Type | Description |
---|---|---|
modelEvaluationName |
string |
A fully-qualified path representing ModelEvaluation resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the model_evaluation. |
matchModelFromModelEvaluationName(modelEvaluationName) → {string}
Parse the model from ModelEvaluation resource.
Parameters:
Name | Type | Description |
---|---|---|
modelEvaluationName |
string |
A fully-qualified path representing ModelEvaluation resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the model. |
matchModelFromModelName(modelName) → {string}
Parse the model from Model resource.
Parameters:
Name | Type | Description |
---|---|---|
modelName |
string |
A fully-qualified path representing Model resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the model. |
matchProjectFromAnnotationSpecName(annotationSpecName) → {string}
Parse the project from AnnotationSpec resource.
Parameters:
Name | Type | Description |
---|---|---|
annotationSpecName |
string |
A fully-qualified path representing AnnotationSpec resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the project. |
matchProjectFromDatasetName(datasetName) → {string}
Parse the project from Dataset resource.
Parameters:
Name | Type | Description |
---|---|---|
datasetName |
string |
A fully-qualified path representing Dataset resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the project. |
matchProjectFromModelEvaluationName(modelEvaluationName) → {string}
Parse the project from ModelEvaluation resource.
Parameters:
Name | Type | Description |
---|---|---|
modelEvaluationName |
string |
A fully-qualified path representing ModelEvaluation resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the project. |
matchProjectFromModelName(modelName) → {string}
Parse the project from Model resource.
Parameters:
Name | Type | Description |
---|---|---|
modelName |
string |
A fully-qualified path representing Model resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the project. |
modelEvaluationPath(project, location, model, model_evaluation) → {string}
Return a fully-qualified modelEvaluation resource name string.
Parameters:
Name | Type | Description |
---|---|---|
project |
string | |
location |
string | |
model |
string | |
model_evaluation |
string |
Returns:
Type | Description |
---|---|
string |
Resource name string. |
modelPath(project, location, model) → {string}
Return a fully-qualified model resource name string.
Parameters:
Name | Type | Description |
---|---|---|
project |
string | |
location |
string | |
model |
string |
Returns:
Type | Description |
---|---|
string |
Resource name string. |