Skip to content

Commit 37b9fc5

Browse files
Google APIscopybara-github
authored andcommitted
feat: Add image block and blob asset in Document proto
PiperOrigin-RevId: 750637959
1 parent c8f09eb commit 37b9fc5

1 file changed

Lines changed: 112 additions & 0 deletions

File tree

google/cloud/documentai/v1beta3/document.proto

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,12 @@ message Document {
897897
repeated Provenance provenance = 3 [deprecated = true];
898898
}
899899

900+
// Represents the annotation of a block or a chunk.
901+
message Annotations {
902+
// The description of the content with this annotation.
903+
string description = 1;
904+
}
905+
900906
// Represents the parsed layout of a document as a collection of blocks that
901907
// the document is divided into.
902908
message DocumentLayout {
@@ -975,6 +981,37 @@ message Document {
975981
repeated DocumentLayoutBlock blocks = 1;
976982
}
977983

984+
// Represents an image type block.
985+
message LayoutImageBlock {
986+
// Source of the image.
987+
oneof image_source {
988+
// Optional. Asset id of the inline image. If set, find the image
989+
// content in the blob_assets field.
990+
string blob_asset_id = 4 [(google.api.field_behavior) = OPTIONAL];
991+
992+
// Optional. Google Cloud Storage uri of the image.
993+
string gcs_uri = 5 [(google.api.field_behavior) = OPTIONAL];
994+
995+
// Optional. Data uri of the image.
996+
// It is composed of four parts: a prefix (data:), a MIME type
997+
// indicating the type of data, an optional base64 token if
998+
// non-textual, and the data itself:
999+
// data:[<mediatype>][;base64],<data>
1000+
string data_uri = 6 [(google.api.field_behavior) = OPTIONAL];
1001+
}
1002+
1003+
// Mime type of the image. An IANA published [media type (MIME type)]
1004+
// (https://www.iana.org/assignments/media-types/media-types.xhtml).
1005+
string mime_type = 1;
1006+
1007+
// Text extracted from the image using OCR or alt text describing the
1008+
// image.
1009+
string image_text = 2;
1010+
1011+
// Annotation of the image block.
1012+
Annotations annotations = 3;
1013+
}
1014+
9781015
oneof block {
9791016
// Block consisting of text content.
9801017
LayoutTextBlock text_block = 2;
@@ -984,13 +1021,19 @@ message Document {
9841021

9851022
// Block consisting of list content/structure.
9861023
LayoutListBlock list_block = 4;
1024+
1025+
// Block consisting of image content.
1026+
LayoutImageBlock image_block = 7;
9871027
}
9881028

9891029
// ID of the block.
9901030
string block_id = 1;
9911031

9921032
// Page span of the block.
9931033
LayoutPageSpan page_span = 5;
1034+
1035+
// Identifies the bounding box for the block.
1036+
BoundingPoly bounding_box = 6;
9941037
}
9951038

9961039
// List of blocks in the document.
@@ -1028,6 +1071,48 @@ message Document {
10281071
ChunkPageSpan page_span = 2;
10291072
}
10301073

1074+
// The image chunk field in the chunk.
1075+
message ImageChunkField {
1076+
// Source of the image.
1077+
oneof image_source {
1078+
// Optional. Asset id of the inline image. If set, find the image
1079+
// content in the blob_assets field.
1080+
string blob_asset_id = 1 [(google.api.field_behavior) = OPTIONAL];
1081+
1082+
// Optional. Google Cloud Storage uri of the image.
1083+
string gcs_uri = 2 [(google.api.field_behavior) = OPTIONAL];
1084+
1085+
// Optional. Data uri of the image.
1086+
// It is composed of four parts: a prefix (data:), a MIME type
1087+
// indicating the type of data, an optional base64 token if
1088+
// non-textual, and the data itself:
1089+
// data:[<mediatype>][;base64],<data>
1090+
string data_uri = 3 [(google.api.field_behavior) = OPTIONAL];
1091+
}
1092+
1093+
// Annotation of the image chunk field.
1094+
Annotations annotations = 4;
1095+
}
1096+
1097+
// The table chunk field in the chunk.
1098+
message TableChunkField {
1099+
// Annotation of the table chunk field.
1100+
Annotations annotations = 1;
1101+
}
1102+
1103+
// The chunk field in the chunk. A chunk field could be one of the various
1104+
// types (e.g. image, table) supported.
1105+
message ChunkField {
1106+
// The type of the chunk field.
1107+
oneof field_type {
1108+
// The image chunk field in the chunk.
1109+
ImageChunkField image_chunk_field = 1;
1110+
1111+
// The table chunk field in the chunk.
1112+
TableChunkField table_chunk_field = 2;
1113+
}
1114+
}
1115+
10311116
// ID of the chunk.
10321117
string chunk_id = 1;
10331118

@@ -1045,12 +1130,31 @@ message Document {
10451130

10461131
// Page footers associated with the chunk.
10471132
repeated ChunkPageFooter page_footers = 6;
1133+
1134+
// Chunk fields inside this chunk.
1135+
repeated ChunkField chunk_fields = 7;
10481136
}
10491137

10501138
// List of chunks.
10511139
repeated Chunk chunks = 1;
10521140
}
10531141

1142+
// Represents a blob asset. It's used to store the content of the inline blob
1143+
// in this document, e.g. image bytes, such that it can be referenced by
1144+
// other fields in the document via asset id.
1145+
message BlobAsset {
1146+
// Optional. The id of the blob asset.
1147+
string asset_id = 1 [(google.api.field_behavior) = OPTIONAL];
1148+
1149+
// Optional. The content of the blob asset, e.g. image bytes.
1150+
bytes content = 2 [(google.api.field_behavior) = OPTIONAL];
1151+
1152+
// The mime type of the blob asset.
1153+
// An IANA published [media type (MIME
1154+
// type)](https://www.iana.org/assignments/media-types/media-types.xhtml).
1155+
string mime_type = 3;
1156+
}
1157+
10541158
// Original source document from the user.
10551159
oneof source {
10561160
// Optional. Currently supports Google Cloud Storage URI of the form
@@ -1065,6 +1169,9 @@ message Document {
10651169
bytes content = 2 [(google.api.field_behavior) = OPTIONAL];
10661170
}
10671171

1172+
// Optional. An internal identifier for document. Should be loggable (no PII).
1173+
string docid = 15 [(google.api.field_behavior) = OPTIONAL];
1174+
10681175
// An IANA published [media type (MIME
10691176
// type)](https://www.iana.org/assignments/media-types/media-types.xhtml).
10701177
string mime_type = 3;
@@ -1110,6 +1217,11 @@ message Document {
11101217

11111218
// Document chunked based on chunking config.
11121219
ChunkedDocument chunked_document = 18;
1220+
1221+
// Optional. The blob assets in this document. This is used to store the
1222+
// content of the inline blobs in this document, e.g. image bytes, such that
1223+
// it can be referenced by other fields in the document via asset id.
1224+
repeated BlobAsset blob_assets = 19 [(google.api.field_behavior) = OPTIONAL];
11131225
}
11141226

11151227
// The revision reference specifies which revision on the document to read.

0 commit comments

Comments
 (0)