I trained a custom model for named entity recognition using Automl service on GCP. Here is my code to run it using 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))
I get this internal error in predict
function:
six.raise_from(exceptions.from_grpc_error(exc), exc) File "", line 3, in raise_from google.api_core.exceptions.InternalServerError: 500 Internal error encountered.
Can someone from GCP explain the source of error and how to fix it?