android - Flutter tflite 插件未在应用程序的发布版本中进行识别
问题描述
我一直在尝试在我的应用程序中使用颤振tflite 插件,到目前为止,我一直在开发/调试中对其进行测试,即当我运行以下命令时
var recognitions = await Tflite.runModelOnImage(
path: croppedFile.path, // required
imageMean: 0.0, // defaults to 117.0
imageStd: 255.0, // defaults to 1.0
numResults: 2, // defaults to 5
threshold: 0.2, // defaults to 0.1
asynch: true // defaults to true
);
它确实给了我一些认可。但是,当我制作相同代码的发布版本时,在具有相同输入数据的同一设备上运行时,它不会返回任何识别。我正在使用以下步骤制作发布版本:
//step 1
flutter build appbundle
// step 2
java -jar bundletool-all-1.3.0.jar build-apks --bundle=app-release.aab --output=app-release.apks --ks=key.jks --ks-pass= --ks-key-alias=key --key-pass=
// step 3
java -jar bundletool-all-1.3.0.jar install-apks --apks=app-release.apks
我还在我的 android build.gradle 中添加了以下内容
aaptOptions {
noCompress 'tflite'
noCompress 'lite'
}
如何在发布时获得不同的结果,而相同的代码在应用程序的调试版本中工作?我的设置中缺少什么?
注意:我只能在 Android 上测试
更新
进一步挖掘,我在配置文件模式下运行应用程序并发现以下日志(注意:这些仅在配置文件模式下显示,所以我不确定它与发布版本有多远。另外,在运行时我没有收到这些错误调试):
2020-11-08 20:04:34.623 4869-4940/com.flutterApp.gng I/flutter: 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
at sq.flutter.tflite.TflitePlugin.feedInputTensor(TflitePlugin.java:326)
at sq.flutter.tflite.TflitePlugin.feedInputTensorImage(TflitePlugin.java:371)
at sq.flutter.tflite.TflitePlugin$RunModelOnImage.<init>(TflitePlugin.java:477)
at sq.flutter.tflite.TflitePlugin.onMethodCall(TflitePlugin.java:102)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.Messag
...
2020-11-08 02:08:07.438 657-657/? I/HWComposer: getActiveConfigs: Attempted to access invalid display -1
2020-11-08 02:08:07.453 657-657/? I/HWComposer: getActiveConfigs: Attempted to access invalid display -1
2020-11-08 02:08:07.460 23087-23136/? I/qtaguid: Tagging socket 89 with tag 6b55000000000(439632) for uid -1 failed errno=-24
2020-11-08 02:08:07.460 23087-23136/? I/NetworkManagementSocketTagger: tagSocketFd(89, 439632, -1) failed with errno-24
2020-11-08 02:08:07.469 657-657/? I/HWComposer: getActiveConfigs: Attempted to access invalid display -1
2020-11-08 02:08:07.486 657-657/? I/HWComposer: getActiveConfigs: Attempted to access invalid display -1
2020-11-08 02:08:07.521 657-657/? I/chatty: uid=1000(system) /system/bin/surfaceflinger identical 2 lines
2020-11-08 02:08:07.540 657-657/? I/HWComposer: getActiveConfigs: Attempted to access invalid display -1
2020-11-08 02:08:07.542 22602-22654/com.flutterApp.gng I/flutter: Found 3 faces
2020-11-08 02:08:07.557 657-657/? I/HWComposer: getActiveConfigs: Attempted to access invalid display -1
2020-11-08 02:08:07.566 1449-2272/? W/StorageManager: getStorageLowBytes lowPercent : 5, lowBytes : 2861259366, maxLowBytes : 524288000
2020-11-08 02:08:07.577 22602-22654/com.flutterApp.gng I/flutter: PlatformException(Failed to run model, Interpreter busy, java.lang.RuntimeException: Interpreter busy
at sq.flutter.tflite.TflitePlugin$TfliteTask.<init>(TflitePlugin.java:427)
at sq.flutter.tflite.TflitePlugin$RunModelOnImage.<init>(TflitePlugin.java:465)
at sq.flutter.tflite.TflitePlugin.onMethodCall(TflitePlugin.java:102)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:325)
at android.os.Looper.loop(Looper.java:142)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1
2020-11-08 02:08:07.588 657-657/? I/HWComposer: getActiveConfigs: Attempted to access invalid display -1
2020-11-08 02:08:07.608 22602-22654/com.flutterApp.gng I/flutter: PlatformException(Failed to run model, Interpreter busy, java.lang.RuntimeException: Interpreter busy
at sq.flutter.tflite.TflitePlugin$TfliteTask.<init>(TflitePlugin.java:427)
at sq.flutter.tflite.TflitePlugin$RunModelOnImage.<init>(TflitePlugin.java:465)
at sq.flutter.tflite.TflitePlugin.onMethodCall(TflitePlugin.java:102)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:325)
at android.os.Looper.loop(Looper.java:142)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1
2020-11-08 02:08:07.622 657-657/? I/HWComposer: getActiveConfigs: Attempted to access invalid display -1
2020-11-08 02:08:07.641 22602-22654/com.flutterApp.gng I/flutter: PlatformException(Failed to run model, Interpreter busy, java.lang.RuntimeException: Interpreter busy
at sq.flutter.tflite.TflitePlugin$TfliteTask.<init>(TflitePlugin.java:427)
at sq.flutter.tflite.TflitePlugin$RunModelOnImage.<init>(TflitePlugin.java:465)
at sq.flutter.tflite.TflitePlugin.onMethodCall(TflitePlugin.java:102)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:325)
at android.os.Looper.loop(Looper.java:142)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1
由于我在调试模式下看不到行为,因此我仍然对运行发布版本时应用程序中发生的情况感到困惑。
解决方案
推荐阅读
- java - 作为 JAVA 8 的一部分,Nashorn 可以实时实现的目的是什么?
- c# - SceneChange 脚本编译器错误:由于保护级别而无法访问
- ios - 将 ipa 文件上传到应用商店连接时卡住了
- javascript - 如何在不生成新密钥的情况下将数据推送到 Firebase
- node.js - 我应该使用什么进行链式支付,它提供了与 PayPal 自适应支付相同的功能?
- php - 当 Woocommerce 中的可变产品缺货时隐藏添加到购物车块
- r - 从 R 中的 geojson FeatureCollection 读取单个特征的一般方法
- postgresql - 使用 pgpass 的 Postgres pg 转储
- python - 多维列表的重塑
- angular - 我的图像以数字形式出现