【问题标题】:Can Google's AutoML export trained models for offline inference?Google 的 AutoML 可以导出训练有素的模型以进行离线推理吗?
【发布时间】:2019-01-22 19:59:08
【问题描述】:

AutoML 看起来很棒。一个大问题是 - 我们能否导出训练后的模型以进行离线推理,例如使用 tensorflow 或 tensoflow lite?

【问题讨论】:

    标签: google-cloud-platform automl google-cloud-automl


    【解决方案1】:

    自 2019 年 3 月起不支持此功能。如果您对此功能感兴趣,请将此请求加注星标: https://issuetracker.google.com/issues/113122585

    如果 Google 自此回答后实施了该功能,请检查该链接。

    更新:已添加对分类的初始支持,但尚未检测。请参阅 Peter Gibson 的回答。

    【讨论】:

    • 现在提供初步支持(至少对于 AutoML 视觉分类器)。请参阅下面的答案。
    【解决方案2】:

    编辑:现在可以导出图像分类和对象检测模型。见https://cloud.google.com/vertex-ai/docs/export/export-edge-model#object-detection

    原始答案如下

    AutoML Vision 的当前状态(2019 年 8 月)是您可以导出 AutoML 图像分类模型,但不能导出对象检测。此功能处于测试阶段(AutoML Vision 本身也是如此)。我找不到其他 AutoML 产品的详细信息,也没有亲自尝试过,所以我不确定它们的状态。

    来自https://cloud.google.com/vision/automl/docs/

    AutoML Vision Edge 现在允许您导出经过自定义训练的 模型。

    • AutoML Vision Edge 允许您训练和部署针对边缘设备优化的低延迟、高精度模型。
    • 借助 Tensorflow Lite、Core ML 和容器导出格式,AutoML Vision Edge 支持多种设备。
    • 支持的硬件架构:Edge TPU、ARM 和 NVIDIA。
    • 要在 iOS 或 Android 设备上构建应用程序,您可以使用 ML Kit 中的 AutoML Vision Edge。此解决方案可通过 Firebase 获得 并提供用于创建和部署的端到端开发流程 使用 ML Kit 客户端库为移动设备定制模型。

    文档https://cloud.google.com/vision/automl/docs/edge-quickstart

    我训练了一个分类模型,导出了 tflite 模型(它导出到云存储),并且能够下载模型文件并使用 Python API 将它们加载到 tensorflow 中,而无需太多麻烦。下面是加载模型和运行推理的相关代码:

    基于https://www.tensorflow.org/lite/guide/inference#load_and_run_a_model_in_python

    # Load TFLite model and allocate tensors.
    interpreter = tf.lite.Interpreter(model_path=MODEL_PATH)
    interpreter.allocate_tensors()
    
    # Get input and output tensors.
    input_details = interpreter.get_input_details()
    output_details = interpreter.get_output_details()
    
    def predict(frame):
        interpreter.set_tensor(input_details[0]['index'], frame)
        interpreter.invoke()
    
        # The function `get_tensor()` returns a copy of the tensor data.
        # Use `tensor()` in order to get a pointer to the tensor.
        output_data = interpreter.get_tensor(output_details[0]['index'])
    

    【讨论】:

      【解决方案3】:

      应该是这样的:

      https://cloud.google.com/vision/automl/docs/deploy

      请注意,导出选项(至少目前)不会出现在您已经训练好的模型上。您必须选择其中一个模型并进行训练,然后您可以选择将模型留在云端或生成边缘版本。

      您可以以任一通用格式导出图像分类模型 TensorFlow Lite 格式、Edge TPU 编译的 TensorFlow Lite 格式,或 TensorFlow 格式使用 导出模型 API。

      【讨论】:

      • 欢迎来到 Stack Overflow!虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接的答案可能会失效。
      【解决方案4】:

      目前尚无法从 AutoML 导出模型。 @Infinite Loops、automl 和 ml 引擎是不同的产品。

      【讨论】:

      • 是否可以从 ML Engine 导出?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-05-24
      • 1970-01-01
      • 2018-11-29
      • 1970-01-01
      • 2020-06-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多