2

在初始读取分类器文件 (.mlmodel) 期间,我在 Watchkit 扩展中收到以下运行时错误:

“WatchKit 应用程序扩展 [441:999198] [espresso] [Espresso::handle_ex_] 异常 = 不支持的引擎类型”

我认为这是 ML 的版本问题,所以我从 Xcode 10.13 升级到 11,但仍然遇到相同的错误。当我将 ML 代码从 iPhone 的 ViewController 移动到 Watchkit Extension iWatch 的 InterfaceController 时,我才开始收到此错误。

我还注意到自动生成的分类器(.mlmodel)文件在不同的部分有不同的支持设备版本,为什么会这样?另外,我现在正在运行 MacOS Catalina Beta (10.15),但在 MacOS 和 Xcode 10.14 的 Beta 升级之前也发生了此错误。

@available(macOS 10.13,iOS 11.0,tvOS 11.0,watchOS 4.0,*)@available(macOS 10.14,iOS 12.0,tvOS 12.0,watchOS 5.0,*)

我自动生成的“GestureClassifier.mlmodel”文件的一部分似乎产生了错误,并且还显示了以下两个“@available”版本差异:

/// Class for model loading and prediction
@available(macOS 10.13, iOS 11.0, tvOS 11.0, watchOS 4.0, *)
class GestureClassifier {
    var model: MLModel

/// URL of model assuming it was installed in the same bundle as this class
    class var urlOfModelInThisBundle : URL {
        let bundle = Bundle(for: GestureClassifier.self)
        return bundle.url(forResource: "GestureClassifier", withExtension:"mlmodelc")!
    }

    /**
        Construct a model with explicit path to mlmodelc file
        - parameters:
           - url: the file url of the model
           - throws: an NSError object that describes the problem
    */
    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() {
        try! self.init(contentsOf: type(of:self).urlOfModelInThisBundle)
    }

    /**
        Construct a model with configuration
        - parameters:
           - configuration: the desired model configuration
           - throws: an NSError object that describes the problem
    */
    @available(macOS 10.14, iOS 12.0, tvOS 12.0, watchOS 5.0, *)
    convenience init(configuration: MLModelConfiguration) throws {
        try self.init(contentsOf: type(of:self).urlOfModelInThisBundle, configuration: configuration)
    }

"WatchKit App Extension[441:999198] [espresso] [Espresso::handle_ex_] exception=Unsupported engine type"
4

0 回答 0