繁体   English   中英

为 Xamarin.iOS 将 .mlmodel 编译为 .mlmodelc?

[英]Compile .mlmodel to .mlmodelc for Xamarin.iOS?

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

您可以使用Xcode编译您的模型:

xcrun coremlcompiler compile MyModel.mlmodel MyModel.mlmodelc

这将输出您可以添加到项目中的.mlmodelc。

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

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

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

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

步骤 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_name.mlmodelc 是转换后的modelc 名称(名称不必相同)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM