- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试运行我自己的自定义模型来进行对象检测。我从 Google 云 - Vision (https://console.cloud.google.com/vision/) 创建了我的数据集(我对图像进行了装箱和标记),它看起来像这样:
训练模型后,我从这里下载了 TFLite 文件(labelmap.txt、model.tflite 和一个 json 文件):
然后,我将它们添加到 Android 对象检测示例 (https://github.com/tensorflow/examples/tree/master/lite/examples/object_detection/android) 中。
但是当我运行项目时它崩溃了:
2020-07-12 18:03:05.160 14845-14883/? E/AndroidRuntime: FATAL EXCEPTION: inference
Process: org.tensorflow.lite.examples.detection, PID: 14845
java.lang.IllegalArgumentException: Cannot copy to a TensorFlowLite tensor (normalized_input_image_tensor) with 307200 bytes from a Java Buffer with 4320000 bytes.
at org.tensorflow.lite.Tensor.throwIfSrcShapeIsIncompatible(Tensor.java:423)
at org.tensorflow.lite.Tensor.setTo(Tensor.java:189)
at org.tensorflow.lite.NativeInterpreterWrapper.run(NativeInterpreterWrapper.java:154)
at org.tensorflow.lite.Interpreter.runForMultipleInputsOutputs(Interpreter.java:343)
at org.tensorflow.lite.examples.detection.tflite.TFLiteObjectDetectionAPIModel.recognizeImage(TFLiteObjectDetectionAPIModel.java:197)
at org.tensorflow.lite.examples.detection.DetectorActivity$2.run(DetectorActivity.java:182)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.os.HandlerThread.run(HandlerThread.java:67)
我尝试更改参数
TF_OD_API_IS_QUANTIZED 为假和
标签偏移 为 0,我还将这一行从 TFLiteObjectDetectionAPIModel.java 修改为
d.imgData = ByteBuffer.allocateDirect(_4_ * d.inputSize * d.inputSize * 3 * numBytesPerChannel);
(我把 1 换成了 4)
最佳答案
有一个很棒的可视化工具,叫做 Netron .我使用了你的 .tflite 文件,你的模型的输入是:
因此,在您计算字节缓冲区的行的代码中
1 * d.inputSize * d.inputSize * 3 * numBytesPerChannel
1* 320 * 320 * 3 * 1
关于Android - TFLite OD - 无法从 4320000 字节的 Java 缓冲区复制到 307200 字节的 TensorFlowLite 张量 (normalized_input_image_tensor),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62866577/
我正在尝试将我使用 Keras 定义的网络转换为 tflite。网络如下: model = tf.keras.Sequential([ # Embedding tf.k
您使用的模型的顶级目录是什么 :/home/USER/PROJECT/tf-models 我是否编写了自定义代码(而不是使用 TensorFlow 中提供的股票示例脚本) : 否 操作系统平台和发行版
我刚刚使用 Google AutoML 训练了一个单标签图像分类模型,但未能在 Android 手机中使用它。我修改了代码并将我的自定义模型替换为来自 https://github.com/tenso
我正在尝试将经过训练的模型从检查点文件转换为 tflite .我正在使用 tf.lite.LiteConverter .浮点转换顺利进行,推理速度合理。但是INT8的推理速度转换非常慢。我试图通过输入
我试图将 albert 的 .pb 模型转换为 tflite 我使用https://github.com/google-research/albert制作了.pb模型在 tf 1.15 中 我用过tc
我有一个用 Tensorflow.Keras 编写的自定义神经网络,并应用 Hard-swish 函数作为激活(如 MobileNetV3 论文中使用的那样): 实现: def swish(x):
我正在尝试使用来自 TensorFlow for Poets 2 的移动网络传输学习示例进行图像分类的 TFLite 实现 我能够使用代码实验室中的四个花卉样本成功完成迁移学习并获得以下屏幕 这是正在
我是 tensorflow 的新手,我正在尝试将我的 .pb(原型(prototype)缓冲区)文件转换为精简版。但我面临一些问题。import time,sys,warnings,glob,rand
我尝试通过 TFLite 将我的模型 (pb) 转换为精简版。这是我的代码: import tensorflow as tf graph_def_file = "./graph.pb" input_a
有了经过训练的“.h5”Keras 模型文件,我正在尝试优化推理时间: 探索了 2 个选项: 通过 TensorRT 加速推理 'int8' 量化。 此时我可以将模型文件转换为 TensorFlow
我有一个简单的网络,我已经使用 tensorflow 进行了剪枝和量化。我专门按照本教程在我的网络上应用: https://www.tensorflow.org/model_optimization/
我正在加载 this python中的对象检测模型。我可以使用以下代码行加载它: import tflite_runtime.interpreter as tflite model_path = 'p
好的,所以在我的应用程序中,我正在尝试使用人脸网络模型来实现人脸识别,该模型转换为 tflite,平均约为 93 MB, 但是这个模型最终会增加我的 apk 的大小。 所以我正在尝试寻找替代方法来解决
我得到了 MobileNet 的预训练 .pb 文件,发现它没有被量化,而完全量化的模型应该转换成 .tflite 格式。由于我不熟悉移动应用程序开发工具,我如何从 .tflite 文件中获取 M
我想知道是否有办法知道 tflite 中特定节点的输入和输出列表?我知道我可以获得输入/输出详细信息,但这不允许我重建解释器内部发生的计算过程。所以我要做的是: interpreter = tf.li
我对 TensorFlow 和 TensorFlow Lite 相当陌生。我已遵循有关如何使用 toco 量化模型并将模型转换为定点计算的教程。现在我有一个 tflite 文件,它应该只执行定点操作。
我从姿势估计 tflite 模型开始,用于获取人类的关键点。 https://www.tensorflow.org/lite/models/pose_estimation/overview 我开始拟合
我正在使用here中的posenet tflite模型。它接受输入 1*353*257*3 输入图像并返回 4 个尺寸为 1*23*17*17、1*23*17*34、1*23*17*64 和 1*23
我已经阅读了多个代码实验室,在这些代码实验室中,Google 对属于一类的图像进行了分类。如果我需要使用 2 个或更多类怎么办?比如我想对一张图片是水果还是蔬菜进行分类,然后分类是水果还是蔬菜。 最佳
目前,我正在尝试制作一个 Android 食品识别应用程序。我设法构建了一个应用程序来处理图像并在“mobilenet_quant_v1_224.tflite”预训练模型上运行。一切正常,现在我想将自
我是一名优秀的程序员,十分优秀!