1- // Copyright 2018 Google LLC.
1+ // Copyright 2019 Google LLC.
22//
33// Licensed under the Apache License, Version 2.0 (the "License");
44// you may not use this file except in compliance with the License.
@@ -49,6 +49,38 @@ service ImageAnnotator {
4949 };
5050 }
5151
52+ // Service that performs image detection and annotation for a batch of files.
53+ // Now only "application/pdf", "image/tiff" and "image/gif" are supported.
54+ //
55+ // This service will extract at most 5 (customers can specify which 5 in
56+ // AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each
57+ // file provided and perform detection and annotation for each image
58+ // extracted.
59+ rpc BatchAnnotateFiles (BatchAnnotateFilesRequest )
60+ returns (BatchAnnotateFilesResponse ) {
61+ option (google.api.http ) = {
62+ post : "/v1/files:annotate"
63+ body : "*"
64+ };
65+ }
66+
67+ // Run asynchronous image detection and annotation for a list of images.
68+ //
69+ // Progress and results can be retrieved through the
70+ // `google.longrunning.Operations` interface.
71+ // `Operation.metadata` contains `OperationMetadata` (metadata).
72+ // `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results).
73+ //
74+ // This service will write image annotation outputs to json files in customer
75+ // GCS bucket, each json file containing BatchAnnotateImagesResponse proto.
76+ rpc AsyncBatchAnnotateImages (AsyncBatchAnnotateImagesRequest )
77+ returns (google.longrunning.Operation ) {
78+ option (google.api.http ) = {
79+ post : "/v1/images:asyncBatchAnnotate"
80+ body : "*"
81+ };
82+ }
83+
5284 // Run asynchronous image detection and annotation for a list of generic
5385 // files, such as PDF files, which may contain multiple pages and multiple
5486 // images per page. Progress and results can be retrieved through the
@@ -128,6 +160,28 @@ message Feature {
128160 string model = 3 ;
129161}
130162
163+ // A bucketized representation of likelihood, which is intended to give clients
164+ // highly stable results across model upgrades.
165+ enum Likelihood {
166+ // Unknown likelihood.
167+ UNKNOWN = 0 ;
168+
169+ // It is very unlikely that the image belongs to the specified vertical.
170+ VERY_UNLIKELY = 1 ;
171+
172+ // It is unlikely that the image belongs to the specified vertical.
173+ UNLIKELY = 2 ;
174+
175+ // It is possible that the image belongs to the specified vertical.
176+ POSSIBLE = 3 ;
177+
178+ // It is likely that the image belongs to the specified vertical.
179+ LIKELY = 4 ;
180+
181+ // It is very likely that the image belongs to the specified vertical.
182+ VERY_LIKELY = 5 ;
183+ }
184+
131185// External image source (Google Cloud Storage or web URL image location).
132186message ImageSource {
133187 // **Use `image_uri` instead.**
@@ -294,7 +348,7 @@ message FaceAnnotation {
294348 }
295349
296350 // The bounding polygon around the face. The coordinates of the bounding box
297- // are in the original image's scale, as returned in `ImageParams` .
351+ // are in the original image's scale.
298352 // The bounding box is computed to "frame" the face in accordance with human
299353 // expectations. It is based on the landmarker results.
300354 // Note that one or more x and/or y coordinates may not be generated in the
@@ -505,7 +559,7 @@ message ImageProperties {
505559// Single crop hint that is used to generate a new crop when serving an image.
506560message CropHint {
507561 // The bounding polygon for the crop region. The coordinates of the bounding
508- // box are in the original image's scale, as returned in `ImageParams` .
562+ // box are in the original image's scale.
509563 BoundingPoly bounding_poly = 1 ;
510564
511565 // Confidence of this being a salient region. Range [0, 1].
@@ -565,7 +619,7 @@ message ImageContext {
565619}
566620
567621// Request for performing Google Cloud Vision API tasks over a user-provided
568- // image, with user-requested features.
622+ // image, with user-requested features, and with context information .
569623message AnnotateImageRequest {
570624 // The image to be processed.
571625 Image image = 1 ;
@@ -648,6 +702,9 @@ message AnnotateFileResponse {
648702
649703 // Individual responses to images found within the file.
650704 repeated AnnotateImageResponse responses = 2 ;
705+
706+ // This field gives the total number of pages in the file.
707+ int32 total_pages = 3 ;
651708}
652709
653710// Multiple image annotation requests are batched into a single service call.
@@ -662,6 +719,48 @@ message BatchAnnotateImagesResponse {
662719 repeated AnnotateImageResponse responses = 1 ;
663720}
664721
722+ // A request to annotate one single file, e.g. a PDF, TIFF or GIF file.
723+ message AnnotateFileRequest {
724+ // Required. Information about the input file.
725+ InputConfig input_config = 1 ;
726+
727+ // Required. Requested features.
728+ repeated Feature features = 2 ;
729+
730+ // Additional context that may accompany the image(s) in the file.
731+ ImageContext image_context = 3 ;
732+
733+ // Pages of the file to perform image annotation.
734+ //
735+ // Pages starts from 1, we assume the first page of the file is page 1.
736+ // At most 5 pages are supported per request. Pages can be negative.
737+ //
738+ // Page 1 means the first page.
739+ // Page 2 means the second page.
740+ // Page -1 means the last page.
741+ // Page -2 means the second to the last page.
742+ //
743+ // If the file is GIF instead of PDF or TIFF, page refers to GIF frames.
744+ //
745+ // If this field is empty, by default the service performs image annotation
746+ // for the first 5 pages of the file.
747+ repeated int32 pages = 4 ;
748+ }
749+
750+ // A list of requests to annotate files using the BatchAnnotateFiles API.
751+ message BatchAnnotateFilesRequest {
752+ // The list of file annotation requests. Right now we support only one
753+ // AnnotateFileRequest in BatchAnnotateFilesRequest.
754+ repeated AnnotateFileRequest requests = 1 ;
755+ }
756+
757+ // A list of file annotation responses.
758+ message BatchAnnotateFilesResponse {
759+ // The list of file annotation responses, each response corresponding to each
760+ // AnnotateFileRequest in BatchAnnotateFilesRequest.
761+ repeated AnnotateFileResponse responses = 1 ;
762+ }
763+
665764// An offline file annotation request.
666765message AsyncAnnotateFileRequest {
667766 // Required. Information about the input file.
@@ -683,6 +782,21 @@ message AsyncAnnotateFileResponse {
683782 OutputConfig output_config = 1 ;
684783}
685784
785+ // Request for async image annotation for a list of images.
786+ message AsyncBatchAnnotateImagesRequest {
787+ // Individual image annotation requests for this batch.
788+ repeated AnnotateImageRequest requests = 1 ;
789+
790+ // Required. The desired output location and metadata (e.g. format).
791+ OutputConfig output_config = 2 ;
792+ }
793+
794+ // Response to an async batch image annotation request.
795+ message AsyncBatchAnnotateImagesResponse {
796+ // The output location and metadata from AsyncBatchAnnotateImagesRequest.
797+ OutputConfig output_config = 1 ;
798+ }
799+
686800// Multiple async file annotation requests are batched into a single service
687801// call.
688802message AsyncBatchAnnotateFilesRequest {
@@ -702,6 +816,14 @@ message InputConfig {
702816 // The Google Cloud Storage location to read the input from.
703817 GcsSource gcs_source = 1 ;
704818
819+ // File content, represented as a stream of bytes.
820+ // Note: As with all `bytes` fields, protobuffers use a pure binary
821+ // representation, whereas JSON representations use base64.
822+ //
823+ // Currently, this field only works for BatchAnnotateFiles requests. It does
824+ // not work for AsyncBatchAnnotateFiles requests.
825+ bytes content = 3 ;
826+
705827 // The type of the file. Currently only "application/pdf" and "image/tiff"
706828 // are supported. Wildcards are not supported.
707829 string mime_type = 2 ;
@@ -735,16 +857,23 @@ message GcsSource {
735857
736858// The Google Cloud Storage location where the output will be written to.
737859message GcsDestination {
738- // Google Cloud Storage URI where the results will be stored. Results will
739- // be in JSON format and preceded by its corresponding input URI. This field
740- // can either represent a single file, or a prefix for multiple outputs.
741- // Prefixes must end in a `/`.
860+ // Google Cloud Storage URI prefix where the results will be stored. Results
861+ // will be in JSON format and preceded by its corresponding input URI prefix.
862+ // This field can either represent a gcs file prefix or gcs directory. In
863+ // either case, the uri should be unique because in order to get all of the
864+ // output files, you will need to do a wildcard gcs search on the uri prefix
865+ // you provide.
742866 //
743867 // Examples:
744868 //
745- // * File: gs://bucket-name/filename.json
746- // * Prefix: gs://bucket-name/prefix/here/
747- // * File: gs://bucket-name/prefix/here
869+ // * File Prefix: gs://bucket-name/here/filenameprefix The output files
870+ // will be created in gs://bucket-name/here/ and the names of the
871+ // output files will begin with "filenameprefix".
872+ //
873+ // * Directory Prefix: gs://bucket-name/some/location/ The output files
874+ // will be created in gs://bucket-name/some/location/ and the names of the
875+ // output files could be anything because there was no filename prefix
876+ // specified.
748877 //
749878 // If multiple outputs, each response is still AnnotateFileResponse, each of
750879 // which contains some subset of the full list of AnnotateImageResponse.
@@ -782,25 +911,3 @@ message OperationMetadata {
782911 // The time when the operation result was last updated.
783912 google.protobuf.Timestamp update_time = 6 ;
784913}
785-
786- // A bucketized representation of likelihood, which is intended to give clients
787- // highly stable results across model upgrades.
788- enum Likelihood {
789- // Unknown likelihood.
790- UNKNOWN = 0 ;
791-
792- // It is very unlikely that the image belongs to the specified vertical.
793- VERY_UNLIKELY = 1 ;
794-
795- // It is unlikely that the image belongs to the specified vertical.
796- UNLIKELY = 2 ;
797-
798- // It is possible that the image belongs to the specified vertical.
799- POSSIBLE = 3 ;
800-
801- // It is likely that the image belongs to the specified vertical.
802- LIKELY = 4 ;
803-
804- // It is very likely that the image belongs to the specified vertical.
805- VERY_LIKELY = 5 ;
806- }
0 commit comments