How do i connect my auto ml python client to my app for inferences?

223 views Asked by At

I trained a model using google cloud auto ml. Then I proceeded to build an app using streamlit that can make predictions using the python client code provided by Google AutoML. But I get the error ValueError: Protocol message FieldDescriptorProto has no "proto3_optional" field.

Below is the code snippet

 uploaded_file = st.file_uploader("Choose an image...", type="jpg")
if uploaded_file is not None:
    image = Image.open(uploaded_file)
    st.image(image, caption='Uploaded Image.', use_column_width=True)
    st.write("")
    st.write("Classifying...")

    from google.cloud import automl_v1beta1
    from google.cloud import service_pb2
    from google.cloud import vision
    from google.cloud.vision import types
    import base64
    from google.cloud import automl


def list_model_evaluations(project_id, model_id):
    from google.cloud import automl
    project_id = "xxxx"
    model_id = "xxxx"

    client = automl.AutoMlClient()
    model_full_id = client.model_path(project_id, "us-central1", 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
            )
        )

Help will be greatly appreciated.

1

There are 1 answers

0
Kiril On

Probably you have some dependency incompatibility which seems quite common with protobuf. I presume you have something like 'protobuf==xx.yy.zz' in your requirements.txt file (or whatever file of dependencies you have) - can you please swap it just for 'protobuf'.