ios – 无法提取模型类型swift

ios – 无法提取模型类型swift,第1张

概述在尝试制作性别分类器模型时,我在使用 Swift Playgrounds时遇到了一些问题.当我将Gender.mlmodel和Gender.swift添加到Playground页面(Resources / and Sources /)中的各自文件夹时,我得到一个相当奇怪的错误,如下所示: Fatal error: ‘try!’ expression unexpectedly raised an e 在尝试制作性别分类器模型时,我在使用 Swift Playgrounds时遇到了一些问题.当我将Gender.mlmodel和Gender.swift添加到Playground页面(Resources / and Sources /)中的各自文件夹时,我得到一个相当奇怪的错误,如下所示:

Fatal error: ‘try!’ Expression unexpectedly raised an error: Error Domain=com.apple.CoreML Code=0 “Unable to extract model type from stream in compiled model: Error opening file stream: /var/folders/kt/11b_lk412hv327qjhvgnhvzr0000gn/T/com.apple.dt.Xcode.pg/auxiliarymodules/7C17E9A3-54C7-4828-96BD-00AE07EC7F3E/Gender_ClassifIEr_PageSources.framework/Resources/Gender.mlmodel/coremldata.bin: unspecifIEd iostream_category error” UserInfo={NSLocalizedDescription=Unable to extract model type from stream in compiled model: Error opening file stream: /var/folders/kt/11b_lk412hv327qjhvgnhvzr0000gn/T/com.apple.dt.Xcode.pg/auxiliarymodules/7C17E9A3-54C7-4828-96BD-00AE07EC7F3E/Gender_ClassifIEr_PageSources.framework/Resources/Gender.mlmodel/coremldata.bin: unspecifIEd iostream_category error}: file /buildroot/library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-900.0.74.1/src/swift/stdlib/public/core/ErrorType.swift,line 181

我认为它访问文件本身有一个问题,所以我尝试使用不同的位置和绝对路径作为String(在强制解包时返回一个值),但无济于事.另外,我尝试了其他我知道可以加载的模型(SqueeZenet.mlmodel),并且这样做不起作用,返回一个类似的错误.

我感谢任何人能提供的任何帮助,我对这个问题感到非常困惑.谢谢!

解决方法 我找到了解决方案:显然Swift Playgrounds没有将.mlmodel编译为.mlmodelc,从而导致无法读取未编译的模型.对于其他想知道的人,只需运行MLModel.compile(at:URL?)将其转换为编译格式. 总结

以上是内存溢出为你收集整理的ios – 无法提取模型类型swift全部内容,希望文章能够帮你解决ios – 无法提取模型类型swift所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/web/1067117.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存