App add custom tensorflow-ite model run error

Failed to invoke the interpreter with error: Invalid tensor index 1, max index is 0.
transform model details

def relu6(x):
    return K.relu(x, max_value=6)

with CustomObjectScope({'relu6': relu6}):

    keras_model = "../checkpoints/conv_1d_time_stacked_model/ep-022-vl-0.2538.hdf5"

    # converter = tf.lite.TFLiteConverter.from_keras_model_file(keras_model, input_arrays, output_arrays)
    converter = tf.lite.TFLiteConverter.from_keras_model_file(keras_model)
    tflite_model = converter.convert()
    open("conv_actions_frozen.tflite", "wb").write(tflite_model)

@jkyaoyajie,

Welcome to the Tensorflow Forum!

Could you please provide the complete stack trace and toy model to reproduce the issue?

Thank you!

for example : examples/README.md at master · tensorflow/examples · GitHub , i used this ml to train, when i move conv_actions_frozen.tflite to the example/speechcommand /ios, the error will reproduce . it looks like the inputs outputs params not set. (converter = tf.lite.TFLiteConverter.from_keras_model_file(keras_model))

I used speechCommand ml for training, replacing the trained model with the tflite file of the demo project, and attempting to run the demo, the error was displayed

@jkyaoyajie,

Are you facing trouble while converting into the tflite model or using the example with custom model?

Thank you!

Yes, according to the principle, the ml training should be directly usable in iOS demo projects, but there will be the above error messages. I don’t know how to handle this problem.
Operating steps:

  1. cd examples/tree/master/lite/examples/speech_commands/ml
  2. python download.py
  3. python train.py [-h] [-sample_rate SAMPLE_RATE]
    [-batch_size BATCH_SIZE]
    [-output_representation OUTPUT_REPRESENTATION]
    -data_dirs DATA_DIRS [DATA_DIRS …]
  4. python convert_keras_lite.py
  5. Replace conv_ actions_ Frozen.tflite file in iOS project
  6. run it .

Can you help me solve this problem? I’m a novice, thank you very much

@jkyaoyajie,

To debug your issue further could you please provide iOS configurations?

iOS configurations ? I used demo without changing the configuration, only replacing the tflite model file
examples/lite/examples/speech_commands/ios at master · tensorflow/examples · GitHub