【问题标题】:How to access the model's description in CoreML?如何在 CoreML 中访问模型的描述?
【发布时间】:2021-02-09 21:13:35
【问题描述】:

我有一个 CoreML 模型,并使用 coremltools 向模型中添加了信息:

model.author = 'Vincent Garcia'
model.license = 'BSD'
model.short_description = 'The model is doing something.'

有没有办法从 Swift 访问这些信息?

在 Apple 的文档中是这样写的:

检查模型的元数据和 MLFeatureDescription 实例 通过模型描述。

我试过了:

let model = try! MyModel(configuration: MLModelConfiguration())
let desc = model.modelDescription

但我收到以下错误:

“MyModel”类型的值没有成员“modelDescription”

看来我没有正确使用文档。 感谢您的帮助!

【问题讨论】:

    标签: swift coreml coremltools


    【解决方案1】:

    MyModel 不是MLModel 对象,而是专门为您的模型生成的类。但是,它内部确实有一个 MLModel 对象,在 model 属性中。

    您可以像这样访问描述:

    let model = try! MyModel(configuration: MLModelConfiguration())
    let desc = model.model.modelDescription
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-18
      • 1970-01-01
      • 1970-01-01
      • 2014-11-30
      • 2018-05-29
      相关资源
      最近更新 更多