-
Notifications
You must be signed in to change notification settings - Fork 74k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does tFlite support input shape=[1,32,None,3] #29590
Comments
I believe the converter currently can't handle unknown dimension other than the batch size dimension. You could try use a fixed length (such as max length) instead. |
if use a fixed length(max width),the run time will be too long for small width |
I see. Currently dynamic input shape is not supported in tflite. However a walkaround could be:
It's not guaranteed that this path will always work as expected though, however it's no harm if you can give it a try. Thanks! |
@haozha111 Seems your method does not work.
and
the program will crash with
|
Hi Melody, sorry that it doesn't work for you. We are actively working on dynamic shapes in TF Lite, and hope to make the user experience better. Adding Nupur who is working in this area. |
Any news on dynamic shapes in TF Lite? |
I tried resize input_tensor.It would crash in seconds. |
or at least can we have variable batch? I resize input/output tensors, but when call allocate_tensors (either from python or java) I get an error inside reshape operator that the input and output tensors don't have the same number of elements |
We added support for unknown dimensions in TensorFlow Lite today (5591208). Can you try converting your model again with tonight's (1/31) When you load the model it should have an additional field You can then call If it does not work, can you provide a detailed error and repro instructions? |
@gargn I exported a .tflite file generated from AutoML. The default input is 224x224. Any ideas on how to change the input to 200x80 and then save and download a new .tflite file? I can't seem to find documentation on this? I know i can use Thoughts? |
I tried this with and It's not working -- I believe it's because
My data needs to be
As an aside, if any of you know how I can make the TF 1.x yolo model I'm trying to convert have fixed tensor shapes so I can compile, that would be amazing! I've only started learning TF now that the nice 2.x APIs are there for me use and don't know anything about TF 1.x idioms. |
I've tried this in
Output:
|
Having the same issue as adrian |
Having the same issue here. |
We can specify a random non-batch size dimemsion for dynamic axis using tensorflow-2.2.0-rc3 tflite_convert. However, the tflite-runtime cannot recalculate the appropriate output tensor dimensions if our model needs to. interpreter = tflite.Interpreter(model_path="densenet.tflite")
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
width = 277 # Any number that is valid for the model
interpreter.resize_tensor_input(input_details[0]['index'], (1, 32, width, 1))
interpreter.allocate_tensors()
interpreter.set_tensor(input_details[0]['index'], X)
interpreter.invoke()
output = interpreter.get_tensor(output_details[0]['index']) Something like this will occur:
Looks like tflite not yet able to modify all internal operator input/output dimensions accordingly. |
@adriancaruana I think your issue was resolved already in recent |
@james34602 Can you print |
@jvishnuvardhan I remove most parameters in the model, however, the I/O of the model remains identical to the original unshrink model file. ---Python print start--- output_details: Traceback (most recent call last):
We hope tensorflow team fix the problem...even Matlab MatConvNet can handle dynamic I/O shape... |
I used concrete_function to set input shape when converting saved_model to fflite format. |
@james34602 I printed the
Can you update the model with |
@lynx97 Can you please create a new issue and provide a standalone code to reproduce the issue. Opening new issue is better and can be easy to follow for other users who are facing similar issue like you. Thanks! |
@jvishnuvardhan Thanks for attention. |
Hello guys, @jvishnuvardhan
|
@gds101054108 Can you please verify once and close the issue if this was resolved for you. Couple of other above who had similar issue like you confirmed that |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you. |
Closing as stale. Please reopen if you'd like to work on this further. |
Hi!I am very curious for this trick, but I don't know how to achieve this. Could you give me a example? |
hey @james34602 @jvishnuvardhan @gargn Also, [1, 32, width, 1] is not similar to [1, 32,None, 1] right? |
@purva98 |
Good morning
…On Sun, Jun 7, 2020, 10:26 AM James Fung ***@***.***> wrote:
@purva98 <https://github.com/purva98>
tfnightly solve many problems, give it a shot.
[1, 32, width, 1] is [1, 32,None, 1]
width is not predetermined.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#29590 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIT525WESAGKJFSY3SWJ2W3RVNFKBANCNFSM4HWRWFCQ>
.
|
Hey @james34602 @jvishnuvardhan @gargn I have been facing similar issues listed in this thread. Since the model requires dynamic input sizes I had set the width and height to For resizing and setting the input data, I followed this snippet, here interpreter.resize_tensor_input(input_details[0]['index'], (1, batch_image.shape[1], batch_image.shape[2], 3), strict=True)
interpreter.allocate_tensors()
interpreter.set_tensor(input_details[0]['index'], input_data) You can see the input details shape has changed after executing the above snippet interpreter.get_input_details() [{'dtype': numpy.float32, But on executing
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-59-7d35ed1dfe14> in <module>()
----> 1 interpreter.invoke()
/usr/local/lib/python3.6/dist-packages/tensorflow/lite/python/interpreter.py in invoke(self)
522 """
523 self._ensure_safe()
--> 524 self._interpreter.Invoke()
525
526 def reset_all_variables(self):
RuntimeError: tensorflow/lite/kernels/kernel_util.cc:249 d1 == d2 || d1 == 1 || d2 == 1 was not true.Node number 49 (ADD) failed to prepare.
tensorflow/lite/kernels/kernel_util.cc:249 d1 == d2 || d1 == 1 || d2 == 1 was not true.Node number 37 (ADD) failed to prepare.
I have put together a Colab notebook to reproduce both the situations. Model Files and Test Images (for both cases):
|
It still has the problem. RuntimeError: tensorflow/lite/kernels/reshape.cc:66 num_input_elements != num_output_elements (416 != 0)Node number 11 (RESHAPE) failed to prepare. |
I have the same problem as @tjdevWorks .
I get:
@jvishnuvardhan Does any news on this exist or can somebody provide some help? |
Any news on dynamic shapes in TF Lite? |
System information
Linux Ubuntu 16.04
tf-cpu-1.13.1
I use tensorflow train a crnn+ctc OCR model,the width of textline is Variable,but when I convert pb to tflite,ValueError: None is only supported in the 1st dimension Tensor 'input_images' has invalid shape [1, 32, None, 3]。
The text was updated successfully, but these errors were encountered: