title: ImageBoundingBox
description: >
Import and export format for importing/exporting images together with bounding
box annotations. Can be used in Dataset.import_schema_uri field.
type: object
required:
- imageGcsUri
properties:
imageGcsUri:
type: string
description: >
A Cloud Storage URI pointing to an image. Up to 30MB in size.
Supported file mime types: `image/jpeg`, `image/gif`, `image/png`,
`image/webp`, `image/bmp`, `image/tiff`, `image/vnd.microsoft.icon`.
boundingBoxAnnotations:
type: array
description: Multiple bounding box Annotations on the image.
items:
type: object
description: >
Bounding box anntoation. `xMin`, `xMax`, `yMin`, and `yMax` are relative
to the image size, and the point 0,0 is in the top left of the image.
properties:
displayName:
type: string
description: >
It will be imported as/exported from AnnotationSpec's display name,
i.e. the name of the label/class.
xMin:
description: The leftmost coordinate of the bounding box.
type: number
format: double
xMax:
description: The rightmost coordinate of the bounding box.
type: number
format: double
yMin:
description: The topmost coordinate of the bounding box.
type: number
format: double
yMax:
description: The bottommost coordinate of the bounding box.
type: number
format: double
annotationResourceLabels:
description: Resource labels on the Annotation.
type: object
additionalProperties:
type: string
dataItemResourceLabels:
description: Resource labels on the DataItem.
type: object
additionalProperties:
type: string
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2024-11-25。"],[],[],null,["# Prepare image training data for object detection\n\nThis page describes how to prepare image training data for use in a Vertex AI dataset to train an image object detection model.\n\n\u003cbr /\u003e\n\nThe following objective section includes information about data requirements,\ninput/output schema file, and the format of the data import files\n([JSON Lines](https://jsonlines.org/)\n\\& CSV) that are defined by the schema.\n\n\u003cbr /\u003e\n\n### Object detection\n\n\u003cbr /\u003e\n\n\n### Data requirements\n\n\u003cbr /\u003e\n\n\n### YAML schema file\n\n\u003cbr /\u003e\n\nUse the following publicly accessible schema file to import image object detection\nannotations (bounding boxes and labels). This schema file dictates the format\nof the data input files. This file's structure follows the\n[OpenAPI schema](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#schema).\n\n\u003cbr /\u003e\n\n[`gs://google-cloud-aiplatform/schema/dataset/ioformat/image_bounding_box_io_format_1.0.0.yaml`](https://storage.cloud.google.com/google-cloud-aiplatform/schema/dataset/ioformat/image_bounding_box_io_format_1.0.0.yaml)\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n#### **Full schema file**\n\n```\ntitle: ImageBoundingBox\ndescription: \u003e\n Import and export format for importing/exporting images together with bounding\n box annotations. Can be used in Dataset.import_schema_uri field.\ntype: object\nrequired:\n- imageGcsUri\nproperties:\n imageGcsUri:\n type: string\n description: \u003e\n A Cloud Storage URI pointing to an image. Up to 30MB in size.\n Supported file mime types: `image/jpeg`, `image/gif`, `image/png`,\n `image/webp`, `image/bmp`, `image/tiff`, `image/vnd.microsoft.icon`.\n boundingBoxAnnotations:\n type: array\n description: Multiple bounding box Annotations on the image.\n items:\n type: object\n description: \u003e\n Bounding box anntoation. `xMin`, `xMax`, `yMin`, and `yMax` are relative\n to the image size, and the point 0,0 is in the top left of the image.\n properties:\n displayName:\n type: string\n description: \u003e\n It will be imported as/exported from AnnotationSpec's display name,\n i.e. the name of the label/class.\n xMin:\n description: The leftmost coordinate of the bounding box.\n type: number\n format: double\n xMax:\n description: The rightmost coordinate of the bounding box.\n type: number\n format: double\n yMin:\n description: The topmost coordinate of the bounding box.\n type: number\n format: double\n yMax:\n description: The bottommost coordinate of the bounding box.\n type: number\n format: double\n annotationResourceLabels:\n description: Resource labels on the Annotation.\n type: object\n additionalProperties:\n type: string\n dataItemResourceLabels:\n description: Resource labels on the DataItem.\n type: object\n additionalProperties:\n type: string\n```\n\n\u003cbr /\u003e\n\n\n### Input files\n\n\u003cbr /\u003e\n\n\n### JSON Lines\n\nJSON on each line: \n\n```\n\n\n{\n \"imageGcsUri\": \"gs://bucket/filename.ext\",\n \"boundingBoxAnnotations\": [\n {\n \"displayName\": \"OBJECT1_LABEL\",\n \"xMin\": \"X_MIN\",\n \"yMin\": \"Y_MIN\",\n \"xMax\": \"X_MAX\",\n \"yMax\": \"Y_MAX\",\n \"annotationResourceLabels\": {\n \"aiplatform.googleapis.com/annotation_set_name\": \"displayName\",\n \"env\": \"prod\"\n }\n },\n {\n \"displayName\": \"OBJECT2_LABEL\",\n \"xMin\": \"X_MIN\",\n \"yMin\": \"Y_MIN\",\n \"xMax\": \"X_MAX\",\n \"yMax\": \"Y_MAX\"\n }\n ],\n \"dataItemResourceLabels\": {\n \"aiplatform.googleapis.com/ml_use\": \"test/train/validation\"\n }\n}\n```\n\n**Field notes**:\n\n- `imageGcsUri` - The only required field.\n- `annotationResourceLabels` - Can contain any number of key-value string pairs. The only system-reserved key-value pair is the following:\n - \"aiplatform.googleapis.com/annotation_set_name\" : \"\u003cvar translate=\"no\"\u003evalue\u003c/var\u003e\"\n\n Where \u003cvar translate=\"no\"\u003evalue\u003c/var\u003e is one of the display names of the\n existing annotation sets in the dataset.\n- `dataItemResourceLabels` - Can contain any number of key-value string pairs. The only system-reserved key-value pair is the following which specifies the machine learning use set of the data item:\n - \"aiplatform.googleapis.com/ml_use\" : \"\u003cvar translate=\"no\"\u003etraining/test/validation\u003c/var\u003e\"\n\n#### Example JSON Lines - `object_detection.jsonl`:\n\n```\n\n\n{\"imageGcsUri\": \"gs://bucket/filename1.jpeg\", \"boundingBoxAnnotations\": [{\"displayName\": \"Tomato\", \"xMin\": \"0.3\", \"yMin\": \"0.3\", \"xMax\": \"0.7\", \"yMax\": \"0.6\"}], \"dataItemResourceLabels\": {\"aiplatform.googleapis.com/ml_use\": \"test\"}}\n{\"imageGcsUri\": \"gs://bucket/filename2.gif\", \"boundingBoxAnnotations\": [{\"displayName\": \"Tomato\", \"xMin\": \"0.8\", \"yMin\": \"0.2\", \"xMax\": \"1.0\", \"yMax\": \"0.4\"},{\"displayName\": \"Salad\", \"xMin\": \"0.0\", \"yMin\": \"0.0\", \"xMax\": \"1.0\", \"yMax\": \"1.0\"}], \"dataItemResourceLabels\": {\"aiplatform.googleapis.com/ml_use\": \"training\"}}\n{\"imageGcsUri\": \"gs://bucket/filename3.png\", \"boundingBoxAnnotations\": [{\"displayName\": \"Baked goods\", \"xMin\": \"0.5\", \"yMin\": \"0.7\", \"xMax\": \"0.8\", \"yMax\": \"0.8\"}], \"dataItemResourceLabels\": {\"aiplatform.googleapis.com/ml_use\": \"training\"}}\n{\"imageGcsUri\": \"gs://bucket/filename4.tiff\", \"boundingBoxAnnotations\": [{\"displayName\": \"Salad\", \"xMin\": \"0.1\", \"yMin\": \"0.2\", \"xMax\": \"0.8\", \"yMax\": \"0.9\"}], \"dataItemResourceLabels\": {\"aiplatform.googleapis.com/ml_use\": \"validation\"}}\n...\n```\n\n### CSV\n\nCSV format: \n\n```\n[ML_USE],GCS_FILE_PATH,[LABEL],[BOUNDING_BOX]*\n```\n**List of columns**\n\n- `ML_USE` (Optional). For data split purposes when training a model. Use TRAINING, TEST, or VALIDATION. For more information about manual data splitting, see [About data splits for AutoML models](/vertex-ai/docs/general/ml-use).\n- `GCS_FILE_PATH`. This field contains the Cloud Storage URI for the image. Cloud Storage URIs are case-sensitive.\n- `LABEL`. Labels must start with a letter and only contain letters, numbers, and underscores.\n- `BOUNDING_BOX`. A bounding box for an object in the image. Specifying a bounding box involves more than one column. \n\n **A.** `X_MIN`,`Y_MIN` \n **B.** `X_MAX`,`Y_MIN` \n **C.** `X_MAX`,`Y_MAX` \n **D.** `X_MIN`,`Y_MAX` \n\n Each vertex is specified by x, y coordinate values. Coordinates are normalized float\n values \\[0,1\\]; 0.0 is X_MIN or Y_MIN, 1.0 is X_MAX or Y_MAX.\n\n For example, a bounding box for the entire image\n is expressed as (0.0,0.0,,,1.0,1.0,,), or (0.0,0.0,1.0,0.0,1.0,1.0,0.0,1.0).\n\n The bounding box for an object can be specified in one of two ways:\n 1. Two vertices (two sets of x,y coordinates) that are diagonally opposite points of the rectangle: \n **A.** `X_MIN`,`Y_MIN` \n **C.** `X_MAX`,`Y_MAX` \n as shown in this example: \n **A,,C,** \n \u003cvar translate=\"no\"\u003eX_MIN\u003c/var\u003e`,`\u003cvar translate=\"no\"\u003eY_MIN\u003c/var\u003e`,,,`\u003cvar translate=\"no\"\u003eX_MAX\u003c/var\u003e`,`\u003cvar translate=\"no\"\u003eY_MAX\u003c/var\u003e`,,`\n 2. All four vertices specified as shown in: \n \u003cvar translate=\"no\"\u003eX_MIN\u003c/var\u003e`,`\u003cvar translate=\"no\"\u003eY_MIN\u003c/var\u003e`,`\u003cvar translate=\"no\"\u003eX_MAX\u003c/var\u003e`,`\u003cvar translate=\"no\"\u003eY_MIN\u003c/var\u003e`,\n `\u003cvar translate=\"no\"\u003eX_MAX\u003c/var\u003e`,`\u003cvar translate=\"no\"\u003eY_MAX\u003c/var\u003e`,`\u003cvar translate=\"no\"\u003eX_MIN\u003c/var\u003e`,`\u003cvar translate=\"no\"\u003eY_MAX\u003c/var\u003e`,` \n If the four specified vertices don't form a rectangle parallel to image edges, Vertex AI specifies vertices that do form such a rectangle.\n\n#### Example CSV - `object_detection.csv`:\n\n```\ntest,gs://bucket/filename1.jpeg,Tomato,0.3,0.3,,,0.7,0.6,,\ntraining,gs://bucket/filename2.gif,Tomato,0.8,0.2,,,1.0,0.4,,\ngs://bucket/filename2.gif\ngs://bucket/filename3.png,Baked goods,0.5,0.7,0.8,0.7,0.8,0.8,0.5,0.8\nvalidation,gs://bucket/filename4.tiff,Salad,0.1,0.2,,,0.8,0.9,,\n...\n \n```"]]