tensorflow: Unable to batch tensorflowLite object detection model
System information
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow): Yes
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): MacOSX
- TensorFlow installed from (source or binary): Binary
- TensorFlow version (use command below): 1.13.1
- Python version: 3.7
Describe the current behavior I’m using the TfLite object detection models in python and upon trying to resize the input to increase the batch size; I’m getting an error as follows:
Traceback (most recent call last):
File "test_cropped_face.py", line 70, in <module>
interpreter.allocate_tensors()
File "/Users/harshitdwivedi/Desktop/tf_env/lib/python3.7/site-packages/tensorflow/lite/python/interpreter.py", line 73, in allocate_tensors
return self._interpreter.AllocateTensors()
File "/Users/harshitdwivedi/Desktop/tf_env/lib/python3.7/site-packages/tensorflow/lite/python/interpreter_wrapper/tensorflow_wrap_interpreter_wrapper.py", line 106, in AllocateTensors
return _tensorflow_wrap_interpreter_wrapper.InterpreterWrapper_AllocateTensors(self)
RuntimeError: tensorflow/lite/kernels/reshape.cc:58 num_input_elements != num_output_elements (3276800 != 65536)Node number 88 (RESHAPE) failed to prepare.
Describe the expected behavior Setting a custom batch size for an image classification model works without any issues; so I expect the same thing to happen here as well.
Standalone code to reproduce the issue
interpreter = tf.contrib.lite.Interpreter(model_path="cropped_face.tflite")
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
# resize the input to run inference on more than 1 image at a time; the default size is [1,512,512,3]
interpreter.resize_tensor_input(input_details[0]['index'], [50, 512, 512, 3])
interpreter.allocate_tensors()
Here’s the model I’m using. I have trained it via the GCP’s Cloud Vision Dashboard. https://drive.google.com/file/d/1teJ34GvWmd-1aZBqNLeqIy-owOj5_RDS/view?usp=sharing
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 18 (6 by maintainers)
Is there any resoultion to get tensorflow lite working for batches > 1? I got the same error when I resize the input tensor