[英]Compile .mlmodel to .mlmodelc for Xamarin.iOS?
I want to use CoreML for my Xamarin.iOS app but how can I use models?我想将 CoreML 用于我的 Xamarin.iOS 应用程序,但如何使用模型? All samples in developer.xamarin is use .mlmodelc but I downloaded .mlmodel. developer.xamarin 中的所有示例都使用 .mlmodelc,但我下载了 .mlmodel。 How can I convert to .mlmodelc?如何转换为 .mlmodelc?
You can use Xcode to compile your model: 您可以使用Xcode编译您的模型:
xcrun coremlcompiler compile MyModel.mlmodel MyModel.mlmodelc
This outputs an .mlmodelc that you can add to your project. 这将输出您可以添加到项目中的.mlmodelc。
Or you can do it dynamically inside your app by using MLModel.compileModel(at:)
. 或者您可以使用MLModel.compileModel(at:)
在应用程序内动态执行此操作。
您也可以在Mac终端中使用此命令:
/Applications/Xcode.app/Contents/Developer/usr/bin/coremlc compile coreml.mlmodel
You can follow the below steps:您可以按照以下步骤操作:
Step 1: Open Terminal and check the present directory using 'pwd' command.步骤 1:打开终端并使用“pwd”命令检查当前目录。
Step 2: Go to your directory/folder from present directory where .mlmodel file is located using cd command, example: 'cd Desktop/mlfolder'.第 2 步:使用 cd 命令从 .mlmodel 文件所在的当前目录转到您的目录/文件夹,例如:'cd Desktop/mlfolder'。
Step 3: Enter below command第 3 步:输入以下命令
/Applications/Xcode.app/Contents/Developer/usr/bin/coremlc compile model_name.mlmodel model_name.mlmodelc
Note: here model_name.mlmodel is the name of the mlmodel(you can name your model name here) and model_name.mlmodelc is the converted modelc name(name need not be same).注意:这里的model_name.mlmodel 是mlmodel 的名称(你可以在这里命名你的模型名称),model_name.mlmodelc 是转换后的modelc 名称(名称不必相同)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.