1// Copyright 2021 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17package google.cloud.automl.v1;
18
19import "google/api/annotations.proto";
20import "google/api/client.proto";
21import "google/api/field_behavior.proto";
22import "google/api/resource.proto";
23import "google/cloud/automl/v1/annotation_payload.proto";
24import "google/cloud/automl/v1/data_items.proto";
25import "google/cloud/automl/v1/io.proto";
26import "google/longrunning/operations.proto";
27
28option csharp_namespace = "Google.Cloud.AutoML.V1";
29option go_package = "cloud.google.com/go/automl/apiv1/automlpb;automlpb";
30option java_multiple_files = true;
31option java_outer_classname = "PredictionServiceProto";
32option java_package = "com.google.cloud.automl.v1";
33option php_namespace = "Google\\Cloud\\AutoMl\\V1";
34option ruby_package = "Google::Cloud::AutoML::V1";
35
36// AutoML Prediction API.
37//
38// On any input that is documented to expect a string parameter in
39// snake_case or dash-case, either of those cases is accepted.
40service PredictionService {
41  option (google.api.default_host) = "automl.googleapis.com";
42  option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
43
44  // Perform an online prediction. The prediction result is directly
45  // returned in the response.
46  // Available for following ML scenarios, and their expected request payloads:
47  //
48  // AutoML Vision Classification
49  //
50  // * An image in .JPEG, .GIF or .PNG format, image_bytes up to 30MB.
51  //
52  // AutoML Vision Object Detection
53  //
54  // * An image in .JPEG, .GIF or .PNG format, image_bytes up to 30MB.
55  //
56  // AutoML Natural Language Classification
57  //
58  // * A TextSnippet up to 60,000 characters, UTF-8 encoded or a document in
59  // .PDF, .TIF or .TIFF format with size upto 2MB.
60  //
61  // AutoML Natural Language Entity Extraction
62  //
63  // * A TextSnippet up to 10,000 characters, UTF-8 NFC encoded or a document
64  //  in .PDF, .TIF or .TIFF format with size upto 20MB.
65  //
66  // AutoML Natural Language Sentiment Analysis
67  //
68  // * A TextSnippet up to 60,000 characters, UTF-8 encoded or a document in
69  // .PDF, .TIF or .TIFF format with size upto 2MB.
70  //
71  // AutoML Translation
72  //
73  // * A TextSnippet up to 25,000 characters, UTF-8 encoded.
74  //
75  // AutoML Tables
76  //
77  // * A row with column values matching
78  //   the columns of the model, up to 5MB. Not available for FORECASTING
79  //   `prediction_type`.
80  rpc Predict(PredictRequest) returns (PredictResponse) {
81    option (google.api.http) = {
82      post: "/v1/{name=projects/*/locations/*/models/*}:predict"
83      body: "*"
84    };
85    option (google.api.method_signature) = "name,payload,params";
86  }
87
88  // Perform a batch prediction. Unlike the online [Predict][google.cloud.automl.v1.PredictionService.Predict], batch
89  // prediction result won't be immediately available in the response. Instead,
90  // a long running operation object is returned. User can poll the operation
91  // result via [GetOperation][google.longrunning.Operations.GetOperation]
92  // method. Once the operation is done, [BatchPredictResult][google.cloud.automl.v1.BatchPredictResult] is returned in
93  // the [response][google.longrunning.Operation.response] field.
94  // Available for following ML scenarios:
95  //
96  // * AutoML Vision Classification
97  // * AutoML Vision Object Detection
98  // * AutoML Video Intelligence Classification
99  // * AutoML Video Intelligence Object Tracking * AutoML Natural Language Classification
100  // * AutoML Natural Language Entity Extraction
101  // * AutoML Natural Language Sentiment Analysis
102  // * AutoML Tables
103  rpc BatchPredict(BatchPredictRequest) returns (google.longrunning.Operation) {
104    option (google.api.http) = {
105      post: "/v1/{name=projects/*/locations/*/models/*}:batchPredict"
106      body: "*"
107    };
108    option (google.api.method_signature) = "name,input_config,output_config,params";
109    option (google.longrunning.operation_info) = {
110      response_type: "BatchPredictResult"
111      metadata_type: "OperationMetadata"
112    };
113  }
114}
115
116// Request message for [PredictionService.Predict][google.cloud.automl.v1.PredictionService.Predict].
117message PredictRequest {
118  // Required. Name of the model requested to serve the prediction.
119  string name = 1 [
120    (google.api.field_behavior) = REQUIRED,
121    (google.api.resource_reference) = {
122      type: "automl.googleapis.com/Model"
123    }
124  ];
125
126  // Required. Payload to perform a prediction on. The payload must match the
127  // problem type that the model was trained to solve.
128  ExamplePayload payload = 2 [(google.api.field_behavior) = REQUIRED];
129
130  // Additional domain-specific parameters, any string must be up to 25000
131  // characters long.
132  //
133  // AutoML Vision Classification
134  //
135  // `score_threshold`
136  // : (float) A value from 0.0 to 1.0. When the model
137  //   makes predictions for an image, it will only produce results that have
138  //   at least this confidence score. The default is 0.5.
139  //
140  // AutoML Vision Object Detection
141  //
142  // `score_threshold`
143  // : (float) When Model detects objects on the image,
144  //   it will only produce bounding boxes which have at least this
145  //   confidence score. Value in 0 to 1 range, default is 0.5.
146  //
147  // `max_bounding_box_count`
148  // : (int64) The maximum number of bounding
149  //   boxes returned. The default is 100. The
150  //   number of returned bounding boxes might be limited by the server.
151  //
152  // AutoML Tables
153  //
154  // `feature_importance`
155  // : (boolean) Whether
156  // [feature_importance][google.cloud.automl.v1.TablesModelColumnInfo.feature_importance]
157  //   is populated in the returned list of
158  //   [TablesAnnotation][google.cloud.automl.v1.TablesAnnotation]
159  //   objects. The default is false.
160  map<string, string> params = 3;
161}
162
163// Response message for [PredictionService.Predict][google.cloud.automl.v1.PredictionService.Predict].
164message PredictResponse {
165  // Prediction result.
166  // AutoML Translation and AutoML Natural Language Sentiment Analysis
167  // return precisely one payload.
168  repeated AnnotationPayload payload = 1;
169
170  // The preprocessed example that AutoML actually makes prediction on.
171  // Empty if AutoML does not preprocess the input example.
172  //
173  // For AutoML Natural Language (Classification, Entity Extraction, and
174  // Sentiment Analysis), if the input is a document, the recognized text is
175  // returned in the
176  // [document_text][google.cloud.automl.v1.Document.document_text]
177  // property.
178  ExamplePayload preprocessed_input = 3;
179
180  // Additional domain-specific prediction response metadata.
181  //
182  // AutoML Vision Object Detection
183  //
184  // `max_bounding_box_count`
185  // : (int64) The maximum number of bounding boxes to return per image.
186  //
187  // AutoML Natural Language Sentiment Analysis
188  //
189  // `sentiment_score`
190  // : (float, deprecated) A value between -1 and 1,
191  //   -1 maps to least positive sentiment, while 1 maps to the most positive
192  //   one and the higher the score, the more positive the sentiment in the
193  //   document is. Yet these values are relative to the training data, so
194  //   e.g. if all data was positive then -1 is also positive (though
195  //   the least).
196  //   `sentiment_score` is not the same as "score" and "magnitude"
197  //   from Sentiment Analysis in the Natural Language API.
198  map<string, string> metadata = 2;
199}
200
201// Request message for [PredictionService.BatchPredict][google.cloud.automl.v1.PredictionService.BatchPredict].
202message BatchPredictRequest {
203  // Required. Name of the model requested to serve the batch prediction.
204  string name = 1 [
205    (google.api.field_behavior) = REQUIRED,
206    (google.api.resource_reference) = {
207      type: "automl.googleapis.com/Model"
208    }
209  ];
210
211  // Required. The input configuration for batch prediction.
212  BatchPredictInputConfig input_config = 3 [(google.api.field_behavior) = REQUIRED];
213
214  // Required. The Configuration specifying where output predictions should
215  // be written.
216  BatchPredictOutputConfig output_config = 4 [(google.api.field_behavior) = REQUIRED];
217
218  // Additional domain-specific parameters for the predictions, any string must
219  // be up to 25000 characters long.
220  //
221  // AutoML Natural Language Classification
222  //
223  // `score_threshold`
224  // : (float) A value from 0.0 to 1.0. When the model
225  //   makes predictions for a text snippet, it will only produce results
226  //   that have at least this confidence score. The default is 0.5.
227  //
228  //
229  // AutoML Vision Classification
230  //
231  // `score_threshold`
232  // : (float) A value from 0.0 to 1.0. When the model
233  //   makes predictions for an image, it will only produce results that
234  //   have at least this confidence score. The default is 0.5.
235  //
236  // AutoML Vision Object Detection
237  //
238  // `score_threshold`
239  // : (float) When Model detects objects on the image,
240  //   it will only produce bounding boxes which have at least this
241  //   confidence score. Value in 0 to 1 range, default is 0.5.
242  //
243  // `max_bounding_box_count`
244  // : (int64) The maximum number of bounding
245  //   boxes returned per image. The default is 100, the
246  //   number of bounding boxes returned might be limited by the server.
247  // AutoML Video Intelligence Classification
248  //
249  // `score_threshold`
250  // : (float) A value from 0.0 to 1.0. When the model
251  //   makes predictions for a video, it will only produce results that
252  //   have at least this confidence score. The default is 0.5.
253  //
254  // `segment_classification`
255  // : (boolean) Set to true to request
256  //   segment-level classification. AutoML Video Intelligence returns
257  //   labels and their confidence scores for the entire segment of the
258  //   video that user specified in the request configuration.
259  //   The default is true.
260  //
261  // `shot_classification`
262  // : (boolean) Set to true to request shot-level
263  //   classification. AutoML Video Intelligence determines the boundaries
264  //   for each camera shot in the entire segment of the video that user
265  //   specified in the request configuration. AutoML Video Intelligence
266  //   then returns labels and their confidence scores for each detected
267  //   shot, along with the start and end time of the shot.
268  //   The default is false.
269  //
270  //   WARNING: Model evaluation is not done for this classification type,
271  //   the quality of it depends on training data, but there are no metrics
272  //   provided to describe that quality.
273  //
274  // `1s_interval_classification`
275  // : (boolean) Set to true to request
276  //   classification for a video at one-second intervals. AutoML Video
277  //   Intelligence returns labels and their confidence scores for each
278  //   second of the entire segment of the video that user specified in the
279  //   request configuration. The default is false.
280  //
281  //   WARNING: Model evaluation is not done for this classification
282  //   type, the quality of it depends on training data, but there are no
283  //   metrics provided to describe that quality.
284  //
285  // AutoML Video Intelligence Object Tracking
286  //
287  // `score_threshold`
288  // : (float) When Model detects objects on video frames,
289  //   it will only produce bounding boxes which have at least this
290  //   confidence score. Value in 0 to 1 range, default is 0.5.
291  //
292  // `max_bounding_box_count`
293  // : (int64) The maximum number of bounding
294  //   boxes returned per image. The default is 100, the
295  //   number of bounding boxes returned might be limited by the server.
296  //
297  // `min_bounding_box_size`
298  // : (float) Only bounding boxes with shortest edge
299  //   at least that long as a relative value of video frame size are
300  //   returned. Value in 0 to 1 range. Default is 0.
301  //
302  map<string, string> params = 5;
303}
304
305// Result of the Batch Predict. This message is returned in
306// [response][google.longrunning.Operation.response] of the operation returned
307// by the [PredictionService.BatchPredict][google.cloud.automl.v1.PredictionService.BatchPredict].
308message BatchPredictResult {
309  // Additional domain-specific prediction response metadata.
310  //
311  // AutoML Vision Object Detection
312  //
313  // `max_bounding_box_count`
314  // : (int64) The maximum number of bounding boxes returned per image.
315  //
316  // AutoML Video Intelligence Object Tracking
317  //
318  // `max_bounding_box_count`
319  // : (int64) The maximum number of bounding boxes returned per frame.
320  map<string, string> metadata = 1;
321}
322