将 Tensorflow 模型导出到 CoreML 时出错

问题描述 投票:0回答:1

“顺序”对象没有属性“_get_save_spec”

import tensorflow as tf
import coremltools as ct
print(tf.__version__)
# Load your existing Keras model
model_path = "/Users/name/Desktop/model.h5"
model = tf.keras.models.load_model(model_path)

# Save the model in SavedModel format
model.save(model_path, save_format='tensorflow')

# Convert the SavedModel to CoreML, specifying the source as 'tensorflow'
coreml_model = ct.convert(model_path, source='tensorflow')

# Save the CoreML model
coreml_model.save("/Users/name/Desktop/model.mlmodel")

我被告知要降级版本,我一直降级到 TensorFlow 2.13.0。任何指导表示赞赏。

tensorflow keras coreml
1个回答
0
投票

保存前只需运行一次 model.predict() 即可。 coremltools 文档中给出了这一点。

© www.soinside.com 2019 - 2024. All rights reserved.