【问题标题】:How to call the AutoML Vision model prediction from an iOS app in swift?如何从 iOS 应用程序中快速调用 AutoML Vision 模型预测?
【发布时间】:2020-06-15 20:51:45
【问题描述】:

我正在研究 Google Cloud AutoML 视觉对象检测。 我正在关注下面的教程https://cloud.google.com/vision/automl/object-detection/docs/prepare

由于我想要一个自定义模型,我创建了一个新数据集并对其进行了训练。在训练期间,它要求为我的模型在 Cloud HostedEdge 之间进行选择。我选择了云托管

要使用此云托管模型/预测图像,我们需要从我们端进行 Rest API 调用。在本教程中,提到了如何在各种客户端库中进行这些 Rest API 调用,而不是在 Swift 中。我想知道如何从 iOS 应用程序通过 Swift 进行此 Rest API 调用。

如何执行 REST API?

给出关于 Rest API 的信息

request.json

{
 "payload": {
 "image": {
   "imageBytes": "YOUR_IMAGE_BYTE"
  },
 }
}

执行请求

curl -X POST -H "Content-Type: application/json" \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
https://automl.googleapis.com/v1beta1/projects/drughk-9747d/locations/us-central1/models/ICN6566958205491349320:predict -d @request.json

【问题讨论】:

    标签: ios swift google-cloud-platform google-api google-cloud-firestore


    【解决方案1】:

    查看Cloud Vision Swift Sample,特别是ImagePickerViewController.swift,其中 createRequest 方法使用 API_KEY 调用 Google API for ImageDetection 来验证请求。

    【讨论】:

    猜你喜欢
    • 2019-01-04
    • 2019-02-13
    • 1970-01-01
    • 2021-10-31
    • 2019-02-06
    • 2020-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多