Я получаю следующую ошибку времени выполнения при первоначальном вызове моего жеста-классификатора.mlmodel в расширении приложения Watchkit - PullRequest
1 голос
/ 06 июля 2019

Я получаю следующую ошибку времени выполнения в расширении Watchkit во время первоначального чтения файла классификатора (.mlmodel):

"Расширение приложения WatchKit [441: 999198] [espresso] [Espresso :: handle_ex_] исключение = не поддерживаетсятип двигателя "

Я думал, что это проблема с версией ML, поэтому я обновил Xcode 10.13 до 11 и все еще получаю ту же ошибку.Я начал получать эту ошибку только тогда, когда переместил свой код ML с iPhone ViewController в расширение Watchkit InterfaceController iWatch.

Я также заметил, что файл автоматически сгенерированного классификатора (.mlmodel) имеет разные версии поддерживаемых устройств в разных разделах,с чего бы это?Кроме того, сейчас я использую MacOS Catalina Beta (10.15), но эта ошибка также возникала до того, как было доступно бета-обновление MacOS и Xcode 10.14.

@ (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"
...