【问题标题】:Compile .mlmodel to .mlmodelc for Xamarin.iOS?为 Xamarin.iOS 将 .mlmodel 编译为 .mlmodelc?
【发布时间】:2018-06-09 22:31:43
【问题描述】:

我想将 CoreML 用于我的 Xamarin.iOS 应用,但如何使用模型? developer.xamarin 中的所有示例都使用 .mlmodelc,但我下载了 .mlmodel。如何转换为 .mlmodelc?

【问题讨论】:

    标签: ios xamarin machine-learning xamarin.ios coreml


    【解决方案1】:

    你可以使用 Xcode 来编译你的模型:

    xcrun coremlcompiler compile MyModel.mlmodel MyModel.mlmodelc
    

    这会输出一个 .mlmodelc,您可以将其添加到您的项目中。

    或者您可以使用MLModel.compileModel(at:) 在您的应用中动态执行此操作。

    【讨论】:

      【解决方案2】:

      您也可以在 Mac 终端中使用此命令:

      /Applications/Xcode.app/Contents/Developer/usr/bin/coremlc compile coreml.mlmodel
      

      【讨论】:

      • 记得放输出路径("coremlc: Error: compile command missing destination path")
      【解决方案3】:

      您可以按照以下步骤操作:

      第 1 步:打开终端并使用“pwd”命令检查当前目录。

      第 2 步:使用 cd 命令从 .mlmodel 文件所在的当前目录转到您的目录/文件夹,例如:'cd Desktop/mlfolder'。

      第 3 步:输入以下命令

         /Applications/Xcode.app/Contents/Developer/usr/bin/coremlc compile model_name.mlmodel model_name.mlmodelc
      

      注意:这里model_name.mlmodel是mlmodel的名字(你可以在这里命名你的model名字),model_name.mlmodelc是转换后的modelc名字(名字可以不一样)。

      【讨论】:

        猜你喜欢
        • 2021-07-09
        • 2021-01-25
        • 2017-11-11
        • 2018-09-12
        • 2019-05-22
        • 1970-01-01
        • 2016-07-01
        • 2012-05-15
        • 2013-07-19
        相关资源
        最近更新 更多