Skip to content

tflite export and preprocess_input/decode_predictions #82

Answered by leondgarse
avber asked this question in Q&A
Discussion options

You must be logged in to vote

For PreprocessInput, currently will not make it a layer.

  • Firstly, the main process for PreprocessInput is resize and rescale. For resize, it's not helpful for TFLite model, I'm not sure if the dynamic input shape is support by TFLite:
    # Define a simple model with dynamic input shape
    inputs = keras.layers.Input([None, None, 3])
    nn = tf.image.resize(inputs, [512, 512])
    bb = keras.models.Model(inputs, nn)
    
    # Convert TFLite
    converter = tf.lite.TFLiteConverter.from_keras_model(bb)
    open(bb.name + ".tflite", "wb").write(converter.convert())
    
    # Check input shape, it is not dynamic anymore...
    tf.lite.Interpreter(model_path=bb.name + ".tflite").get_input_details()[0]["shape"]
    # array([1, 1, 1, 3],…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@avber
Comment options

Answer selected by avber
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants