我使用 GCP 上的 Automl 服务为命名实体识别训练了一个自定义模型。这是我使用 python 运行它的代码:
from google.cloud import automl
# TODO(developer): Uncomment and set the following variables
# project_id = "YOUR_PROJECT_ID"
# model_id = "YOUR_MODEL_ID"
# content = "text to predict"
prediction_client = automl.PredictionServiceClient()
# Get the full path of the model.
model_full_id = automl.AutoMlClient.model_path(
project_id, "us-central1", model_id
)
text_snippet = automl.TextSnippet(
content=text_content, mime_type="text/plain"
)
payload = automl.ExamplePayload(text_snippet=text_snippet)
response = prediction_client.predict(name=model_full_id, payload=payload)
for annotation_payload in response.payload:
print(
"Text Extract Entity Types: {}".format(
annotation_payload.display_name
)
)
print(
"Text Score: {}".format(annotation_payload.text_extraction.score)
)
text_segment = annotation_payload.text_extraction.text_segment
print("Text Extract Entity Content: {}".format(text_segment.content))
print("Text Start Offset: {}".format(text_segment.start_offset))
print("Text End Offset: {}".format(text_segment.end_offset))
我在函数中得到这个内部错误predict
:
六.raise_from(exceptions.from_grpc_error(exc),exc)文件“”,第3行,在raise_from google.api_core.exceptions.InternalServerError:500遇到内部错误。
GCP 的人可以解释错误的来源以及如何解决它吗?