如何将对象检测模型转换为Coreml
我有使用对象检测API训练的SSD MobilenetV2模型(TensorFlow版本2.8.2)。如何将其转换为Coreml?尝试使用Coremltools(版本5.2),但失败了。
我做了以下操作:
- 使用exporter_main_v2.py将检查点转换为saved_model.pb
- 使用exporter_main_v2.py使用
tf.saved_model.load(model_path)
- 运行
coremltools.convert(modal,source,source,source =“ tensorflow”), 。
在步骤3上,我收到以下错误:
NotImplementedError: Expected model format: [SavedModel | [concrete_function] | tf.keras.Model | .h5], got <tensorflow.python.saved_model.load.Loader._recreate_base_user_object.<locals>._UserObject object at 0x7fab1a41cd90>
I have SSD MobilenetV2 model trained using object detection API (tensorflow version 2.8.2). How can I convert it to coreml? Tried to use coremltools (version 5.2), but failed.
I did the following:
- Converted checkpoints to saved_model.pb using exporter_main_v2.py
- Loaded the model using
tf.saved_model.load(model_path)
- Run
coremltools.convert(model, source="tensorflow")
On step 3 I got the following error:
NotImplementedError: Expected model format: [SavedModel | [concrete_function] | tf.keras.Model | .h5], got <tensorflow.python.saved_model.load.Loader._recreate_base_user_object.<locals>._UserObject object at 0x7fab1a41cd90>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Coremltools期望keras .H5型号,但您正在提供检查站。
您将需要实例化检查点来自相同的类模型,加载检查点,然后将模型提供给Coreml。
Coremltools is expecting a Keras .h5 model but you are providing a checkpoint.
You will need to instantiate the same class model the checkpoint came from, load the checkpoint, then provide the model to CoreML.