【发布时间】:2020-12-12 17:06:34
【问题描述】:
我正在做一个包含对象检测 AI 的研究项目,能够通过网络摄像头检测 7 类对象。
使用google colab,我成功训练了ssd_mobilenet_v2_quantized_300x300_coco模型,使用tensorflow 1.15。
目标是在 Raspberry Pi 3b+ 中运行模型,使用官方相机和 Google Coral EdgeTPU 设备,因此必须对模型进行量化才能使用它。
问题出在测试部分;因此在训练模型后,使用以下方法将其转换为 tflite:
!python export_tflite_ssd_graph.py --pipeline_config_path="/content/drive/My Drive/Colab Data/models/research/object_detection/training/ssd_mobilenet_v2_quantized_300x300_coco.config" --trained_checkpoint_prefix=training/model.ckpt-28523 --output_directory=compiler/ --add_postprocessing_op=true
和
!tflite_convert --graph_def_file=compiler/tflite_graph.pb --output_file=compiler/detect.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','TFLite_Detection_PostProcess:3' --inference_type=QUANTIZED_UINT8 --mean_values=128 --std_dev_values=128 --change_concat_input_ranges=false --allow_custom_ops
转换后的模型:https://gofile.io/d/kOe2Ac
尝试使用 Edje Electronics 网络摄像头脚本测试模型。 found here
并输出此错误:
RuntimeError: tensorflow/lite/kernels/detection_postprocess.cc:404 ValidateBoxes(decoded_boxes, num_boxes) was not true.Node number 98 (TFLite_Detection_PostProcess) failed to invoke.
最奇怪的是,如果我尝试在我当前的工作站(使用 tensorflow 1.15.1)中运行相同的脚本,代码运行完美,所以 rpi 应该有问题。
rpi 正在运行 tensorflow 1.15.2,由 WHL 源代码构建。实际上,我尝试了所有版本,但总是出现相同的错误。
如果能给我带来任何帮助,我将不胜感激。提前致谢。
【问题讨论】:
-
您是否尝试过从 zoo 准备好的量化模型以在您的 RPi 配置上运行以确保 SW/HW 正常?
-
是的,已经尝试使用来自 googleapis 的 coco_ssd_mobilenet_v1_1.0_quant_2018_06_29 ......完美运行。所以我仍然不明白为什么会出现这种奇怪的行为。如果我的模型没有得到正确的训练或编译,它将无法在工作站上运行,并且运行良好……也许它与 rpi 上的 tensorflow lite 相关?
-
是否可以在没有 TPU 的情况下在 RPi 上测试您的模型?
-
是的,同样的错误也会发生
-
能否分享一下 tflite 模型或底部的屏幕截图,如 Netron 中所见?什么是“节点号 98”也可以派上用场。它也可以在 netron 中找到。我认为解码器有问题:他们有解码器处理器的自定义操作,它可能与您的更改不兼容。
标签: tensorflow object-detection tensorflow-lite