簡體   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