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/cloud/automl/v1/geometry.proto"; 20import "google/cloud/automl/v1/io.proto"; 21import "google/cloud/automl/v1/text_segment.proto"; 22 23option csharp_namespace = "Google.Cloud.AutoML.V1"; 24option go_package = "cloud.google.com/go/automl/apiv1/automlpb;automlpb"; 25option java_multiple_files = true; 26option java_package = "com.google.cloud.automl.v1"; 27option php_namespace = "Google\\Cloud\\AutoMl\\V1"; 28option ruby_package = "Google::Cloud::AutoML::V1"; 29 30// A representation of an image. 31// Only images up to 30MB in size are supported. 32message Image { 33 // Input only. The data representing the image. 34 // For Predict calls [image_bytes][google.cloud.automl.v1.Image.image_bytes] must be set . 35 oneof data { 36 // Image content represented as a stream of bytes. 37 // Note: As with all `bytes` fields, protobuffers use a pure binary 38 // representation, whereas JSON representations use base64. 39 bytes image_bytes = 1; 40 } 41 42 // Output only. HTTP URI to the thumbnail image. 43 string thumbnail_uri = 4; 44} 45 46// A representation of a text snippet. 47message TextSnippet { 48 // Required. The content of the text snippet as a string. Up to 250000 49 // characters long. 50 string content = 1; 51 52 // Optional. The format of [content][google.cloud.automl.v1.TextSnippet.content]. Currently the only two allowed 53 // values are "text/html" and "text/plain". If left blank, the format is 54 // automatically determined from the type of the uploaded [content][google.cloud.automl.v1.TextSnippet.content]. 55 string mime_type = 2; 56 57 // Output only. HTTP URI where you can download the content. 58 string content_uri = 4; 59} 60 61// Message that describes dimension of a document. 62message DocumentDimensions { 63 // Unit of the document dimension. 64 enum DocumentDimensionUnit { 65 // Should not be used. 66 DOCUMENT_DIMENSION_UNIT_UNSPECIFIED = 0; 67 68 // Document dimension is measured in inches. 69 INCH = 1; 70 71 // Document dimension is measured in centimeters. 72 CENTIMETER = 2; 73 74 // Document dimension is measured in points. 72 points = 1 inch. 75 POINT = 3; 76 } 77 78 // Unit of the dimension. 79 DocumentDimensionUnit unit = 1; 80 81 // Width value of the document, works together with the unit. 82 float width = 2; 83 84 // Height value of the document, works together with the unit. 85 float height = 3; 86} 87 88// A structured text document e.g. a PDF. 89message Document { 90 // Describes the layout information of a [text_segment][google.cloud.automl.v1.Document.Layout.text_segment] in the document. 91 message Layout { 92 // The type of TextSegment in the context of the original document. 93 enum TextSegmentType { 94 // Should not be used. 95 TEXT_SEGMENT_TYPE_UNSPECIFIED = 0; 96 97 // The text segment is a token. e.g. word. 98 TOKEN = 1; 99 100 // The text segment is a paragraph. 101 PARAGRAPH = 2; 102 103 // The text segment is a form field. 104 FORM_FIELD = 3; 105 106 // The text segment is the name part of a form field. It will be treated 107 // as child of another FORM_FIELD TextSegment if its span is subspan of 108 // another TextSegment with type FORM_FIELD. 109 FORM_FIELD_NAME = 4; 110 111 // The text segment is the text content part of a form field. It will be 112 // treated as child of another FORM_FIELD TextSegment if its span is 113 // subspan of another TextSegment with type FORM_FIELD. 114 FORM_FIELD_CONTENTS = 5; 115 116 // The text segment is a whole table, including headers, and all rows. 117 TABLE = 6; 118 119 // The text segment is a table's headers. It will be treated as child of 120 // another TABLE TextSegment if its span is subspan of another TextSegment 121 // with type TABLE. 122 TABLE_HEADER = 7; 123 124 // The text segment is a row in table. It will be treated as child of 125 // another TABLE TextSegment if its span is subspan of another TextSegment 126 // with type TABLE. 127 TABLE_ROW = 8; 128 129 // The text segment is a cell in table. It will be treated as child of 130 // another TABLE_ROW TextSegment if its span is subspan of another 131 // TextSegment with type TABLE_ROW. 132 TABLE_CELL = 9; 133 } 134 135 // Text Segment that represents a segment in 136 // [document_text][google.cloud.automl.v1p1beta.Document.document_text]. 137 TextSegment text_segment = 1; 138 139 // Page number of the [text_segment][google.cloud.automl.v1.Document.Layout.text_segment] in the original document, starts 140 // from 1. 141 int32 page_number = 2; 142 143 // The position of the [text_segment][google.cloud.automl.v1.Document.Layout.text_segment] in the page. 144 // Contains exactly 4 145 // [normalized_vertices][google.cloud.automl.v1p1beta.BoundingPoly.normalized_vertices] 146 // and they are connected by edges in the order provided, which will 147 // represent a rectangle parallel to the frame. The 148 // [NormalizedVertex-s][google.cloud.automl.v1p1beta.NormalizedVertex] are 149 // relative to the page. 150 // Coordinates are based on top-left as point (0,0). 151 BoundingPoly bounding_poly = 3; 152 153 // The type of the [text_segment][google.cloud.automl.v1.Document.Layout.text_segment] in document. 154 TextSegmentType text_segment_type = 4; 155 } 156 157 // An input config specifying the content of the document. 158 DocumentInputConfig input_config = 1; 159 160 // The plain text version of this document. 161 TextSnippet document_text = 2; 162 163 // Describes the layout of the document. 164 // Sorted by [page_number][]. 165 repeated Layout layout = 3; 166 167 // The dimensions of the page in the document. 168 DocumentDimensions document_dimensions = 4; 169 170 // Number of pages in the document. 171 int32 page_count = 5; 172} 173 174// Example data used for training or prediction. 175message ExamplePayload { 176 // Required. The example data. 177 oneof payload { 178 // Example image. 179 Image image = 1; 180 181 // Example text. 182 TextSnippet text_snippet = 2; 183 184 // Example document. 185 Document document = 4; 186 } 187} 188