首页 > 解决方案 > 如何正确使用 tf-coreml?

问题描述

我想将 tensorflow 模型(https://github.com/vanhuyz/CycleGAN-TensorFlow)转换为 coreml 模型,以便能够在 iOS 上导入它。

我知道要执行转换,使用这段代码就足够了:

import tfcoreml as tf_converter

tf_converter.convert(tf_model_path = 'my_model.pb', 
                     mlmodel_path = 'my_model.mlmodel', 
                     output_feature_names = ['softmax:0'])

但我不知道在第三个参数“output_feature_names”中放什么。有什么想法?

标签: tensorflowcoremlgenerative-adversarial-network

解决方案


如果您使用Netron打开 .pb 文件并一直滚动到底部,您会看到最后一层是 EncodeJpeg,因此输出特征名称将是EncodeJpeg:0.

但是,Core ML 没有“encode jpeg”操作,因此您无法转换整个图形。您需要找到 Core ML 仍然支持的最后一个张量。

我会尝试output_feature_names=["G_7/output/Tanh:0"],但很可能图中还有其他无法转换的东西。


推荐阅读