-
Notifications
You must be signed in to change notification settings - Fork 228
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
Cannot convert between a TensorFlowLite buffer with XXX bytes and a ByteBuffer with XXX bytes #6
Comments
Same problem here. I tried all the steps and guidelines in these links but still, nothing seems to work... |
I resolved it by using this modified class: |
@moster67 Still isn't working. I have the similar code approach as well. I trained my own model. It's funny that same number and layer in a CNN architecture on different image optimization give different results. |
Could you elaborate your solution? Stuck on the same problem, and i don't see what exactly we are replacing here. Nevermind, solved it by noting that with floats we are using 4 times as many bytes |
@EXJUSTICE you are right.. changing the value type from int to float fixed it for me |
@Div1090 will you please elaborate specifically what values are to be changed ? |
@Tanv33rA In the function
This ought to fix the problem! |
My recent PR has added support for float models. Simply change the variable QUANT to false in TensorFlowImageClassifier.java along with changing the model and lebels name. |
Check which values return methods getImageSizeX() and getImageSizeY() in your ImageClassifier class. For example, for model getImageSizeX() = 192 |
thank you so much @soum-io |
I was facing the exact same issue with values: So the problem was that i converted my mobilenet model with python api (for tf lite conversion) but when i used the command line api for the same, it worked. Hope it helps. The command line api is available at : |
I also downloaded the Tensorflow for Poets 2 github repository. While I was trying to place my graph and labels into the tflite-app, I got this error. I resolved the issue by following @SergeyKarleev's answer. For me, changing the static final int DIM_IMG_SIZE_X and static final int DIM_IMG_SIZE_Y values to 299 was the answer. These values can be found in the ImageClassifier.java document in the android folder. I guess that not setting the IMG_SIZE correctly while following the tutorial is what causes the issue. I don't know if this issue is still unresolved, but I thought I'd share my fix anyway. |
I created a custom model using Google Vision API and the expected input size for that model was 512x512 as opposed to the 300x300 in MobileSSDNet (default with TFLite example). I changed |
I use the code base and found same issue from I do download my trained model from Azure Custom Vision to use instead of default model of the project defined. I would like to tell you first here, I'm newbie to ML and Tensorflow thing. URL Yes, I know this is Object Detection, not Image classification like this issue. But What I google and only found is here the best fit with keyword. Here is error message. I tried to read and do along with all yours comment and found this row in the code. the value in formula is reflect with the later number of error message. I tried to change to exactly number of former number in error message but found a new error. So, how can I change to my own model I trained in Azure to change on the default model in example and can use it without error? |
THE SAME ERROR :(( Models (both as float and quantizied) have been constructed with the codes at: However, the app give this error: PLEASE HELP ME TO SOLVE THIS ISSUE :((( |
I try all the above steps but not working |
@xenogew I have exactly the same error. Did you find the solution? |
i also got
i have try change line error
when i try change to float like
i got new problem |
Hello guys, Seems like TSLite only support exact square bitmap inputs And max size which is supported Here is the sample code to crop and resize bitmap
Crop bitmap Created scaled version of bitmap for model input Crop Bitmap to maintain aspect ratio of model input.
Hope it helps |
@pkpdeveloper can you give me source about the max size supported? |
Did not dig too deep into why it works but I got back a prediction from my model Edit the method in this file to the one below Edit: remove the D typo in the image above (Must have pressed a key when copying screen)
Hopefully, that helps someone |
Resizing the Buffer works for me
here 300, 300 is the size of the input matrix of the model |
Hi, many thanks for the article and the sample-code.
It works fine with the model mentioned in your project. However, I trained my own model (using the tensorflow-for-poets 1 and 2 tutorials) but I get an error using my model with your code:
"Cannot convert between a TensorFlowLite buffer with XXX bytes and a ByteBuffer with XXX bytes."
This happens when running the following statement:
interpreter.run(byteBuffer, result);
My model works fine with the sample-project in "the tensorflow-for-poets2 tutorial.
Just wondering what can be the issue. Any ideas?
Thanks.
The text was updated successfully, but these errors were encountered: