-
Notifications
You must be signed in to change notification settings - Fork 75.3k
How to specify shape of input for TFLite model after receiving SavedModel format? #30180
Copy link
Copy link
Closed
Closed
Copy link
Labels
TF 2.0Issues relating to TensorFlow 2.0Issues relating to TensorFlow 2.0comp:liteTF Lite related issuesTF Lite related issues
Description
I use TF 2.0. Let's suppose I have a model that I successfully converted to SavedModel format. I used following code to convert my model in Imperative API (subclassed tf.keras.Model) to SavedModel:
tf.keras.experimental.export_saved_model(
model, file_path,
serving_only=True,
input_signature=[tf.TensorSpec(shape=[None, None, None, 3], dtype=tf.float32)])Now I want to convert my model to TFLite, but I have a problem, because I need to specify all dims except for batch. It's okay, but I want to do it after saving my model in SavedModel format. For example, if I want to do several models with different shapes, this feature is required (e.g, [None, 1280, 720, 3], [None, 600, 600, 3] etc.).
How can I do it in step where I convert my model to TFLite? I mean in this step (or something like that after receiving SavedModel format):
converter = tf.lite.TFLiteConverter.from_saved_model(file_path)
tflite_model = converter.convert()Maybe I can specify input_shape in convert() or another way?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
TF 2.0Issues relating to TensorFlow 2.0Issues relating to TensorFlow 2.0comp:liteTF Lite related issuesTF Lite related issues