coremltools: Keras model converted to ML Program doesn't load in Xcode
πDescribe the bug
If you convert a Keras model to ML Program, it doesnβt work at all.
- Shows a warning while converting (see Trace below)
- Shows an error in Xcode:
Trace
Running TensorFlow Graph Passes: 100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 5/5 [00:00<00:00, 98.66 passes/s]
Converting Frontend ==> MIL Ops: 100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 4/4 [00:00<00:00, 13842.59 ops/s]
Running MIL Common passes: 100%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 31/31 [00:00<00:00, 59398.55 passes/s]
Running MIL FP16ComputePrecision pass: 100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 1/1 [00:00<00:00, 1912.59 passes/s]
Running MIL Clean up passes: 100%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 8/8 [00:00<00:00, 11869.27 passes/s]
/Users/x/miniforge3/envs/tf/lib/python3.9/site-packages/coremltools/models/model.py:122: RuntimeWarning: You will not be able to run predict() on this Core ML model. Underlying exception message was: Error compiling model: "Error reading protobuf spec. validator error: Model specification version field missing or corrupt.".
_warnings.warn(
To Reproduce
from tensorflow import keras
from tensorflow.keras import layers
import coremltools as ct
input = keras.Input(shape=[10])
output = layers.Dense(10)(input)
model = keras.Model(input, output)
model.compile(optimizer='adam', loss='mse')
mlmodel = ct.convert(model, minimum_deployment_target=ct.target.iOS15)
mlmodel.save('model.mlpackage')
System environment (please complete the following information):
- coremltools version (e.g., 3.0b5): 5.0b4
- OS (e.g., MacOS, Linux): macOS
- macOS version (if applicable): 11.6
- XCode version (if applicable): 13.0 RC
- How you install python (anaconda, virtualenv, system): anaconda
- python version (e.g. 3.7): 3.9.4
- any other relevant information:
- TensorFlow version: 2.5.0
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (1 by maintainers)
@iutlu - yes, please create a separate GitHub issue. I donβt believe your having the same problem.
@imxieyi - is this still an issue with the latest (non-RC) version of Xcode?