xref: /aosp_15_r20/external/googleapis/google/cloud/datalabeling/v1beta1/annotation.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2019 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//
15
16syntax = "proto3";
17
18package google.cloud.datalabeling.v1beta1;
19
20import "google/cloud/datalabeling/v1beta1/annotation_spec_set.proto";
21import "google/protobuf/duration.proto";
22
23option csharp_namespace = "Google.Cloud.DataLabeling.V1Beta1";
24option go_package = "cloud.google.com/go/datalabeling/apiv1beta1/datalabelingpb;datalabelingpb";
25option java_multiple_files = true;
26option java_package = "com.google.cloud.datalabeling.v1beta1";
27option php_namespace = "Google\\Cloud\\DataLabeling\\V1beta1";
28option ruby_package = "Google::Cloud::DataLabeling::V1beta1";
29
30// Specifies where the annotation comes from (whether it was provided by a
31// human labeler or a different source).
32enum AnnotationSource {
33  ANNOTATION_SOURCE_UNSPECIFIED = 0;
34
35  // Answer is provided by a human contributor.
36  OPERATOR = 3;
37}
38
39// Annotation for Example. Each example may have one or more annotations. For
40// example in image classification problem, each image might have one or more
41// labels. We call labels binded with this image an Annotation.
42message Annotation {
43  // Output only. Unique name of this annotation, format is:
44  //
45  // projects/{project_id}/datasets/{dataset_id}/annotatedDatasets/{annotated_dataset}/examples/{example_id}/annotations/{annotation_id}
46  string name = 1;
47
48  // Output only. The source of the annotation.
49  AnnotationSource annotation_source = 2;
50
51  // Output only. This is the actual annotation value, e.g classification,
52  // bounding box values are stored here.
53  AnnotationValue annotation_value = 3;
54
55  // Output only. Annotation metadata, including information like votes
56  // for labels.
57  AnnotationMetadata annotation_metadata = 4;
58
59  // Output only. Sentiment for this annotation.
60  AnnotationSentiment annotation_sentiment = 6;
61}
62
63enum AnnotationSentiment {
64  ANNOTATION_SENTIMENT_UNSPECIFIED = 0;
65
66  // This annotation describes negatively about the data.
67  NEGATIVE = 1;
68
69  // This label describes positively about the data.
70  POSITIVE = 2;
71}
72
73enum AnnotationType {
74  ANNOTATION_TYPE_UNSPECIFIED = 0;
75
76  // Classification annotations in an image. Allowed for continuous evaluation.
77  IMAGE_CLASSIFICATION_ANNOTATION = 1;
78
79  // Bounding box annotations in an image. A form of image object detection.
80  // Allowed for continuous evaluation.
81  IMAGE_BOUNDING_BOX_ANNOTATION = 2;
82
83  // Oriented bounding box. The box does not have to be parallel to horizontal
84  // line.
85  IMAGE_ORIENTED_BOUNDING_BOX_ANNOTATION = 13;
86
87  // Bounding poly annotations in an image.
88  IMAGE_BOUNDING_POLY_ANNOTATION = 10;
89
90  // Polyline annotations in an image.
91  IMAGE_POLYLINE_ANNOTATION = 11;
92
93  // Segmentation annotations in an image.
94  IMAGE_SEGMENTATION_ANNOTATION = 12;
95
96  // Classification annotations in video shots.
97  VIDEO_SHOTS_CLASSIFICATION_ANNOTATION = 3;
98
99  // Video object tracking annotation.
100  VIDEO_OBJECT_TRACKING_ANNOTATION = 4;
101
102  // Video object detection annotation.
103  VIDEO_OBJECT_DETECTION_ANNOTATION = 5;
104
105  // Video event annotation.
106  VIDEO_EVENT_ANNOTATION = 6;
107
108  // Classification for text. Allowed for continuous evaluation.
109  TEXT_CLASSIFICATION_ANNOTATION = 8;
110
111  // Entity extraction for text.
112  TEXT_ENTITY_EXTRACTION_ANNOTATION = 9;
113
114  // General classification. Allowed for continuous evaluation.
115  GENERAL_CLASSIFICATION_ANNOTATION = 14;
116}
117
118// Annotation value for an example.
119message AnnotationValue {
120  oneof value_type {
121    // Annotation value for image classification case.
122    ImageClassificationAnnotation image_classification_annotation = 1;
123
124    // Annotation value for image bounding box, oriented bounding box
125    // and polygon cases.
126    ImageBoundingPolyAnnotation image_bounding_poly_annotation = 2;
127
128    // Annotation value for image polyline cases.
129    // Polyline here is different from BoundingPoly. It is formed by
130    // line segments connected to each other but not closed form(Bounding Poly).
131    // The line segments can cross each other.
132    ImagePolylineAnnotation image_polyline_annotation = 8;
133
134    // Annotation value for image segmentation.
135    ImageSegmentationAnnotation image_segmentation_annotation = 9;
136
137    // Annotation value for text classification case.
138    TextClassificationAnnotation text_classification_annotation = 3;
139
140    // Annotation value for text entity extraction case.
141    TextEntityExtractionAnnotation text_entity_extraction_annotation = 10;
142
143    // Annotation value for video classification case.
144    VideoClassificationAnnotation video_classification_annotation = 4;
145
146    // Annotation value for video object detection and tracking case.
147    VideoObjectTrackingAnnotation video_object_tracking_annotation = 5;
148
149    // Annotation value for video event case.
150    VideoEventAnnotation video_event_annotation = 6;
151  }
152}
153
154// Image classification annotation definition.
155message ImageClassificationAnnotation {
156  // Label of image.
157  AnnotationSpec annotation_spec = 1;
158}
159
160// A vertex represents a 2D point in the image.
161// NOTE: the vertex coordinates are in the same scale as the original image.
162message Vertex {
163  // X coordinate.
164  int32 x = 1;
165
166  // Y coordinate.
167  int32 y = 2;
168}
169
170// A vertex represents a 2D point in the image.
171// NOTE: the normalized vertex coordinates are relative to the original image
172// and range from 0 to 1.
173message NormalizedVertex {
174  // X coordinate.
175  float x = 1;
176
177  // Y coordinate.
178  float y = 2;
179}
180
181// A bounding polygon in the image.
182message BoundingPoly {
183  // The bounding polygon vertices.
184  repeated Vertex vertices = 1;
185}
186
187// Normalized bounding polygon.
188message NormalizedBoundingPoly {
189  // The bounding polygon normalized vertices.
190  repeated NormalizedVertex normalized_vertices = 1;
191}
192
193// Image bounding poly annotation. It represents a polygon including
194// bounding box in the image.
195message ImageBoundingPolyAnnotation {
196  // The region of the polygon. If it is a bounding box, it is guaranteed to be
197  // four points.
198  oneof bounded_area {
199    BoundingPoly bounding_poly = 2;
200
201    NormalizedBoundingPoly normalized_bounding_poly = 3;
202  }
203
204  // Label of object in this bounding polygon.
205  AnnotationSpec annotation_spec = 1;
206}
207
208// A line with multiple line segments.
209message Polyline {
210  // The polyline vertices.
211  repeated Vertex vertices = 1;
212}
213
214// Normalized polyline.
215message NormalizedPolyline {
216  // The normalized polyline vertices.
217  repeated NormalizedVertex normalized_vertices = 1;
218}
219
220// A polyline for the image annotation.
221message ImagePolylineAnnotation {
222  oneof poly {
223    Polyline polyline = 2;
224
225    NormalizedPolyline normalized_polyline = 3;
226  }
227
228  // Label of this polyline.
229  AnnotationSpec annotation_spec = 1;
230}
231
232// Image segmentation annotation.
233message ImageSegmentationAnnotation {
234  // The mapping between rgb color and annotation spec. The key is the rgb
235  // color represented in format of rgb(0, 0, 0). The value is the
236  // AnnotationSpec.
237  map<string, AnnotationSpec> annotation_colors = 1;
238
239  // Image format.
240  string mime_type = 2;
241
242  // A byte string of a full image's color map.
243  bytes image_bytes = 3;
244}
245
246// Text classification annotation.
247message TextClassificationAnnotation {
248  // Label of the text.
249  AnnotationSpec annotation_spec = 1;
250}
251
252// Text entity extraction annotation.
253message TextEntityExtractionAnnotation {
254  // Label of the text entities.
255  AnnotationSpec annotation_spec = 1;
256
257  // Position of the entity.
258  SequentialSegment sequential_segment = 2;
259}
260
261// Start and end position in a sequence (e.g. text segment).
262message SequentialSegment {
263  // Start position (inclusive).
264  int32 start = 1;
265
266  // End position (exclusive).
267  int32 end = 2;
268}
269
270// A time period inside of an example that has a time dimension (e.g. video).
271message TimeSegment {
272  // Start of the time segment (inclusive), represented as the duration since
273  // the example start.
274  google.protobuf.Duration start_time_offset = 1;
275
276  // End of the time segment (exclusive), represented as the duration since the
277  // example start.
278  google.protobuf.Duration end_time_offset = 2;
279}
280
281// Video classification annotation.
282message VideoClassificationAnnotation {
283  // The time segment of the video to which the annotation applies.
284  TimeSegment time_segment = 1;
285
286  // Label of the segment specified by time_segment.
287  AnnotationSpec annotation_spec = 2;
288}
289
290// Video frame level annotation for object detection and tracking.
291message ObjectTrackingFrame {
292  // The bounding box location of this object track for the frame.
293  oneof bounded_area {
294    BoundingPoly bounding_poly = 1;
295
296    NormalizedBoundingPoly normalized_bounding_poly = 2;
297  }
298
299  // The time offset of this frame relative to the beginning of the video.
300  google.protobuf.Duration time_offset = 3;
301}
302
303// Video object tracking annotation.
304message VideoObjectTrackingAnnotation {
305  // Label of the object tracked in this annotation.
306  AnnotationSpec annotation_spec = 1;
307
308  // The time segment of the video to which object tracking applies.
309  TimeSegment time_segment = 2;
310
311  // The list of frames where this object track appears.
312  repeated ObjectTrackingFrame object_tracking_frames = 3;
313}
314
315// Video event annotation.
316message VideoEventAnnotation {
317  // Label of the event in this annotation.
318  AnnotationSpec annotation_spec = 1;
319
320  // The time segment of the video to which the annotation applies.
321  TimeSegment time_segment = 2;
322}
323
324// Additional information associated with the annotation.
325message AnnotationMetadata {
326  // Metadata related to human labeling.
327  OperatorMetadata operator_metadata = 2;
328}
329
330// General information useful for labels coming from contributors.
331message OperatorMetadata {
332  // Confidence score corresponding to a label. For examle, if 3 contributors
333  // have answered the question and 2 of them agree on the final label, the
334  // confidence score will be 0.67 (2/3).
335  float score = 1;
336
337  // The total number of contributors that answer this question.
338  int32 total_votes = 2;
339
340  // The total number of contributors that choose this label.
341  int32 label_votes = 3;
342
343  // Comments from contributors.
344  repeated string comments = 4;
345}
346