【问题标题】:java.lang.IllegalArgumentException: ByteBuffer is not a valid flatbuffer modeljava.lang.IllegalArgumentException:ByteBuffer 不是有效的平面缓冲区模型
【发布时间】:2021-02-09 20:34:31
【问题描述】:

拜托,我急需帮助,已经尝试解决这个问题 10 天了。我训练的 TensorFlow lite 模型在这里。我运行了 python 推理测试并且它有效。但是,它无法在此处的 Android 示例对象检测应用程序上运行 https://github.com/tensorflow/examples/tree/master/lite/examples/object_detection/android

通过调试这么长的问题modelHandle = createModelWithBuffer(this.modelByteBuffer, errorHandle); specifically this part in NativeInterpreterWrapper.class

NativeInterpreterWrapper(ByteBuffer buffer, Options options) {
this.inferenceDurationNanoseconds = -1L;
this.isMemoryAllocated = false;
this.delegates = new ArrayList();
this.ownedDelegates = new ArrayList();
TensorFlowLite.init();
if (buffer != null && (buffer instanceof MappedByteBuffer || buffer.isDirect() && buffer.order() == ByteOrder.nativeOrder())) {
this.modelByteBuffer = buffer;
long errorHandle = createErrorReporter(512);
long modelHandle = createModelWithBuffer(this.modelByteBuffer, errorHandle);
this.init(errorHandle, modelHandle, options);
} else {
throw new IllegalArgumentException("Model ByteBuffer should be either a MappedByteBuffer of the model file, or a direct ByteBuffer using ByteOrder.nativeOrder() which contains bytes of model content.");
}
}

系统信息

我是否编写了自定义代码(而不是使用 TensorFlow 中提供的股票示例脚本): 操作系统平台 MACOS sieera 10.13 安卓工作室 4 我已经尝试了所有可能的解决方案并更新了 NDK 我在 Gradle 中使用过

buildscript {
repositories {
google()
jcenter()
mavenLocal()
}

aaptOptions {
noCompress "tflite"
noCompress "lite"
}

implementation 'org.tensorflow:tensorflow-lite-metadata:0.0.0-nightly'
implementation 'org.tensorflow:tensorflow-lite-select-tf-ops:0.0.0-nightly'
also tried
implementation 'org.tensorflow:tensorflow-lite-metadata:0.1.2-nightly' and no difference

请帮帮我,我不知道是文件本身还是android库。

【问题讨论】:

  • 在此处发布错误

标签: android gradle exception object-detection tensorflow-lite


【解决方案1】:

您的模型文件可能已损坏。我遇到了同样的问题,然后我意识到我的模型文件已损坏,它只有 4mb 大小,而实际模型大小超过 160mb。

【讨论】:

    猜你喜欢
    • 2014-10-10
    • 1970-01-01
    • 2022-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-06
    • 1970-01-01
    相关资源
    最近更新 更多