detect.tflite无法将TF模型转换为tflite

2024-09-29 19:06:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用mac,运行Catalina 10.15.5,使用Python 2.7.17,从源代码运行Tensorflow 1.15.3,使用pip安装,而不是Anaconda,我的bazel版本是0.26.1

我正在尝试将ssd_mobilenet_v3_small_coco上的自定义模型转换为TFlite,遵循本教程:On step 3但无法使用以下行将我的TFlite_graph.pb转换为detect.TFlite:

bazel run --config=opt tensorflow/lite/toco:toco -- --input_file=/Users/jp3spinelli/Desktop/models/research/object_detection/TFLite_model/tflite_graph.pb --output_file=/Users/jp3spinelli/Desktop/models/research/object_detection/TFLite_model/detect.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=FLOAT --allow_custom_ops

我一直遇到这个错误(我只包括最后一点,因为它很长):

WARNING: /Users/jp3spinelli/tensorflow/tensorflow/core/BUILD:2455:12: in srcs attribute of cc_library rule //tensorflow/core:lib_internal_impl: please do not import '//tensorflow/core/lib/strings:proto_text_util.cc' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /Users/jp3spinelli/tensorflow/tensorflow/core/BUILD:2455:12: in srcs attribute of cc_library rule //tensorflow/core:lib_internal_impl: please do not import '//tensorflow/core/lib/strings:scanner.cc' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /Users/jp3spinelli/tensorflow/tensorflow/core/BUILD:2455:12: in srcs attribute of cc_library rule //tensorflow/core:lib_internal_impl: please do not import '//tensorflow/core/lib/strings:strcat.cc' directly. You should either move the file to this package or depend on an appropriate rule there
INFO: Analyzed target //tensorflow/lite/toco:toco (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //tensorflow/lite/toco:toco up-to-date:
  bazel-bin/tensorflow/lite/toco/toco
INFO: Elapsed time: 0.472s, Critical Path: 0.00s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/tensorflow/lite/toco/toco '--input_file=/Users/jp3spinelli/Desktop/models/research/object_detection/TFLite_model/tflite_graph.pb' '--output_file=/Users/jp3spinelli/Desktop/models/research/object_detection/TFLite_model/detect.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_DetectioINFO: Build completed successfully, 1 total action
2020-07-21 18:03:47.675656: I tensorflow/lite/toco/import_tensorflow.cc:659] Converting unsupported operation: TFLite_Detection_PostProcess
2020-07-21 18:03:47.691874: F tensorflow/lite/toco/tooling_util.cc:1669] Check failed: input_array_dims[i] == input_array_proto.shape().dims(i) (320 vs. 300)
Abort trap: 6

它正在创建一个文件,但它没有字节,所以我知道有些地方出错了。 我正在使用我的tensorflow目录,它位于我的主目录中。我注意到的一件奇怪的事情是,我桌面上“models”文件夹的路径显示它是从“iclouddrive”开始的,而不是从“Users”开始的

请让我知道如何解决这个问题,我是新的编码,所以我需要一些逐步的说明。谢谢


Tags: coreinfoinputlibtensorflowliteruleusers
1条回答
网友
1楼 · 发布于 2024-09-29 19:06:43

我认为您应该将“”之间的输出_数组设置为字符串,尝试运行如下操作:

bazel run  config=opt tensorflow/lite/toco:toco   \
 input_file=$OUTPUT_DIR/tflite_graph.pb \
 output_file=$OUTPUT_DIR/detect.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=FLOAT \
 allow_custom_ops

相关问题 更多 >

    热门问题