Coremltools: warning at Keras model convert to mlmodel

Created on 23 Nov 2020  路  4Comments  路  Source: apple/coremltools

鉂換uestion

System Information

  • If applicable

I want to convert my own Keras model, which input/output is only one dim, when I try to convert it into coreml format, always get warming like, and this warming turn out to be an error in Xcode

/anaconda3/envs/speech/lib/python3.6/site-packages/coremltools/models/model.py:119: RuntimeWarning: You will not be able to run predict() on this Core ML model. Underlying exception message was: { NSLocalizedDescription = "Error in declaring network."; } RuntimeWarning,

my model structure is

def denoise_model(hidden = 48, kernel_size = 8, strides = 2, ):

input_shape = Input(shape=(37920, ))
x = Reshape((37920, 1))(input_shape)
x = Conv1D(filters = hidden,
           kernel_size = kernel_size,
           strides = strides,
           padding= 'same')(x)
x = Activation('relu')(x)

x = Conv1D(filters = hidden * 2,
           kernel_size = 1)(x)
x = Activation('relu')(x)
x = keras.layers.Flatten()(x)

return Model(inputs = input_shape, outputs = x)

and my convert code is

mlmodel = coremltools.converters.keras.convert(model,)

question

Most helpful comment

I found that if I set input shape like (16384, ), mlmodel can convert successfully.
but if input shape higher than 16384,
RuntimeWarning: You will not be able to run predict() on this Core ML model. Underlying exception message was: { NSLocalizedDescription = "Error in declaring network."; } RuntimeWarning,
this warning show up

All 4 comments

I found that if I set input shape like (16384, ), mlmodel can convert successfully.
but if input shape higher than 16384,
RuntimeWarning: You will not be able to run predict() on this Core ML model. Underlying exception message was: { NSLocalizedDescription = "Error in declaring network."; } RuntimeWarning,
this warning show up

I have the same issue. Which version of coremltools are you using?

I have exactly the same problem. Fully Conv Network successfully converts with shape 480x320 but fails with 640x480.
coremltools 4.0

Simple example to reproduce the behavior:

_this doesn't gives the error ->_

import coremltools as ct
model = ct.converters.onnx.convert(model='models/onnx/version-RFB-320.onnx', minimum_ios_deployment_target='13')

_this does ->_

import coremltools as ct
model = ct.converters.onnx.convert(model='models/onnx/version-RFB-640.onnx', minimum_ios_deployment_target='13')

Models are here: models

coremltools version: 4.0
Keras version : 2.3.1

Was this page helpful?
0 / 5 - 0 ratings