【问题标题】:Is it possible to change the type of the input tensor in the coreml model from multiarray to image?是否可以将 coreml 模型中输入张量的类型从多数组更改为图像?
【发布时间】:2020-01-24 11:49:44
【问题描述】:

我有一个带有这些参数的 coreml 模型,我想将输入张量的类型从具有形状 (112,112,3) 的 Multiarray 更改为 RGB 图像(112,112)

Core ML input(s):
[name: "input_to_float__0"
type {
multiArrayType {
shape: 3
shape: 112
shape: 112
dataType: DOUBLE
}
}
]
Core ML output(s):
[name: "logits__BiasAdd__0"
type {
multiArrayType {
shape: 80
dataType: DOUBLE
} 
}
]

有可能吗?

我该怎么做?

【问题讨论】:

    标签: image tensorflow coreml


    【解决方案1】:

    当您将模型转换为 Core ML(使用 image_input_names)时,最容易指定这一点。

    但你也可以使用一点 Python 来解决这个问题:

    import coremltools
    import coremltools.proto.FeatureTypes_pb2 as ft
    spec = coremltools.utils.load_spec("YourModel.mlmodel")
    input = spec.description.input[0]
    input.type.imageType.colorSpace = ft.ImageFeatureType.RGB
    input.type.imageType.height = 112
    input.type.imageType.width = 112
    coremltools.utils.save_spec(spec, "YourNewModel.mlmodel")
    

    【讨论】:

    • 我解决了我的问题,我在 github 上找到了一个解决方案,感谢您的回答
    猜你喜欢
    • 2020-10-09
    • 2020-02-05
    • 2021-01-06
    • 2019-06-01
    • 1970-01-01
    • 2017-12-10
    • 2011-06-14
    • 1970-01-01
    • 2018-04-17
    相关资源
    最近更新 更多