annotation.proto 10 KB

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