Python 来自颤振的GCP AI平台预测请求

Python 来自颤振的GCP AI平台预测请求,python,flutter,tensorflow,google-cloud-platform,Python,Flutter,Tensorflow,Google Cloud Platform,我已经在GCP AI平台上部署了一个模型,可以成功地从我的Jupyter笔记本请求预测。然而,我需要执行来自颤振应用程序的请求,似乎找不到这样做的方法 以下代码在笔记本上运行良好: from google.api_core.client_options import ClientOptions from googleapiclient import discovery endpoint = 'https://australia-southeast1-ml.googleapis.com' cli

我已经在GCP AI平台上部署了一个模型,可以成功地从我的Jupyter笔记本请求预测。然而,我需要执行来自颤振应用程序的请求,似乎找不到这样做的方法

以下代码在笔记本上运行良好:

from google.api_core.client_options import ClientOptions
from googleapiclient import discovery

endpoint = 'https://australia-southeast1-ml.googleapis.com'
client_options = ClientOptions(api_endpoint=endpoint)
ml = discovery.build('ml', 'v1', client_options=client_options)

request_body = { 'instances': [image_content] }
request = ml.projects().predict(
    name='projects/[PROJECT_NAME]/models/[MODEL_NAME]/versions/version1/',
    body=request_body)

response = request.execute()
print(response)

有没有办法将此python代码转换为dart以在我的颤振应用程序中使用?

是的,有dart包可用于连接GCP AI平台

  • Dart的AI平台培训和预测API可在以下位置找到。您可以使用合适的类来请求预测
  • 其他适用于Dart的Google Cloud API可在此处获得。您可以在“示例”部分找到Dart存储API的示例,以供参考