我使用 MobileNet_v1_1.0_224 张量流模型进行对象检测。现在,我有自定义冻结图(.pb 文件),需要将其转换为 tflite 扩展名,以便我可以在移动设备上使用我的模型。
有人可以帮我识别这个张量板图中的输入和输出名称吗?我需要它们用作输入和输出参数,以将我的冻结图(.pb 文件)转换为tensorflow lite(.tflite)文件
参考错误:配置值 download_clang 未在任何 .rc 文件中定义。我陷入了同样的问题。我有tensorflow 2并且已签出分支 r2.2 。我有相同的错误:错误:配置值 download_clang 不是在任何 .rc 文件中定义。谁能告诉我理想情况下我应该安装哪个 bazel 版本。我已经尝试过 2.0 和 3.0
如果我在 MLKit 中使用预训练的 TFLite 对象检测模型,则会收到以下错误:
Run Code Online (Sandbox Code Playgroud)CalculatorGraph::Run() failed in Run: Calculator::Open() for node "BoxClassifierCalculator" failed: #vk Unexpected number of dimensions for output index 0: got 3D, expected either 2D (BxN with B=1) or 4D (BxHxWxN with B=1, W=1, H=1).
知道我可能做错了什么吗?
使用 TFlite 文件并将其嵌入实际 Android 应用程序的分步说明是什么?作为参考,这是回归。输入将是图像,输出应该是数字。我已经看过 TensorFlow 文档,但他们没有解释如何从头开始。
Tensorflow 有几个基准测试工具:
我对 .pb 基准工具的参数有几个问题:
num_threads相关的单线程实验或通过使用tensorflow内螺纹平行运行次数?还有一些关于结果解释的问题:
count在结果输出?如何Timings (microseconds): count=相关--max_num_runs的参数?例子:
Run --num_threads=-1 --max_num_runs=1000:
2019-03-20 14:30:33.253584: I tensorflow/core/util/stat_summarizer.cc:85] Timings (microseconds): count=1000 first=3608 curr=3873 min=3566 max=8009 avg=3766.49 std=202
2019-03-20 14:30:33.253584: I tensorflow/core/util/stat_summarizer.cc:85] Memory (bytes): count=1000 curr=3301344(all same)
2019-03-20 14:30:33.253591: I tensorflow/core/util/stat_summarizer.cc:85] 207 nodes observed
2019-03-20 14:30:33.253597: I tensorflow/core/util/stat_summarizer.cc:85]
2019-03-20 14:30:33.378352: I tensorflow/tools/benchmark/benchmark_model.cc:636] FLOPs estimate: 116.65M
2019-03-20 14:30:33.378390: I tensorflow/tools/benchmark/benchmark_model.cc:638] FLOPs/second: 46.30B
Run --num_threads=1 --max_num_runs=1000:
2019-03-20 …Run Code Online (Sandbox Code Playgroud) 我在原生 Android 上使用带有 TensorFlow Lite 的自定义对象检测模型。在这一点上,我只检测到 2 个自定义对象。我正在使用 TensorFlow 对象检测 API,并且我有一个管道可以生成优化的 .tflite 文件。
但是,在推理时,该模型最多只返回 10 个单独的检测。根据https://www.tensorflow.org/lite/models/object_detection/overview,这是预期的。问题是我的图像具有相对较大的对象密度。我需要能够在每个图像/推理调用中检测多达 30 个单独的对象。
如果我将示例 Android 应用程序中的 NUM_DETECTIONS 从 TF 存储库从 10 更改为 20,由于形状不匹配,我会收到运行时异常。如何生成能够产生超过 10 个对象检测实例的 .tflite 文件?
谢谢!
我已经在 keras 中训练了我自己的图像分类模型模型,并将其转换为 tflite 然后我想通过 tensorflow lite 在 android 中使用该模型。为此,我使用了一个 github 项目来直接获取该项目的应用程序链接:
但是我在 logcat 中遇到了这个错误:
2020-03-30 14:50:48.747 27421-27421/com.amitshekhar.tflite E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.amitshekhar.tflite, PID: 27421
java.lang.IllegalArgumentException: Cannot copy between a TensorFlowLite tensor with shape [2] and a Java object with shape [1, 2].
at org.tensorflow.lite.Tensor.throwIfShapeIsIncompatible(Tensor.java:342)
at org.tensorflow.lite.Tensor.throwIfDataIsIncompatible(Tensor.java:305)
at org.tensorflow.lite.Tensor.copyTo(Tensor.java:183)
at org.tensorflow.lite.NativeInterpreterWrapper.run(NativeInterpreterWrapper.java:166)
at org.tensorflow.lite.Interpreter.runForMultipleInputsOutputs(Interpreter.java:311)
at org.tensorflow.lite.Interpreter.run(Interpreter.java:272)
at com.amitshekhar.tflite.TensorFlowImageClassifier.recognizeImage(TensorFlowImageClassifier.java:70)
at com.amitshekhar.tflite.MainActivity$1.onImage(MainActivity.java:75)
at com.wonderkiln.camerakit.EventDispatcher$1.run(EventDispatcher.java:42)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7094)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:536)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:928)
Run Code Online (Sandbox Code Playgroud)
对此的任何帮助将不胜感激,此外,除了我的模型的输入大小和我自己的 tflite …
我正在尝试在 Android 上运行 tflite 模型以进行对象检测。对于相同的,
(a) 培训:
!python3 object_detection/model_main.py \
--pipeline_config_path=/content/drive/My\ Drive/Detecto\ Tutorial/models/research/object_detection/samples/configs/ssd_mobilenet_v2_coco.config \
--model_dir=training/
Run Code Online (Sandbox Code Playgroud)
(修改配置文件以指向提到我的特定 TFrecords 的位置)
(b) 导出推理图
!python /content/drive/'My Drive'/'Detecto Tutorial'/models/research/object_detection/export_inference_graph.py \
--input_type=image_tensor \
--pipeline_config_path=/content/drive/My\ Drive/Detecto\ Tutorial/models/research/object_detection/samples/configs/ssd_mobilenet_v2_coco.config \
--output_directory={output_directory} \
--trained_checkpoint_prefix={last_model_path}
Run Code Online (Sandbox Code Playgroud)
(c) 创建 tflite 就绪图
!python /content/drive/'My Drive'/'Detecto Tutorial'/models/research/object_detection/export_tflite_ssd_graph.py \
--pipeline_config_path=/content/drive/My\ Drive/Detecto\ Tutorial/models/research/object_detection/samples/configs/ssd_mobilenet_v2_coco.config \
--output_directory={output_directory} \
--trained_checkpoint_prefix={last_model_path} \
--add_postprocessing_op=true
Run Code Online (Sandbox Code Playgroud)
我使用图形文件中的 tflite_convert 创建了一个 tflite 模型,如下所示
!tflite_convert
--graph_def_file=/content/drive/My\ Drive/Detecto\ Tutorial/models/research/fine_tuned_model/tflite_graph.pb
--output_file=/content/drive/My\ Drive/Detecto\ Tutorial/models/research/fine_tuned_model /detect3.tflite
--output_format = TFLITE
--input_shapes = 1,300,300,3
--input_arrays = normalized_input_image_tensor
--output_arrays = 'TFLite_Detection_PostProcess', 'TFLite_Detection_PostProcess:1', 'TFLite_Detection_PostProcess:2', …
tensorflow ×8
android ×2
python ×2
bazel ×1
benchmarking ×1
c++ ×1
google-mlkit ×1
metadata ×1
raspberry-pi ×1
tensorboard ×1