JGH*_*JGH 5 flutter tensorflow-lite
我将 h5 文件转换为 tflite。这个h5文件是ml5 Json模型。我刚刚自己转换成h5文件。但它不适用于错误代码。
Windows10、Python 3.6.8、tfv2.0.0
代码:
import tensorflow as tf
model=tf.keras.models.load_model("E:\h5\outputs\model.h5")
converter = tf.lite.TFLiteConverter.from_keras_model(model)
converter.experimental_new_converter = True
tflite_model = converter.convert()
open("E:\h5\converted_model.tflite", "wb").write(tflite_model)
Run Code Online (Sandbox Code Playgroud)
我用这些代码转换了文件
这个模型文件被放入我的应用程序中。
错误代码:
[+14766 ms] D/ViewRootImpl@454dd0a[MainActivity]( 1610): ViewPostIme pointer 0
[ +133 ms] D/ViewRootImpl@454dd0a[MainActivity]( 1610): ViewPostIme pointer 1
[ +13 ms] I/tflite ( 1610): Initialized TensorFlow Lite runtime.
[ +36 ms] I/flutter ( 1610): success
[ +12 ms] I/CameraManagerGlobal( 1610): Camera 0 facing CAMERA_FACING_BACK state now
CAMERA_STATE_OPEN for client com.example.examplerealtime API Level 2
[ +9 ms] D/SensorManager( 1610): registerListener :: 1, LSM6DSO Acceleration Sensor,
200000, 0,
[ +86 ms] W/Gralloc3( 1610): allocator 3.x is not supported
[ +573 ms] I/CameraManagerGlobal( 1610): Camera 0 facing CAMERA_FACING_BACK state now
CAMERA_STATE_ACTIVE for client com.example.examplerealtime API Level 2
[ +37 ms] I/CameraManagerGlobal( 1610): Camera 0 facing CAMERA_FACING_BACK state now
CAMERA_STATE_IDLE for client com.example.examplerealtime API Level 2
[ +146 ms] I/Choreographer( 1610): Skipped 44 frames! The application may be doing too
much work on its main thread.
[ +499 ms] I/CameraManagerGlobal( 1610): Camera 0 facing CAMERA_FACING_BACK state now
CAMERA_STATE_ACTIVE for client com.example.examplerealtime API Level 2
[ +118 ms] D/RenderScript HIDL Adaptation( 1610): IRenderScriptDevice::getService()
[ +11 ms] D/RenderScript HIDL Adaptation( 1610): IRenderScriptDevice::getService()
returned 0x78d5593060
[ ] D/RenderScript HIDL Adaptation( 1610): HIDL successfully loaded.
[ +1 ms] V/RenderScript( 1610): ARM mali (64 bit) RenderScript Compute Driver
[ +40 ms] V/RenderScript( 1610): Successfully loaded runtime: libRSDriverArm.so
[ +1 ms] D/ ( 1610): Successfully queried cache dir:
/data/user_de/0/com.example.examplerealtime/code_cache
[ ] D/RenderScript( 1610): Setting cache dir:
/data/user_de/0/com.example.examplerealtime/code_cache
[ +31 ms] E/MethodChannel#tflite( 1610): Failed to handle method call
[ ] E/MethodChannel#tflite( 1610): java.lang.IllegalArgumentException: Unsupported
value: java.lang.ArrayIndexOutOfBoundsException: length=2; index=3
[ ] E/MethodChannel#tflite( 1610): at
io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:278)
[ ] E/MethodChannel#tflite( 1610): at
io.flutter.plugin.common.StandardMethodCodec.encodeErrorEnvelope(StandardMethodCodec.java
:69)
[ ] E/MethodChannel#tflite( 1610): at
io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.ja
va:236)
[ ] E/MethodChannel#tflite( 1610): at
sq.flutter.tflite.TflitePlugin.onMethodCall(TflitePlugin.java:113)
[ ] E/MethodChannel#tflite( 1610): at
io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.
java:226)
[ ] E/MethodChannel#tflite( 1610): at
io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:8
5)
[ ] E/MethodChannel#tflite( 1610): at
io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:631)
[ ] E/MethodChannel#tflite( 1610): at
android.os.MessageQueue.nativePollOnce(Native Method)
[ ] E/MethodChannel#tflite( 1610): at
android.os.MessageQueue.next(MessageQueue.java:336)
[ ] E/MethodChannel#tflite( 1610): at android.os.Looper.loop(Looper.java:197
)
[ ] E/MethodChannel#tflite( 1610): at
android.app.ActivityThread.main(ActivityThread.java:7777)
[ ] E/MethodChannel#tflite( 1610): at java.lang.reflect.Method.invoke(Native
Method)
[ ] E/MethodChannel#tflite( 1610): at
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
[ ] E/MethodChannel#tflite( 1610): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)
[ +4 ms] E/flutter ( 1610): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled
Exception: PlatformException(error, Unsupported value:
java.lang.ArrayIndexOutOfBoundsException: length=2; index=3, null)
[ ] E/flutter ( 1610): #0 StandardMethodCodec.decodeEnvelope
(package:flutter/src/services/message_codecs.dart:569:7)
[ ] E/flutter ( 1610): #1 MethodChannel._invokeMethod
(package:flutter/src/services/platform_channel.dart:156:18)
[ ] E/flutter ( 1610): <asynchronous suspension>
[ ] E/flutter ( 1610): #2 MethodChannel.invokeMethod
(package:flutter/src/services/platform_channel.dart:329:12)
[ ] E/flutter ( 1610): #3 Tflite.runModelOnFrame
(package:tflite/tflite.dart:67:27)
[ ] E/flutter ( 1610): #4 _CameraState.initState.<anonymous
closure>.<anonymous closure> (package:flutter_realtime_detection/camera.dart:49:22)
[ ] E/flutter ( 1610): #5 CameraController.startImageStream.<anonymous
closure> (package:camera/camera.dart:353:20)
[ ] E/flutter ( 1610): #6 _rootRunUnary (dart:async/zone.dart:1192:38)
[ ] E/flutter ( 1610): #7 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
[ ] E/flutter ( 1610): #8 _CustomZone.runUnaryGuarded
(dart:async/zone.dart:987:7)
[ ] E/flutter ( 1610): #9 _BufferingStreamSubscription._sendData
(dart:async/stream_impl.dart:339:11)
[ ] E/flutter ( 1610): #10 _DelayedData.perform
(dart:async/stream_impl.dart:594:14)
[ ] E/flutter ( 1610): #11 _StreamImplEvents.handleNext
(dart:async/stream_impl.dart:710:11)
[ ] E/flutter ( 1610): #12 _PendingEvents.schedule.<anonymous closure>
(dart:async/stream_impl.dart:670:7)
[ ] E/flutter ( 1610): #13 _rootRun (dart:async/zone.dart:1180:38)
[ ] E/flutter ( 1610): #14 _CustomZone.run (dart:async/zone.dart:1077:19)
[ ] E/flutter ( 1610): #15 _CustomZone.runGuarded (dart:async/zone.dart:979:7)
[ +1 ms] E/flutter ( 1610): #16 _CustomZone.bindCallbackGuarded.<anonymous closure>
(dart:async/zone.dart:1019:23)
[ ] E/flutter ( 1610): #17 _rootRun (dart:async/zone.dart:1184:13)
[ ] E/flutter ( 1610): #18 _CustomZone.run (dart:async/zone.dart:1077:19)
[ ] E/flutter ( 1610): #19 _CustomZone.runGuarded (dart:async/zone.dart:979:7)
[ ] E/flutter ( 1610): #20 _CustomZone.bindCallbackGuarded.<anonymous closure>
(dart:async/zone.dart:1019:23)
[ ] E/flutter ( 1610): #21 _microtaskLoop
(dart:async/schedule_microtask.dart:43:21)
[ ] E/flutter ( 1610): #22 _startMicrotaskLoop
(dart:async/schedule_microtask.dart:52:5)
[ ] E/flutter ( 1610):
[ +482 ms] W/System ( 1610): A resource failed to call close.
[ +1 ms] W/System ( 1610): A resource failed to call destroy.
[ +18 ms] I/chatty ( 1610): uid=10403(com.example.examplerealtime) FinalizerDaemon
identical 1 line
[ ] W/System ( 1610): A resource failed to call destroy.
[+7729 ms] I/CameraManagerGlobal( 1610): Camera 0 facing CAMERA_FACING_BACK state now
CAMERA_STATE_CLOSED for client com.example.examplerealtime API Level 2
Run Code Online (Sandbox Code Playgroud)
错误的原因是什么?
| 归档时间: |
|
| 查看次数: |
1294 次 |
| 最近记录: |