- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我在 App Store 上有一个应用程序,我从 Crashlytics 获取了它的错误日志。在我的项目中初始化 CoreML 模型时,用户遇到的最常见错误之一(也是我重现失败的错误)发生了。以下是我如何初始化模型:
class VisionManager: NSObject {
/// Prediction model
private static let model = MobileNet()
...
override init() {
super.init()
guard let visionModel = try? VNCoreMLModel(for: VisionManager.model.model) else {
// this case should never happen as we know for sure that the model we are using is an image classification model
fatalError("The CoreML model being used is not compatible with the Vision framework.")
}
...
}
...
}
在 Crashlytics 上看到的错误内容如下:
fatal error: 'try!' expression unexpectedly raised an error: Error Domain=com.apple.CoreML Code=0 "Error in declaring network." UserInfo={NSLocalizedDescription=Error in declaring network.}: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-900.0.65.2/src/swift/stdlib/public/core/ErrorType.swift, line 181
并且堆栈跟踪显示错误是在执行 guard
block 时抛出的。实际上,它更深入地表明错误是在调用初始化程序时在顶部的静态初始化内部抛出的。初始化器连同整个 MobileNet.swift 类是自动生成的,如下所示:
init(contentsOf url: URL) throws {
self.model = try MLModel(contentsOf: url)
}
/// Construct a model that automatically loads the model from the app's bundle
convenience init() {
let bundle = Bundle(for: MobileNet.self)
let assetPath = bundle.url(forResource: "MobileNet", withExtension:"mlmodelc")
try! self.init(contentsOf: assetPath!)
}
调用 init(contentsOf url: URL)
方法时抛出错误似乎很明显。但是,由于这是一个生成的文件,我相信我无法解决这个错误。
一种可能性是编译后的 .mlmodelc
文件没有以某种方式复制到包中,并且在尝试使用该 URL
MobileNet
对象时,我们得到一个 Uncaught Error 。这可能吗?
非常感谢关于此问题的任何想法或指示。
最佳答案
It seems obvious that the error is thrown calling the init(contentsOf url: URL) method. However, since this is a generated file, I believe there isn't much I can do to tackle this error.
仅供引用,您可以将此生成的文件复制到一个新文件中,并使用它来初始化模型(只需重命名新文件中的类)。然后,尝试更改新文件中的这一行:
let bundle = Bundle(for: MobileNet.self)
到:
let bundle = Bundle.main
我不确定这是否会解决您的特定问题,但当我将生成的文件移动到 Cocoapod 中时它对我有用
关于ios - 初始化 CoreML 模型时崩溃 : Error Domain=com. apple.CoreML Code=0 "Error in declaring network.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47339390/
我试图在创建 ML 框架的帮助下构建一个预训练的 core-ml 模型,但是创建的模型不可更新,有没有办法创建一个可以在设备本身上更新的预训练的 core-ml 模型(Core-ML 3 中新引入的功
我正在修改 this tutorial 中的代码我收到了这个错误: Error preparing CoreML model "Resnet50.mlmodel" for code generatio
我在 App Store 上有一个应用程序,我从 Crashlytics 获取了它的错误日志。在我的项目中初始化 CoreML 模型时,用户遇到的最常见错误之一(也是我重现失败的错误)发生了。以下是我
考虑一个 csv 文件,如下所示: number,weigth,length,depth,diameter 1,100,202,314,455 2,1040,2062,3314,4585 3,1200
我想实现一个应用程序,能够识别相机输入的图片。我的意思不是对象的分类,而是从给定的图像集中检测精确的单个图像。因此,如果我有一个包含 500 张照片的相册,那么如果我将相机指向其中一张照片,那么应用程
我尝试将 sklearn normalizer 转换为 coreml 模型,如下所示: normalized = sklearn.preprocessing.Normalizer() coreml_m
我刚刚开始探索 CoreML,想知道是否有一种方法可以使用它来训练二元分类模型。 请提供任何引用资料或示例,因为我是 ML 菜鸟。 最佳答案 Core ML 不提供任何用于构建或训练模型的 API。它
我对 CoreML 有疑问,因为当我希望程序验证图像时出现错误: [coreml] Error Domain=com.apple.CoreML Code=1 "Input image feature
有很多教程如何使用 ML 在图像上打印检测到的顶级对象,例如 let request = VNCoreMLRequest(model: model) { [weak self] request, er
我目前正在创建一个 hello world,以便大致了解 CoreML 和 CreateML 的强大功能。我的目标是使用 Apples data table example在我的 hello worl
我用过这个library建立音频分类模型。然后我将这个模型转换为 CoreML。后来想在这段代码中实现模型https://github.com/robmsmt/kDS2iOS/ 我对此有疑问,因为模型
我正在为我当前的 objc 项目使用 CoreML。通常,.mlmodel 文件会自动生成一个 .h 文件,供我在我的 viewcontroller 中导入模型类。但是如果我在项目中导入一些 swif
我已经使用 coremltools 从 keras 转换模型,将其添加到项目并添加到目标。然后当我在模型类部分的导航器中按下模型时,我得到“模型类尚未生成。”。什么意思? 最佳答案 引用自苹果开发者论
let model = test2() var data = [1.0, 2.0,2.0,2.0,2.0,2.0,2.0] guard let mlMultiArray
我是 Core ML 的新手,但到目前为止玩得很开心。我目前正在学习如何通过在 Playground 上创建模型并验证其结果来训练模型进行面部识别。我保存 .mlmodel 并在我的应用程序中实现它。
我正在与应用程序扩展共享 CoreML 模型。 Xcode 为模型生成快速代码。为了在扩展中使用该代码,我还必须在应用程序扩展中包含相同的模型。有没有办法在应用程序中只包含一次模型,并在应用程序和扩展
我创建了一个图像相似性模型,并使用引用数据图像对其进行了测试。我测试了 turicreate 模型,我得到了引用数据图像的零距离,并且在将这段代码与 coreml 模型一起使用时也得到了同样的结果:
我想使用 CoreML 和 ARKit 检测门、窗等对象类别,我想找到门的测量值(如高度、宽度和面积)。 如何检测对象并在该对象上添加一些叠加形状,以便我可以找到该对象的真实世界位置和测量值? 最佳答
在 SO 和 reddit 上搜索问题后,我不知道如何在 ML 文本分类器上训练多输入、多输出分类器。我可以训练单个输入、单个输出文本分类器,但这不适合我的用例。 如有任何帮助,我们将不胜感激。我知道
我正在使用 CoreML 和 ARKit 进行人脸识别。但我不想用应用程序构建 CoreML 模型。我用 python Turicate 制作了一个 coreML 模型。我希望这个模型放在服务器上,它
我是一名优秀的程序员,十分优秀!