I just started trying Tensorflow, I'd like to do some experiments on Android, but I read that Tensorflow for Poets (the version for mobile) support .tflite while the models I downloaded and found googling are .pb.
So I decided to convert them using toco, but when I execute the command to convert I always get this error
ValueError: Invalid tensors 'input' were found.
The CLI command is:
toco --graph_def_file=tensorflow_inception_graph.pb --output_file=optimized_graph.tflite --input_format=TENSORFLOW_GRAPHDEF --output_format=TFLITE --input_shape=1,300,300,3 --input_array=input --o
utput_array=final_result --inference_type=FLOAT --inference_input_type=FLOAT
What's wrong with that?
Stacktrace
File "/home/Mitro/venv/bin/toco", line 11, in <module>
sys.exit(main())
File "/home/Mitro/venv/lib/python3.5/site-packages/tensorflow/contrib/lite/python/tflite_convert.py", line 401, in main
app.run(main=run_main, argv=sys.argv[:1])
File "/home/Mitro/venv/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
File "/home/Mitro/venv/lib/python3.5/site-packages/tensorflow/contrib/lite/python/tflite_convert.py", line 397, in run_main
_convert_model(tflite_flags)
File "/home/Mitro/venv/lib/python3.5/site-packages/tensorflow/contrib/lite/python/tflite_convert.py", line 100, in _convert_model
converter = _get_toco_converter(flags)
File "/home/Mitro/venv/lib/python3.5/site-packages/tensorflow/contrib/lite/python/tflite_convert.py", line 87, in _get_toco_converter
return converter_fn(**converter_kwargs)
File "/home/Mitro/venv/lib/python3.5/site-packages/tensorflow/contrib/lite/python/lite.py", line 271, in from_frozen_graph
sess.graph, input_arrays)
File "/home/Mitro/venv/lib/python3.5/site-packages/tensorflow/contrib/lite/python/convert_saved_model.py", line 189, in get_tensors_from_tensor_names
",".join(invalid_tensors)))
Run this script changing the model_file parameter to the pb file, and as an output you will have something like this:
Tensor("import/ Placeholder :0", shape=(?, 299, 299, 3), dtype=float32)
Tensor("import/ final_result :0", shape=(?, 5), dtype=float32)
in this case they are the parameters that you must pass through
--input_array = Placeholder
--output_array = final_result
Here is the complete information
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.