tensorflow - 在珊瑚板上使用非量化的 deeplab 模型
问题描述
我在珊瑚开发板上使用了 deeplab v3 的量化模型。结果不是很精确,所以我想使用非量化模型。
我可以找到 deeplab 的 tflite 非量化模型,所以我想生成它。我在 Tensorflow github 上下载了一个 xception65_coco_voc_trainval 模型: xception65_coco_voc_trainval
然后我使用该命令来转换输入:
bazel-bin/tensorflow/tools/graph_transforms/transform_graph \
--in_graph="/path/to/xception65_coco_voc_trainval.pb" \
--out_graph="/path/to/xception65_coco_voc_trainval_flatten.pb" \
--inputs='ImageTensor' \
--outputs='SemanticPredictions' \
--transforms='
strip_unused_nodes(type=quint8, shape="1,513,513,3")
flatten_atrous_conv
fold_constants(ignore_errors=true, clear_output_shapes=false)
fold_batch_norms
fold_old_batch_norms
remove_device
sort_by_execution_order
然后我用这个命令生成 tflite 文件:
tflite_convert \
--graph_def_file="/tmp/deeplab_mobilenet_v2_opt_flatten_static.pb" \
--output_file="/tmp/deeplab_mobilenet_v2_opt_flatten_static.tflite" \
--output_format=TFLITE \
--input_shape=1,513,513,3 \
--input_arrays="ImageTensor" \
--inference_type=FLOAT \
--inference_input_type=QUANTIZED_UINT8 \
--std_dev_values=128 \
--mean_values=128 \
--change_concat_input_ranges=true \
--output_arrays="SemanticPredictions" \
--allow_custom_ops
这个命令为我生成了一个 tflite 文件。我将文件下载到我的珊瑚开发板上并尝试运行它。
我在 github 上使用该示例来尝试我在珊瑚上的 deeplab 模型: deeplab oncoral
当我启动程序时出现错误:
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted
错误来自该行:
engine = BasicEngine(args.model)
解决方案
推荐阅读
- python - 是否可以通过 PythonSelenium 以从一开始就显示菜单栏的方式启动 Firefox?
- javascript - Firebase 函数未向客户端应用返回响应
- java - Java 无法为 JDBC 驱动程序加载类
- javascript - 使用循环触发多个锚标签的相同 onclick 功能
- typescript - TypeScript:指定方法返回“this”类型
- javascript - 如何在点击时将新页面滚动到顶部?
- python - 我无法在我的 python 3.8 中安装 PyAudio 我该怎么办?
- reactjs - React onClick:无法读取未定义的属性'functionName'
- git - 有没有办法在 github 上查看 .ipynb 文件更改但不是 JSON 格式?
- javascript - Firebase 函数和外部节点包