python - 如何将我的 auto ml python 客户端连接到我的应用程序以进行推理?
问题描述
我使用 google cloud auto ml 训练了一个模型。然后我开始使用 streamlit 构建一个应用程序,该应用程序可以使用 Google AutoML 提供的 python 客户端代码进行预测。但我得到了错误ValueError: Protocol message FieldDescriptorProto has no "proto3_optional" field
。
下面是代码片段
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
)
)
帮助将不胜感激。
解决方案
可能你有一些依赖不兼容,这在 protobuf 中似乎很常见。我认为您的 requirements.txt 文件(或您拥有的任何依赖项文件)中有类似 'protobuf==xx.yy.zz' 的内容 - 您能否将其换成 'protobuf'。
推荐阅读
- reactjs - Running Express.js inside Next.js
- reactjs - 我如何测试反应功能组件的状态?
- python - 如何在 python (SWIG) 中调用 C++ 成员函数?
- r - 为什么变量在传说中被认为是连续的?
- python - Boost Python - 调试嵌入在 C++ 中的 Python 代码
- wildfly - 更新我的耳朵依赖项以匹配新 Wildfly 版本的模块
- listview - ListView在android kotlin中的不同视图
- asp.net-core - 当具有大记录的导航/嵌套属性然后在 EnableQueryAttribute 中指定页面大小时,OData 引发错误
- connection-pooling - 通过 tomcat 8.5 连接到 Oracle8 的选项
- database-design - 初学者 AppleScript Writer:使用循环将许多变量写入脚本