image - 是否可以将 coreml 模型中输入张量的类型从多数组更改为图像?

标签 image tensorflow coreml

我有一个具有这些参数的 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
} 
}
]

enter image description here

可以这样做吗?

我怎样才能做到这一点?

最佳答案

当您将模型转换为 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")

关于image - 是否可以将 coreml 模型中输入张量的类型从多数组更改为图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58078858/

相关文章:

html - 将图像作为边框适合任意大小的 div

html - img alt 文本很长时不显示

swift - CoreML Vision 人脸检测的输入图像大小要求是多少

ios - 机器学习算法的训练强度如何?

css - 将文本对齐到图像的右侧 && 文本不会环绕图像

html - 我如何放置多个包含文本和 float 图像的 div,以便它们一次一个地沿着页面向下流动并且不重叠?

python - TensorFlow/Sklearn 深度神经网络分类器类型错误

tensorflow - Google ML-Engine 中的 keras 模型预测失败

concatenation - TensorFlow 将可变大小的占位符与向量连接起来

python - 导入 coremltools 时出错 - 无法导入名称 ParametricSoftPlus