Closed Snixells closed 4 years ago
I tried in colab with TF nightly verison(2.4.0-dev20200803
) and was able to reproduce the issue.Please, find the gist here.Thanks!
I am facing the same problem...
@Snixells Can you try this?
!pip install tf-nightly
import tensorflow as tf
## TFLite Conversion
model = tf.saved_model.load("saved_model")
concrete_func = model.signatures[tf.saved_model.DEFAULT_SERVING_SIGNATURE_DEF_KEY]
concrete_func.inputs[0].set_shape([1, 640, 640, 3])
tf.saved_model.save(model, "saved_model_updated", signatures={"serving_default":concrete_func})
converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir='saved_model_updated', signature_keys=['serving_default'])
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS, tf.lite.OpsSet.SELECT_TF_OPS]
tflite_model = converter.convert()
## TFLite Interpreter to check input shape
interpreter = tf.lite.Interpreter(model_content=tflite_model)
interpreter.allocate_tensors()
# Get input and output tensors.
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
# Test the model on random input data.
input_shape = input_details[0]['shape']
print(input_shape)
@Snixells
I have tried in colab with TF nightly version as per @MeghnaNatraj suggestion and i am not seeing any issue.Please, find the gist here. Please, verify once and close the issue.Thanks!
@MeghnaNatraj I used your give script to export the model to a tflite but I am getting this
`2020-08-28 11:20:09.890462: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1402] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 14636 MB memory) -> physical GPU (device: 0, name: Tesla V100-SXM2-16GB, pci bus id: 0000:00:04.0, compute capability: 7.0)
2020-08-28 11:20:10.114986: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:816] Optimization results for grappler item: graph_to_optimize
2020-08-28 11:20:10.115049: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] function_optimizer: Graph size after: 4187 nodes (3829), 6745 edges (6380), time = 131.197ms.
2020-08-28 11:20:10.115057: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] function_optimizer: function_optimizer did nothing. time = 2.969ms.
2020-08-28 11:20:15.209765: W tensorflow/compiler/mlir/lite/python/tf_tfl_flatbuffer_helpers.cc:313] Ignored output_format.
2020-08-28 11:20:15.209826: W tensorflow/compiler/mlir/lite/python/tf_tfl_flatbuffer_helpers.cc:316] Ignored drop_control_dependency.
loc("Func/StatefulPartitionedCall/input/_0"): error: requires all operands and results to have compatible element types
Traceback (most recent call last):
File "/home/dev/tf_nightly_env/lib/python3.8/site-packages/tensorflow/lite/python/convert.py", line 196, in toco_convert_protos
model_str = wrap_toco.wrapped_toco_convert(model_flags_str,
File "/home/dev/tf_nightly_env/lib/python3.8/site-packages/tensorflow/lite/python/wrap_toco.py", line 32, in wrapped_toco_convert
return _pywrap_toco_api.TocoConvert(
Exception:
Prerequisites
Please answer the following questions for yourself before submitting an issue.
1. The entire URL of the file you are using
https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf2_detection_zoo.md
2. Describe the bug
I am trying to Convert the SSD ResNet50 V1 FPN 640x640 (RetinaNet50) of the TF 2 Object Detection Zoo to TFLite. My Code is the following:
The Convertion is running without any Errors, but when I try to use the TFLite Model with the following Code
I am getting this Error:
It seems that there are some Problems with the Dimensions of the converted Model. Thanks for your help!
6. System information