1// Copyright 2020 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.v1beta1; 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/v1beta1/annotation_payload.proto"; 24import "google/cloud/automl/v1beta1/data_items.proto"; 25import "google/cloud/automl/v1beta1/io.proto"; 26import "google/cloud/automl/v1beta1/operations.proto"; 27import "google/longrunning/operations.proto"; 28 29option go_package = "cloud.google.com/go/automl/apiv1beta1/automlpb;automlpb"; 30option java_multiple_files = true; 31option java_outer_classname = "PredictionServiceProto"; 32option java_package = "com.google.cloud.automl.v1beta1"; 33option php_namespace = "Google\\Cloud\\AutoMl\\V1beta1"; 34option ruby_package = "Google::Cloud::AutoML::V1beta1"; 35 36// AutoML Prediction API. 37// 38// On any input that is documented to expect a string parameter in 39// snake_case or kebab-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 will be directly 45 // returned in the response. 46 // Available for following ML problems, and their expected request payloads: 47 // * Image Classification - Image in .JPEG, .GIF or .PNG format, image_bytes 48 // up to 30MB. 49 // * Image Object Detection - Image in .JPEG, .GIF or .PNG format, image_bytes 50 // up to 30MB. 51 // * Text Classification - TextSnippet, content up to 60,000 characters, 52 // UTF-8 encoded. 53 // * Text Extraction - TextSnippet, content up to 30,000 characters, 54 // UTF-8 NFC encoded. 55 // * Translation - TextSnippet, content up to 25,000 characters, UTF-8 56 // encoded. 57 // * Tables - Row, with column values matching the columns of the model, 58 // up to 5MB. Not available for FORECASTING 59 // 60 // [prediction_type][google.cloud.automl.v1beta1.TablesModelMetadata.prediction_type]. 61 // * Text Sentiment - TextSnippet, content up 500 characters, UTF-8 62 // encoded. 63 rpc Predict(PredictRequest) returns (PredictResponse) { 64 option (google.api.http) = { 65 post: "/v1beta1/{name=projects/*/locations/*/models/*}:predict" 66 body: "*" 67 }; 68 option (google.api.method_signature) = "name,payload,params"; 69 } 70 71 // Perform a batch prediction. Unlike the online [Predict][google.cloud.automl.v1beta1.PredictionService.Predict], batch 72 // prediction result won't be immediately available in the response. Instead, 73 // a long running operation object is returned. User can poll the operation 74 // result via [GetOperation][google.longrunning.Operations.GetOperation] 75 // method. Once the operation is done, [BatchPredictResult][google.cloud.automl.v1beta1.BatchPredictResult] is returned in 76 // the [response][google.longrunning.Operation.response] field. 77 // Available for following ML problems: 78 // * Image Classification 79 // * Image Object Detection 80 // * Video Classification 81 // * Video Object Tracking * Text Extraction 82 // * Tables 83 rpc BatchPredict(BatchPredictRequest) returns (google.longrunning.Operation) { 84 option (google.api.http) = { 85 post: "/v1beta1/{name=projects/*/locations/*/models/*}:batchPredict" 86 body: "*" 87 }; 88 option (google.api.method_signature) = "name,input_config,output_config,params"; 89 option (google.longrunning.operation_info) = { 90 response_type: "BatchPredictResult" 91 metadata_type: "OperationMetadata" 92 }; 93 } 94} 95 96// Request message for [PredictionService.Predict][google.cloud.automl.v1beta1.PredictionService.Predict]. 97message PredictRequest { 98 // Required. Name of the model requested to serve the prediction. 99 string name = 1 [ 100 (google.api.field_behavior) = REQUIRED, 101 (google.api.resource_reference) = { 102 type: "automl.googleapis.com/Model" 103 } 104 ]; 105 106 // Required. Payload to perform a prediction on. The payload must match the 107 // problem type that the model was trained to solve. 108 ExamplePayload payload = 2 [(google.api.field_behavior) = REQUIRED]; 109 110 // Additional domain-specific parameters, any string must be up to 25000 111 // characters long. 112 // 113 // * For Image Classification: 114 // 115 // `score_threshold` - (float) A value from 0.0 to 1.0. When the model 116 // makes predictions for an image, it will only produce results that have 117 // at least this confidence score. The default is 0.5. 118 // 119 // * For Image Object Detection: 120 // `score_threshold` - (float) When Model detects objects on the image, 121 // it will only produce bounding boxes which have at least this 122 // confidence score. Value in 0 to 1 range, default is 0.5. 123 // `max_bounding_box_count` - (int64) No more than this number of bounding 124 // boxes will be returned in the response. Default is 100, the 125 // requested value may be limited by server. 126 // * For Tables: 127 // feature_imp<span>ortan</span>ce - (boolean) Whether feature importance 128 // should be populated in the returned TablesAnnotation. 129 // The default is false. 130 map<string, string> params = 3; 131} 132 133// Response message for [PredictionService.Predict][google.cloud.automl.v1beta1.PredictionService.Predict]. 134message PredictResponse { 135 // Prediction result. 136 // Translation and Text Sentiment will return precisely one payload. 137 repeated AnnotationPayload payload = 1; 138 139 // The preprocessed example that AutoML actually makes prediction on. 140 // Empty if AutoML does not preprocess the input example. 141 // * For Text Extraction: 142 // If the input is a .pdf file, the OCR'ed text will be provided in 143 // [document_text][google.cloud.automl.v1beta1.Document.document_text]. 144 ExamplePayload preprocessed_input = 3; 145 146 // Additional domain-specific prediction response metadata. 147 // 148 // * For Image Object Detection: 149 // `max_bounding_box_count` - (int64) At most that many bounding boxes per 150 // image could have been returned. 151 // 152 // * For Text Sentiment: 153 // `sentiment_score` - (float, deprecated) A value between -1 and 1, 154 // -1 maps to least positive sentiment, while 1 maps to the most positive 155 // one and the higher the score, the more positive the sentiment in the 156 // document is. Yet these values are relative to the training data, so 157 // e.g. if all data was positive then -1 will be also positive (though 158 // the least). 159 // The sentiment_score shouldn't be confused with "score" or "magnitude" 160 // from the previous Natural Language Sentiment Analysis API. 161 map<string, string> metadata = 2; 162} 163 164// Request message for [PredictionService.BatchPredict][google.cloud.automl.v1beta1.PredictionService.BatchPredict]. 165message BatchPredictRequest { 166 // Required. Name of the model requested to serve the batch prediction. 167 string name = 1 [ 168 (google.api.field_behavior) = REQUIRED, 169 (google.api.resource_reference) = { 170 type: "automl.googleapis.com/Model" 171 } 172 ]; 173 174 // Required. The input configuration for batch prediction. 175 BatchPredictInputConfig input_config = 3 [(google.api.field_behavior) = REQUIRED]; 176 177 // Required. The Configuration specifying where output predictions should 178 // be written. 179 BatchPredictOutputConfig output_config = 4 [(google.api.field_behavior) = REQUIRED]; 180 181 // Required. Additional domain-specific parameters for the predictions, any string must 182 // be up to 25000 characters long. 183 // 184 // * For Text Classification: 185 // 186 // `score_threshold` - (float) A value from 0.0 to 1.0. When the model 187 // makes predictions for a text snippet, it will only produce results 188 // that have at least this confidence score. The default is 0.5. 189 // 190 // * For Image Classification: 191 // 192 // `score_threshold` - (float) A value from 0.0 to 1.0. When the model 193 // makes predictions for an image, it will only produce results that 194 // have at least this confidence score. The default is 0.5. 195 // 196 // * For Image Object Detection: 197 // 198 // `score_threshold` - (float) When Model detects objects on the image, 199 // it will only produce bounding boxes which have at least this 200 // confidence score. Value in 0 to 1 range, default is 0.5. 201 // `max_bounding_box_count` - (int64) No more than this number of bounding 202 // boxes will be produced per image. Default is 100, the 203 // requested value may be limited by server. 204 // 205 // * For Video Classification : 206 // 207 // `score_threshold` - (float) A value from 0.0 to 1.0. When the model 208 // makes predictions for a video, it will only produce results that 209 // have at least this confidence score. The default is 0.5. 210 // `segment_classification` - (boolean) Set to true to request 211 // segment-level classification. AutoML Video Intelligence returns 212 // labels and their confidence scores for the entire segment of the 213 // video that user specified in the request configuration. 214 // The default is "true". 215 // `shot_classification` - (boolean) Set to true to request shot-level 216 // classification. AutoML Video Intelligence determines the boundaries 217 // for each camera shot in the entire segment of the video that user 218 // specified in the request configuration. AutoML Video Intelligence 219 // then returns labels and their confidence scores for each detected 220 // shot, along with the start and end time of the shot. 221 // WARNING: Model evaluation is not done for this classification type, 222 // the quality of it depends on training data, but there are no metrics 223 // provided to describe that quality. The default is "false". 224 // `1s_interval_classification` - (boolean) Set to true to request 225 // classification for a video at one-second intervals. AutoML Video 226 // Intelligence returns labels and their confidence scores for each 227 // second of the entire segment of the video that user specified in the 228 // request configuration. 229 // WARNING: Model evaluation is not done for this classification 230 // type, the quality of it depends on training data, but there are no 231 // metrics provided to describe that quality. The default is 232 // "false". 233 // 234 // * For Tables: 235 // 236 // feature_imp<span>ortan</span>ce - (boolean) Whether feature importance 237 // should be populated in the returned TablesAnnotations. The 238 // default is false. 239 // 240 // * For Video Object Tracking: 241 // 242 // `score_threshold` - (float) When Model detects objects on video frames, 243 // it will only produce bounding boxes which have at least this 244 // confidence score. Value in 0 to 1 range, default is 0.5. 245 // `max_bounding_box_count` - (int64) No more than this number of bounding 246 // boxes will be returned per frame. Default is 100, the requested 247 // value may be limited by server. 248 // `min_bounding_box_size` - (float) Only bounding boxes with shortest edge 249 // at least that long as a relative value of video frame size will be 250 // returned. Value in 0 to 1 range. Default is 0. 251 map<string, string> params = 5 [(google.api.field_behavior) = REQUIRED]; 252} 253 254// Result of the Batch Predict. This message is returned in 255// [response][google.longrunning.Operation.response] of the operation returned 256// by the [PredictionService.BatchPredict][google.cloud.automl.v1beta1.PredictionService.BatchPredict]. 257message BatchPredictResult { 258 // Additional domain-specific prediction response metadata. 259 // 260 // * For Image Object Detection: 261 // `max_bounding_box_count` - (int64) At most that many bounding boxes per 262 // image could have been returned. 263 // 264 // * For Video Object Tracking: 265 // `max_bounding_box_count` - (int64) At most that many bounding boxes per 266 // frame could have been returned. 267 map<string, string> metadata = 1; 268} 269