问题
I'm working with the Raspberry pi 4, to create an image detection model. I need to turn the model into a lite version since I'm installing it on a card called JeVois.
I have Tensorflow 1.13.1 for Raspberry Pi. And, My problem is the following : I finished the training stage and I made the following steps to export the model in lite format:
python3 export_inference_graph.py --input_type image_tensor --pipeline_config_path training/ssd_mobilenet_v1.config --trained_checkpoint_prefix training/model.ckpt-250000 --output_directory inference_graph
export CONFIG_FILE=/home/pi/TensorflowProject/FishLite/DetectionMultiple/models/research/object_detection/training/ssd_mobilenet_v1.config
export CHECKPOINT_PATH=/home/pi/TensorflowProject/FishLite/DetectionMultiple/models/research/object_detection/training/model.ckpt-250000
export OUTPUT_DIR=/home/pi/TensorflowProject/FishLite/DetectionMultiple/models/research/object_detection/tflite
python3 export_tflite_ssd_graph.py \
--pipeline_config_path=$CONFIG_FILE \
--trained_checkpoint_prefix=$CHECKPOINT_PATH \
--output_directory=$OUTPUT_DIR \
--add_postprocessing_op=true
Up to this point I don't have a problem. However, my problem arises when I execute the following command :
tflite_convert --graph_def_file=tflite/tflite_graph.pb --output_file=tflite/jevois_model1.tflite --input_format=TENSORFLOW_GRAPHDEF --output_format=TFLITE --input_shape=1,${IMAGE_SIZE},${IMAGE_SIZE},3 --input_array=input --output_array=final_result --inference_type=FLOAT --input_data_type=FLOAT
I get the following error message:
Traceback (most recent call last):
File "/usr/local/bin/tflite_convert", line 10, in <module>
sys.exit(main())
File "/usr/local/lib/python3.7/dist-packages/tensorflow_core/lite/python/tflite_convert.py", line 515, in main
app.run(main=run_main, argv=sys.argv[:1])
File "/usr/local/lib/python3.7/dist-packages/tensorflow_core/python/platform/app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/usr/local/lib/python3.7/dist-packages/absl/app.py", line 299, in run
_run_main(main, args)
File "/usr/local/lib/python3.7/dist-packages/absl/app.py", line 250, in _run_main
sys.exit(main(argv))
File "/usr/local/lib/python3.7/dist-packages/tensorflow_core/lite/python/tflite_convert.py", line 511, in run_main
_convert_tf1_model(tflite_flags)
File "/usr/local/lib/python3.7/dist-packages/tensorflow_core/lite/python/tflite_convert.py", line 199, in _convert_tf1_model
output_data = converter.convert()
File "/usr/local/lib/python3.7/dist-packages/tensorflow_core/lite/python/lite.py", line 989, in convert
**converter_kwargs)
File "/usr/local/lib/python3.7/dist-packages/tensorflow_core/lite/python/convert.py", line 412, in toco_convert_graph_def
enable_mlir_converter=enable_mlir_converter)
File "/usr/local/lib/python3.7/dist-packages/tensorflow_core/lite/python/convert.py", line 200, in toco_convert_protos
raise ConverterError("See console for info.\n%s\n%s\n" % (stdout, stderr))
tensorflow.lite.python.convert.ConverterError: See console for info.
2020-01-14 07:24:25.715494: I tensorflow/lite/toco/import_tensorflow.cc:659] Converting unsupported operation: TFLite_Detection_PostProcess
2020-01-14 07:24:25.743504: F tensorflow/lite/toco/tooling_util.cc:935] Check failed: GetOpWithOutput(model, output_array) Specified output array "final_result" is not produced by any op in this graph. Is it a typo? This should not happen. If you trigger this error please send a bug report (with code to reporduce this error), to the TensorFlow Lite team.
Fatal Python error: Aborted
Current thread 0xb6f37ad0 (most recent call first):
File "/usr/local/lib/python3.7/dist-packages/tensorflow_core/lite/toco/python/toco_from_protos.py", line 52 in execute
File "/usr/local/lib/python3.7/dist-packages/absl/app.py", line 250 in _run_main
File "/usr/local/lib/python3.7/dist-packages/absl/app.py", line 299 in run
File "/usr/local/lib/python3.7/dist-packages/tensorflow_core/python/platform/app.py", line 40 in run
File "/usr/local/lib/python3.7/dist-packages/tensorflow_core/lite/toco/python/toco_from_protos.py", line 89 in main
File "/usr/local/bin/toco_from_protos", line 10 in <module>
Aborted
I have searched in several forums, I have tried several solutions. but nothing has worked for me. If anyone has an idea, I'd be very grateful
来源:https://stackoverflow.com/questions/59755872/tensorflow-lite-conversion