【问题标题】:Split a pre-trained CoreML model into two将预训练的 CoreML 模型拆分为两部分
【发布时间】:2019-12-27 21:40:39
【问题描述】:

我在这里有一个来自 turicreate 示例的声音分类模型: https://apple.github.io/turicreate/docs/userguide/sound_classifier/

我正在尝试将此模型分成两部分,并使用 coremltools 库将这两个部分保存为单独的 CoreML 模型。谁能指导我如何做到这一点?

我可以加载模型,甚至可以打印出模型的规格。但不知道从这里去哪里。

import coremltools

mlmodel = coremltools.models.MLModel('./EnvSceneClassification.mlmodel')

# Get spec from the model
spec = mlmodel.get_spec()

输出应该是两个 CoreML 模型,即上述模型分为两部分。

【问题讨论】:

    标签: coreml coremltools


    【解决方案1】:

    我不能 100% 确定声音分类器模型是什么样的。如果是管道,您可以将管道中的每个子模型保存为单独的 mlmodel 文件。

    如果不是管道,则需要进行一些模型手术。您需要从规范中删除层(使用del spec.neuralNetworkClassifier.layers[a:b])。

    您还需要更改第一个模型的输入和第二个模型的输出以考虑删除的层。

    【讨论】:

      猜你喜欢
      • 2017-12-01
      • 2019-04-14
      • 1970-01-01
      • 2021-09-10
      • 2020-09-30
      • 2019-01-12
      • 1970-01-01
      • 2020-07-27
      • 2020-06-27
      相关资源
      最近更新 更多