【问题标题】:CoreML model converted from TensorFlow unable to use inside Xcode从 TensorFlow 转换的 CoreML 模型无法在 Xcode 中使用
【发布时间】:2020-06-08 09:07:48
【问题描述】:

我使用 Tensorflow GPU 和 Mobilenet v2 作为预训练模型训练了一个模型,之后我尝试将其转换为 CoreML,如 .mlmodel。我读到您需要添加一些前/后预处理,为此您可以创建一个管道并在 Xcode 中使用该管道。我试过使用他们的例子,可以在这里找到:

https://github.com/hollance/coreml-survival-guide/blob/master/MobileNetV2%2BSSDLite/ssdlite.py

转换成功,但我无法在 Xcode 中使用它,我收到此错误并且我不知道如何解决它,因为此过程没有完整记录。错误:

Error Domain=com.apple.vis Code=3 "The VNCoreMLTransform request failed" UserInfo={NSLocalizedDescription=The VNCoreMLTransform request failed, NSUnderlyingError=0x2828e8b40 {Error Domain=com.apple.CoreML Code=0 "Failed to evaluate model 1 in pipeline" UserInfo={NSLocalizedDescription=Failed to evaluate model 1 in pipeline, NSUnderlyingError=0x2828e9560 {Error Domain=com.apple.CoreML Code=0 "Shape (2 x 1 x 1917) was not in enumerated set of allowed shapes" UserInfo={NSLocalizedDescription=Shape (2 x 1 x 1917) was not in enumerated set of allowed shapes}}}}}

这也是模型的外观:

【问题讨论】:

    标签: swift tensorflow coreml coremltools


    【解决方案1】:

    您的一个模型生成(2 x 1 x 1917) 形状的数据,但管道中的下一个模型不允许此形状的输入。

    您需要使管道中不同模型之间的输入/输出形状匹配。 (并确保模型实际上生成了这些形状的数据;仅仅因为 mlmodel 说形状是某种东西并不意味着它实际上是正确的。)

    【讨论】:

      猜你喜欢
      • 2020-08-25
      • 2018-09-12
      • 2020-01-24
      • 2020-05-21
      • 2019-12-18
      • 2018-06-14
      • 2019-04-02
      • 2017-11-30
      • 2019-07-22
      相关资源
      最近更新 更多