我已经在 Vertex AI(GCP 中 AI Platform 下的一项服务)中训练了一个 AutoML 对象检测模型。我正在尝试访问每个标签的模型评估指标(精度、召回率、准确性等),以获取不同的置信度分数阈值和 IoU 阈值。
然而,我被困在第一步,甚至让模型的性能指标远远低于粒度级别的性能指标。我已按照此说明进行操作,但我似乎无法弄清楚是什么(另请参阅此处evaluation_id
的官方示例代码片段),即:
def get_model_evaluation_image_object_detection_sample(
project: str,
model_id: str,
evaluation_id: str,
location: str = "us-central1",
api_endpoint: str = "us-central1-aiplatform.googleapis.com",
):
# The AI Platform services require regional API endpoints.
client_options = {"api_endpoint": api_endpoint}
# Initialize client that will be used to create and send requests.
# This client only needs to be created once, and can be reused for multiple requests.
client = aiplatform.gapic.ModelServiceClient(client_options=client_options)
name = client.model_evaluation_path(
project=project, location=location, model=model_id, evaluation=evaluation_id
)
response = client.get_model_evaluation(name=name)
print("response:", response)
一段时间后,我发现对于在欧盟训练的模型,api_endpoint
应传递为:
location: str = "europe-west4"
api_endpoint: str = "europe-west4-aiplatform.googleapis.com"
但是无论我尝试什么都会evaluation_id
导致以下错误:
InvalidArgument: 400 List of found errors: 1.Field: name; Message: Invalid ModelEvaluation resource name.
它在文档中说(它似乎包含我需要的东西):
对于边界框指标,Vertex AI 返回不同 IoU 阈值(介于 0 和 1 之间)和置信阈值(介于 0 和 1 之间)的指标值数组。例如,您可以在 IoU 阈值为 0.85 和置信度阈值为 0.8228 时缩小评估指标。通过查看这些不同的阈值,您可以了解它们如何影响其他指标,例如精度和召回率。
在不知道输出数组中包含的情况下,这对每个类如何工作?基本上,我需要为每个类提供不同 IoU 阈值和置信度阈值的模型指标。
我也尝试从 AutoML API 查询,例如:
client_options = {'api_endpoint': 'eu-automl.googleapis.com:443'}
client = automl.AutoMlClient(client_options=client_options)
# Get the full path of the model.
model_full_id = client.model_path(project_id, "europe-west4", model_id)
print("List of model evaluations:")
for evaluation in client.list_model_evaluations(parent=model_full_id, filter=""):
print("Model evaluation name: {}".format(evaluation.name))
print("Model annotation spec id: {}".format(evaluation.annotation_spec_id))
print("Create Time: {}".format(evaluation.create_time))
print("Evaluation example count: {}".format(evaluation.evaluated_example_count))
print(
"Classification model evaluation metrics: {}".format(
evaluation.classification_evaluation_metrics
)
)
毫不奇怪,这也不起作用,并导致:
InvalidArgument: 400 List of found errors: 1.Field: parent; Message: The provided location ID doesn't match the endpoint. For automl.googleapis.com, the valid location ID is `us-central1`. For eu-automl.googleapis.com, the valid location ID is `eu`.