调用Google Vertex ImageDataset的import_data时如何指定标注集ID?
解决方案:指定现有标注集导入数据
问题核心:调用
import_data时若未指定目标标注集,Vertex AI会自动创建新标注集。要将数据导入已有的my_dataset_iod标注集,只需在import_data方法中添加annotation_set_id参数,传入你获取到的对应标注集ID即可。修改后的代码示例:
from google.cloud import storage from google.cloud import aiplatform from datetime import datetime ..... current_datetime = datetime.now().strftime('%Y-%m-%d_%H-%M-%S') jsonl_file_name = f"data_{current_datetime}.jsonl" jsonl_blob = bucket.blob(jsonl_file_name) jsonl_blob.upload_from_string(jsonl_string, content_type='application/jsonl') dataset = aiplatform.ImageDataset(f"projects/{project_id}/locations/us-central1/datasets/{dataset_id}") # 替换为你获取到的my_dataset_iod对应的annotationSetId target_annotation_set_id = "your_my_dataset_iod_annotation_set_id" dataset.import_data( gcs_source=[f"gs://{bucket_name}/{jsonl_file_name}"], import_schema_uri='gs://google-cloud-aiplatform/schema/dataset/ioformat/image_bounding_box_io_format_1.0.0.yaml', annotation_set_id=target_annotation_set_id )
- 说明:
annotation_set_id参数接受字符串格式的标注集ID,传入后,导入的图像及标注数据会直接追加到指定的现有标注集中,不会再自动生成新的标注集。
内容的提问来源于stack exchange,提问作者Will
相关产品推荐
相关产品推荐

