tf2-mobile-2d-single-pose-estimation icon indicating copy to clipboard operation
tf2-mobile-2d-single-pose-estimation copied to clipboard

Convert to Core ML

Open tucan9389 opened this issue 5 years ago • 12 comments

tucan9389 avatar Apr 02 '19 08:04 tucan9389

https://apple.github.io/coremltools/

coremltools 2.0.0 does not support tensorflow 2.0 yet. 😟

coremltools has the following dependencies:

- numpy (1.12.1+)
- protobuf (3.1.0+)

In addition, it has the following soft dependencies that are only needed when you are converting models of these formats:

- Keras (1.2.2, 2.0.4+) with Tensorflow (1.0.x, 1.1.x)
- Xgboost (0.6+)
- scikit-learn (0.15+)
- libSVM

Alternatively, I'll port to pure Keras project, and then train and convert the model to Core ML model.

tucan9389 avatar Apr 02 '19 23:04 tucan9389

Related issue on Sep 2, 2018 (not solved): https://github.com/apple/coremltools/issues/231

tucan9389 avatar Apr 03 '19 08:04 tucan9389

Hi @tucan9389, have you tried tf2/tf.keras -> ONNX -> CoreML conversion?

AndriiTsok avatar Apr 14 '19 17:04 AndriiTsok

@AndriiTsok No, did you try in that way? or others?

tucan9389 avatar Apr 15 '19 02:04 tucan9389

ValueError: Keras layer '<class 'tensorflow.python.keras._impl.keras.engine.topology.InputLayer'>' not supported.

The issue was solved replacing TF-2.0-alpha0 to TF-1.13.1.

tucan9389 avatar Apr 29 '19 05:04 tucan9389

Hi @tucan9389, did the conversion from tf2/tf.keras -> ONNX -> CoreML work when you replaced to TF-1.13.1?

EDIT: Found your 0.1 release containing release/cpm_model/model.* Are these the models from the PoseEstimation-CoreML repository, or this one?

abrowne2 avatar May 28 '19 18:05 abrowne2

@abrowne2 0.1 version is just cloned from edvardHua/PoseEstimationForMobile repostory. It's same with PoseEstimation-CoreML.

tucan9389 avatar Jun 04 '19 05:06 tucan9389

TODO

  • tf.keras model(.h5) → frozen pb(.pb) → coreml model(.mlmodel)

Related issue

  • https://github.com/tf-coreml/tf-coreml/issues/305

tucan9389 avatar Jun 04 '19 05:06 tucan9389

https://github.com/apple/coremltools/issues/446

tucan9389 avatar Sep 13 '19 10:09 tucan9389

Are there any news on converting .pb to .mlmodel file?

idchlife avatar May 11 '20 09:05 idchlife

Are there any news on converting .pb to .mlmodel file?

No in this repo, but the coremltools’s related issue was closed! I’ll try again.

tucan9389 avatar May 11 '20 23:05 tucan9389

TF2's saved_model is only supported on iOS 13 (minimum_ios_deployment_target=13) now.

tucan9389 avatar Jun 21 '20 18:06 tucan9389