java.lang.IllegalArgumentException:无法在具有形状的 TensorFlowLite 张量之间复制 [英] java.lang.IllegalArgumentException: Cannot copy between a TensorFlowLite tensor with shape

查看:24
本文介绍了java.lang.IllegalArgumentException:无法在具有形状的 TensorFlowLite 张量之间复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近几天我一直在尝试这个.我从这里下载了一个示例.我已经替换了模型 Detect.tflite 和标签文件并使用我自己的文件代替,但最终出现了几个错误,如下所示:

I have been trying this for a last few days. I have downloaded a sample from here. I have replaced the model Detect.tflite and label file and put my own instead, but ended up with several errors as shown below:

java.lang.IllegalArgumentException:无法在 1080000 字节的 TensorFlowLite 缓冲区和 270000 字节的 ByteBuffer 之间进行转换.

java.lang.IllegalArgumentException: Cannot convert between a TensorFlowLite buffer with 1080000 bytes and a ByteBuffer with 270000 bytes.

还有这个:

java.lang.IllegalArgumentException:无法在形状为 [1, 1917, 4] 的 TensorFlowLite 张量和形状为 [1, 10,4] 的 Java 对象之间进行复制.

java.lang.IllegalArgumentException: Cannot copy between a TensorFlowLite tensor with shape [1, 1917, 4] and a Java object with shape [1, 10,4].

请帮忙.

推荐答案

问题在于模型的输入张量与我们在代码中提到的数组(Android)不匹配.

The issue is all about the mismatch of input tensor from the model and the array we mention in the code(Android).

改变输入张量起到了作用,模型在这种情况下运行良好.

Changing in the input tensor did the trick and model worked well in this case.

输入张量形状数组从python端更改为[1, 10,4].

The input tensor shape array was changed to [1, 10,4] from python side.

这篇关于java.lang.IllegalArgumentException:无法在具有形状的 TensorFlowLite 张量之间复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆