swift - CICoreMLModelFilter 抛出 "Unsupported engine type"

标签 swift core-graphics core-image coreml

CoreImage 中有这个新的但仍未记录的 CICoreMLModelFilter。它有两个参数:

inputImage - The image to use as an input image. For filters that also use a background image, this is the foreground image.

inputModel - The CoreML model to be used for applying effect on the image.

这个想法非常简单 - 拍摄一张图片,应用风格转换,然后生成风格化的图片。

所以我将 CoreML 模型加载到我的测试应用程序中并尝试将此模型作为 inputModel 键传递:

guard
    let mlFilter = CIFilter(name: "CICoreMLModelFilter")
else {
    return nil
}

let model = StarryStyle().model

mlFilter.setValue(workingImage, forKey: "inputImage")
mlFilter.setValue(model, forKey: "inputModel")

guard
    let mlResult = mlFilter.outputImage
else {
    return nil
}

每当我尝试运行这个非常简单的代码时,我都会遇到以下异常:

[Espresso::handle_ex_] exception=Unsupported engine type

无论我尝试加载什么 MLModel,它总是抛出上述异常。我在 Mojave (10.14) 上运行 Swift 4.2。

有人试过 CoreImage 和 CoreML 吗?

最佳答案

我在 Mac OS 10.14 上遇到此错误 - 在 iOS 12 sans 错误和早期版本的 Mac OS - 10.13 上运行良好的模型上。最初我认为这与浮点量化有关,但我在非量化 float 32 模型和不同设备上尝试过这个,并为以下模型获取它:

  • 输出/运行推理良好
  • 使用标准的 CoreML/Vision API
  • 在集成或独立 GPU 上运行
  • 在 iMac Pro AMD GPU 上
  • 在 MBP Nvidia GPU 上

我不确定这是否只是处理的一些内部异常 - 在 AMD 上,我得到一个稍微不同的错误;

[Espresso:handle_ex_] exception=<private>

我开始认为它是无害的?

关于swift - CICoreMLModelFilter 抛出 "Unsupported engine type",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52576753/

相关文章:

ios - swift : textFieldShouldBeginEditing function fix

swift - 是否可以在 Swift macOS 中使 NSBox 可点击(如 NSButton)?

ios - imageWithCGImage : GCD memory issue

iphone - 使用 CGContextScaleCTM 时避免拉伸(stretch)行程

ios - CI过滤器组合

ios - Core Image 会立即加载图像数据吗?

ios - 使用 CIFilter 后图像自动旋转

ios - 将iOS原生相机应用借用到我自己的应用中

ios - 在 UserDefaults 中编辑结构而不丢失数据 Swift

iphone - 如何在 iOS 上设置向上移动的渐变动画