Comments (20)
Thank you for the reply.
When you go back from the other screen, do you reload the model? I suspect loadLabels() is called again so label size is multiplied.
Can you please try clearing labels array? Add labels = new Vector<>();
before
flutter_tflite/android/src/main/java/sq/flutter/tflite/TflitePlugin.java
Lines 107 to 110 in 624c46d
from flutter_tflite.
Thank you for the reply.
When you go back from the other screen, do you reload the model? I suspect loadLabels() is called again so label size is multiplied.
Can you please try clearing labels array? Addlabels = new Vector<>();
before
flutter_tflite/android/src/main/java/sq/flutter/tflite/TflitePlugin.javaLines 107 to 110 in 624c46d
while ((line = br.readLine()) != null) {
labels.add(line);
}
labelProb = new float[1][labels.size()];
Thanks! This works. =)
For ios in TflitePlugin.mm there's labels.clear(); in the close() method so I'm guessing that one should be ok then for the ios side?
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.
Note: Recompile with -Xlint:deprecation for details.
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.
from flutter_tflite.
I had a similar bug!
After searching and searching I realized that the ".txt" files that I dowloaded from the Git for the assets folder was incorrect. Then I fixed that and everything its working fine now!
By the way I'm using detectObjectOnImage with the model "SSDMobileNet"
tflite version: 1.0.2
Hope it helps!!
from flutter_tflite.
Thank you for the feedback.
Would it be convenient for you to provide a sample project that reproduces the issue?
from flutter_tflite.
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...
from flutter_tflite.
Glad to know it works. šI will add the fix in the next version.
from flutter_tflite.
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, why isn't there an example what to write into pubspec, you write "Add tflite as a dependency in your pubspec.yaml file." and then it takes me to the general info about adding dependencies. I know that, how do I add yours? Like this -> tflite: ^1.0.1 ?
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.
from flutter_tflite.
There are some breaking changes since 1.0.0
https://github.com/shaqian/flutter_tflite#breaking-changes-since-100
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.
https://pub.dartlang.org/packages/tflite#-changelog-tab-
You can try fixing the version like tflite: 0.0.5
, then run flutter packages get
. If you still get red squiggly lines, go to ios
folder and run pod install
.
Thanks,
Qian
from flutter_tflite.
Ok, thanks for the answer I will look into it in a couple of days, keep up the great work! =)
from flutter_tflite.
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)
E/flutter (24486): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7)
E/flutter (24486): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:302:33)
E/flutter (24486):
E/flutter (24486): #2 Tflite.detectObjectOnFrame (package:tflite/tflite.dart:152:27)
E/flutter (24486):
E/flutter (24486): #3 _CameraState.initState.. (package:flutter_realtime_detection/camera.dart:50:20)
E/flutter (24486): #4 CameraController.startImageStream. (package:camera/camera.dart:353:20)
E/flutter (24486): #5 _rootRunUnary (dart:async/zone.dart:1132:38)
E/flutter (24486): #6 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter (24486): #7 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
E/flutter (24486): #8 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
E/flutter (24486): #9 _DelayedData.perform (dart:async/stream_impl.dart:591:14)
E/flutter (24486): #10 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:707:11)
E/flutter (24486): #11 _PendingEvents.schedule. (dart:async/stream_impl.dart:667:7)
E/flutter (24486): #12 _rootRun (dart:async/zone.dart:1120:38)
E/flutter (24486): #13 _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter (24486): #14 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
E/flutter (24486): #15 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:963:23)
E/flutter (24486): #16 _rootRun (dart:async/zone.dart:1124:13)
E/flutter (24486): #17 _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter (24486): #18 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
E/flutter (24486): #19 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:963:23)
E/flutter (24486): #20 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (24486): #21 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
from flutter_tflite.
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)
E/flutter (24486): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7)
E/flutter (24486): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:302:33)
E/flutter (24486):
E/flutter (24486): #2 Tflite.detectObjectOnFrame (package:tflite/tflite.dart:152:27)
E/flutter (24486):
E/flutter (24486): #3 _CameraState.initState.. (package:flutter_realtime_detection/camera.dart:50:20)
E/flutter (24486): #4 CameraController.startImageStream. (package:camera/camera.dart:353:20)
E/flutter (24486): #5 _rootRunUnary (dart:async/zone.dart:1132:38)
E/flutter (24486): #6 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter (24486): #7 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
E/flutter (24486): #8 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
E/flutter (24486): #9 _DelayedData.perform (dart:async/stream_impl.dart:591:14)
E/flutter (24486): #10 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:707:11)
E/flutter (24486): #11 _PendingEvents.schedule. (dart:async/stream_impl.dart:667:7)
E/flutter (24486): #12 _rootRun (dart:async/zone.dart:1120:38)
E/flutter (24486): #13 _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter (24486): #14 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
E/flutter (24486): #15 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:963:23)
E/flutter (24486): #16 _rootRun (dart:async/zone.dart:1124:13)
E/flutter (24486): #17 _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter (24486): #18 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
E/flutter (24486): #19 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:963:23)
E/flutter (24486): #20 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (24486): #21 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
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.
from flutter_tflite.
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,
Qian
from flutter_tflite.
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?
from flutter_tflite.
After searching and searching I realized that the ".txt" files that I dowloaded from the Git for the assets folder was incorrect. Then I fixed that and everything its working fine now!
When you say the txt files were incorrect, what do you mean? Incorrect in what sense?
from flutter_tflite.
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)
E/flutter (24486): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7)
E/flutter (24486): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:302:33)
E/flutter (24486):
E/flutter (24486): #2 Tflite.detectObjectOnFrame (package:tflite/tflite.dart:152:27)
E/flutter (24486):
E/flutter (24486): #3 _CameraState.initState.. (package:flutter_realtime_detection/camera.dart:50:20)
E/flutter (24486): #4 CameraController.startImageStream. (package:camera/camera.dart:353:20)
E/flutter (24486): #5 _rootRunUnary (dart:async/zone.dart:1132:38)
E/flutter (24486): #6 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter (24486): #7 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
E/flutter (24486): #8 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
E/flutter (24486): #9 _DelayedData.perform (dart:async/stream_impl.dart:591:14)
E/flutter (24486): #10 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:707:11)
E/flutter (24486): #11 _PendingEvents.schedule. (dart:async/stream_impl.dart:667:7)
E/flutter (24486): #12 _rootRun (dart:async/zone.dart:1120:38)
E/flutter (24486): #13 _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter (24486): #14 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
E/flutter (24486): #15 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:963:23)
E/flutter (24486): #16 _rootRun (dart:async/zone.dart:1124:13)
E/flutter (24486): #17 _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter (24486): #18 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
E/flutter (24486): #19 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:963:23)
E/flutter (24486): #20 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (24486): #21 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)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.
Can you tell trained it wrong meaning ?
what is wrong is training?
from flutter_tflite.
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?
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]".
from flutter_tflite.
Same issue here :
java.lang.IllegalArgumentException: Cannot copy between a TensorFlowLite tensor with shape [1, 10, 4] and a Java object with shape [1, 1]
I have only one class, I followed this tutorial https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/running_on_mobile_tensorflowlite.md using bazel to convert to tflite.
I understand that the second value of the shape should be the number of classes, but what are the other values ?
from flutter_tflite.
I have the same problem: Cannot copy between a TensorFlowLite tensor with shape [1, 1] and a Java object with shape [1, 2]
I have MobileNetV2 as input layer, 1 flatten and 3 dense layers and then converted to tflite. I have 2 classes in my dataset. Is there some kind of limitation for tflite-flutter package does not work with custom models?
from flutter_tflite.
Any solution ?
from flutter_tflite.
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?
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]".
Any solution?
from flutter_tflite.
Related Issues (20)
- Can I build desktop app by this package?
- E/AndroidRuntime( 4563): Caused by: java.lang.IllegalArgumentException: Cannot copy from a TensorFlowLite tensor (StatefulPartitionedCall:0) with shape [1, 10647, 6] to a Java object with shape [1, 13, 13, 30]. HOT 1
- runModelOnImage returns null HOT 1
- I have a issue in runSegmentationOnImage
- The plugin `tflite` uses a deprecated version of the Android embedding. HOT 1
- The plugin `tflite` uses a deprecated version of the Android embedding. HOT 1
- got this error when running flutter project HOT 3
- Unhandled Exception: PlatformException(Failed to run model, Interpreter busy, java.lang.RuntimeException: Interpreter busy HOT 3
- Can anyone help giving this code in Flutter HOT 2
- help me please
- Failed to transform guice-5.1.0.jar (com.google.inject:guice:5.1.0) to match attributes HOT 1
- Please Update this package HOT 1
- crash when useGpuDelegate is true in v2 HOT 1
- E/AndroidRuntime(10989): Caused by: java.lang.IllegalArgumentException: Cannot copy to a TensorFlowLite tensor (serving_default_conv2d_3_input:0) with 90000 bytes from a Java Buffer with 67500 bytes.
- URGENT!!!!! Please HELP!!! Unhandled Exception: PlatformException(Failed to run model, Attempt to invoke virtual method 'org.tensorflow.lite.Tensor org.tensorflow.lite.Interpreter.getInputTensor(int)' on a null object reference, java.lang.NullPointerException: Attempt to invoke virtual method 'org.tensorflow.lite.Tensor org.tensorflow.lite.Interpreter.getInputTensor(int)' on a null object reference
- URGENT!!!!! Please HELP!!! Unhandled Exception: PlatformException(Failed to run model, Attempt to invoke virtual method 'org.tensorflow.lite.Tensor org.tensorflow.lite.Interpreter.getInputTensor(int)' on a null object reference, java.lang.NullPointerException: Attempt to invoke virtual method 'org.tensorflow.lite.Tensor org.tensorflow.lite.Interpreter.getInputTensor(int)' on a null object reference
- Missing Plugin Exeption
- MissingPluginException(No implementation found for method loadModel on channel tflite) HOT 2
- Remove references to deprecated v1 Android embedding
- It not supporting new flutter sdk version
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_tflite.