am15h / tflite_flutter_plugin

TensorFlow Lite Flutter Plugin
https://pub.dev/packages/tflite_flutter
Apache License 2.0
508 stars 353 forks source link

Support for quantized models #121

Open MoodPatterns opened 3 years ago

MoodPatterns commented 3 years ago

Models with quantized weights (not input or output tensors), don't seem to work.

While a tflite model created with

converter = tf.lite.TFLiteConverter.from_saved_model("./model_path/")
tflite_model = converter.convert()

works perfectly fine, the same tflite model created with

converter = tf.lite.TFLiteConverter.from_saved_model("./model_path/")
converter.optimizations = [tf.lite.Optimize.DEFAULT]
tflite_model = converter.convert()

throws _Fatal signal 6 (SIGABRT), code -1 (SIQUEUE)

when the tflite_flutter interpreter is run.

Both models run fine in Python.

am15h commented 3 years ago

Quantized models are supported, Image Classification and Object Detection Examples use quantized models. Can you share a detailed error log?

MoodPatterns commented 3 years ago

sure, when I switch out the un-optimized for the optimized model I get the following error on _interpreter!.run(inputImage.buffer, output.getBuffer());:

F/libc    ( 5054): Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 5127 (DartWorker), pid 5054 (odpatterns.egao)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'Sony/H8216/H8216:10/52.1.A.3.49/052001A003004902006556692:user/release-keys'
Revision: '0'
ABI: 'arm64'
Timestamp: 2021-06-02 11:22:33+0200
pid: 5054, tid: 5127, name: DartWorker  >>> info.moodpatterns.egao <<<
uid: 10443
signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
    x0  0000000000000000  x1  0000000000001407  x2  0000000000000006  x3  000000754787ab10
    x4  0000000000000078  x5  0000000000000078  x6  0000000000000078  x7  0000000000000078
    x8  00000000000000f0  x9  3bee5314b9aaffcf  x10 0000000000000001  x11 0000000000000000
    x12 fffffff0fffffbdf  x13 fffffffffc000000  x14 0000000000000200  x15 0000000000000008
    x16 000000765bcd98c0  x17 000000765bcb5c80  x18 0000000000000001  x19 00000000000013be
    x20 0000000000001407  x21 00000000ffffffff  x22 0000000000000078  x23 00000075594057a0
    x24 00000075591c79cc  x25 00000075594022b0  x26 0000007559401050  x27 000000754787c020
    x28 0000007573372208  x29 000000754787abb0
    sp  000000754787aaf0  lr  000000765bc6752c  pc  000000765bc67558
backtrace:
      #00 pc 0000000000083558  /apex/com.android.runtime/lib64/bionic/libc.so (abort+160) (BuildId: 4ac85d8f66f3a910f00f4ebf4d6bcd1a)
      #01 pc 00000000002f9fe0  /data/app/info.moodpatterns.egao-CLG5do6hqczxjfkW9F1v6A==/lib/arm64/libtensorflowlite_c.so
      #02 pc 00000000002f9528  /data/app/info.moodpatterns.egao-CLG5do6hqczxjfkW9F1v6A==/lib/arm64/libtensorflowlite_c.so
      #03 pc 000000000007c6a0  /data/app/info.moodpatterns.egao-CLG5do6hqczxjfkW9F1v6A==/lib/arm64/libtensorflowlite_c.so
      #04 pc 000000000016ad24  /data/app/info.moodpatterns.egao-CLG5do6hqczxjfkW9F1v6A==/lib/arm64/libtensorflowlite_c.so
      #05 pc 000000000016a620  /data/app/info.moodpatterns.egao-CLG5do6hqczxjfkW9F1v6A==/lib/arm64/libtensorflowlite_c.so
      #06 pc 000000000016af44  /data/app/info.moodpatterns.egao-CLG5do6hqczxjfkW9F1v6A==/lib/arm64/libtensorflowlite_c.so
      #07 pc 000000000016ead8  /data/app/info.moodpatterns.egao-CLG5do6hqczxjfkW9F1v6A==/lib/arm64/libtensorflowlite_c.so
      #08 pc 0000000000006694  <anonymous:755d680000>
Lost connection to device.