-
Notifications
You must be signed in to change notification settings - Fork 416
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 copy between a TensorFlowLite tensor with shape [1, 2] and a Java object with shape [1, 4]., null) #10
Comments
Thank you for the feedback. |
Hi, I used your example with no modifications, then modified it with the files I have and the above mentioned modifications I did made no difference to how the app reacted. It works when I first use it even with no modifications to your example code, but when I leave the screen to another screen in the app and come back and try to use it I get the error I wrote out. What I don't understand is how can it work if I have a .lite with 2 possible answers and the example has in one class a definition of numResults = 6 and in another numResults = 5, yet it still provides me a correct answer when using the app. I could remake the .lite for the project but you could remake it really easy too. I can't unfortunately send you the original as it's proprietary and from a client I'm making this for, but it's a .lite with 2 possible answers as is the accompanying txt file which has the names of the options written out. As I said the example works great, I get a result meaning the file I'm using works and has worked on an Android version perfectly. However, here I keep getting this error after using it going to another screen in the app and then coming back. Contact me if you need help with making a .lite file, I'll be happy to help you solve this... |
Thank you for the reply. flutter_tflite/android/src/main/java/sq/flutter/tflite/TflitePlugin.java Lines 107 to 110 in 624c46d
|
Thanks! This works. =) Just one more thing irrelevant to this discussion, when running the project I keep getting this notification Note: C:\flutter.pub-cache\hosted\pub.dartlang.org\tflite-0.0.5\android\src\main\java\sq\flutter\tflite\TflitePlugin.java uses or overrides a deprecated API. I was also getting it before applying your solution. Everything works great and it compiles and runs on the phone, just thought I'd mention it so you know. Awesome project by the way, and thanks for making it! You've got a beer from me. |
Glad to know it works. 😃I will add the fix in the next version. |
I've tried version 1.0.1 What did you do, the import is red, I'm using import 'package:tflite/tflite.dart'; like your instructions say and it says 'Target of URI doesn't exist: 'package:tflite/tflite.dart'.' after fliding over it with the mouse to see why it's red. Also, I had a calculation of the final output and showed the result on the screen, I updated to that 1.0.1 (also tried 1.0.0) and now no screen result is showing. I'm working on another app now and don't have time to look into this but why would you change the output, now I have to do this again. |
There are some breaking changes since 1.0.0 I think you were using 0.0.2 or 0.0.3. The latest version that doesn't break your code might be 0.0.5. You can try fixing the version like Thanks, |
Ok, thanks for the answer I will look into it in a couple of days, keep up the great work! =) |
I had a similar bug! Hope it helps!! |
I'm trying to use a tflite file that I trained myself and I'm getting this error: E/flutter (24486): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(error, Unsupported value: java.lang.IllegalArgumentException: Cannot copy between a TensorFlowLite tensor with shape [1, 10, 4] and a Java object with shape [1, 9, 9, 30]., null) |
Well, this is your problem --> Cannot copy between a TensorFlowLite tensor with shape [1, 10, 4] and a Java object with shape [1, 9, 9, 30]., null) - You've trained it wrong. |
Archiving the thread as the original issue is fixed in new version. @brunokitaka Feel free to raise a new issue if you still get error with your model. Thanks, |
Hi I trained the Mobilenet model on certain domain specific images using transfer learning. But, when I try to run the model, I get "Cannot copy between a TensorFlowLite tensor with shape [1, 11] and a Java object with shape [1, 11, 4]". I have 11 classes in my dataset. How may I fix the issue? |
When you say the txt files were incorrect, what do you mean? Incorrect in what sense? |
Can you tell trained it wrong meaning ? |
Were you able to solve this issue, because even I'am facing an issue were I get the error "Cannot copy between a TensorFlow Lite tensor with shape [1,2535,9] and a java object with shape [1,13,13,45]". |
Same issue here : |
I have the same problem: |
Any solution ? |
Any solution? |
Hi, I’m using a graph.lite trained with 2 results and a labels.txt, I have managed to get the example working, however it works wonderfully while I’m using it and I can analyze and take as many pictures as I want, yet when I leave to another screen in the app and come back I get an error like the one below stating that somehow the Java object which had correctly worked and gave me a result on top of the taken image, has now changed from [1,2] to [1,4], what’s more interesting is that this discrepancy keeps growing as I leave and come back, as the next time it’s [1,6], the next [1,8], next [1,10] you get the picture, and it constantly keeps giving me this error and doesn’t go on to analyze the image therefore I get no results anymore. I have to close the app and start it again for tensorflow to work, then again if I leave to another screen and come back it starts the same cycle. Is this a bug or should I change something else? I have used either 224 or 299 for image size when preparing tflite, imageMean was 128 not 127.5 but I’ve tried changing that too without any results. I have tried modifying the variables numResults, imageMean, imageStd, image sizes in main and tflite.dart however I still get an error on second run. The only thing I didn’t try changing was threshold. Can you please help. This is the error I get below. Best regards
E/flutter (23306): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter (23306): PlatformException(error, Unsupported value: java.lang.IllegalArgumentException: Cannot copy between a TensorFlowLite tensor with shape [1, 2] and a Java object with shape [1, 4]., null)
E/flutter (23306): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:551:7)
E/flutter (23306): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:292:18)
E/flutter (23306):
E/flutter (23306): #2 Tflite.runModelOnImage (package:tflite/tflite.dart:33:27)
E/flutter (23306):
E/flutter (23306): #3 _MyAppState.recognizeImage (package:someApp_tabbed_activity/tflite/tflitemain.dart:74:37)
E/flutter (23306):
E/flutter (23306): #4 _MyAppState.getImage (package:someApp_tabbed_activity/tflite/tflitemain.dart:25:5)
E/flutter (23306):
E/flutter (23306): #5 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
E/flutter (23306): #6 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:562:30)
E/flutter (23306): #7 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
E/flutter (23306): #8 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
E/flutter (23306): #9 TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:204:7)
E/flutter (23306): #10 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter (23306): #11 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:184:20)
E/flutter (23306): #12 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:158:22)
E/flutter (23306): #13 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:138:7)
E/flutter (23306): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7)
E/flutter (23306): #15 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7)
E/flutter (23306): #16 _invoke1 (dart:ui/hooks.dart:168:13)
E/flutter (23306): #17 _dispatchPointerDataPacket (dart:ui/hooks.dart:122:5)
The text was updated successfully, but these errors were encountered: