tensorflow: tflite_convert - ValueError: Invalid tensors 'input' were found.

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Window10
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: No
  • TensorFlow installed from (source or binary): pip install tensorflow
  • TensorFlow version (use command below): 1.12
  • Python version: 3.6.7
  • Bazel version (if compiling from source): No
  • GCC/Compiler version (if compiling from source): No
  • CUDA/cuDNN version: No
  • GPU model and memory: No

Describe the current behavior I want to convert mobilenet_v1_0.50_128 frozen graph using tflite_convert or toco to a TensorFlow Lite model, but I get the following error:

2019-02-20 16:09:37.352780: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
Traceback (most recent call last):
  File "c:\users\alice\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)

  File "c:\users\alice\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)

  File "C:\Users\Alice\Anaconda3\Scripts\tflite_convert.exe\__main__.py", line 9, in <module>

  File "c:\users\alice\anaconda3\lib\site-packages\tensorflow\lite\python\tflite_convert.py", line 442, in main
    app.run(main=run_main, argv=sys.argv[:1])

  File "c:\users\alice\anaconda3\lib\site-packages\tensorflow\python\platform\app.py", line 40, in run
    _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)

  File "c:\users\alice\anaconda3\lib\site-packages\absl\app.py", line 300, in run
    _run_main(main, args)

  File "c:\users\alice\anaconda3\lib\site-packages\absl\app.py", line 251, in _run_main
    sys.exit(main(argv))

  File "c:\users\alice\anaconda3\lib\site-packages\tensorflow\lite\python\tflite_convert.py", line 438, in run_main
    _convert_model(tflite_flags)

  File "c:\users\alice\anaconda3\lib\site-packages\tensorflow\lite\python\tflite_convert.py", line 122, in _convert_model
    converter = _get_toco_converter(flags)

  File "c:\users\alice\anaconda3\lib\site-packages\tensorflow\lite\python\tflite_convert.py", line 109, in _get_toco_converter
    return converter_fn(**converter_kwargs)

  File "c:\users\alice\anaconda3\lib\site-packages\tensorflow\lite\python\lite.py", line 387, in from_frozen_graph
    sess.graph, input_arrays)

  File "c:\users\alice\anaconda3\lib\site-packages\tensorflow\lite\python\convert_saved_model.py", line 189, in get_tensors_from_tensor_names
    ",".join(invalid_tensors)))

ValueError: Invalid tensors 'input' were found.

Code to reproduce the issue I run the following command: tflite_convert --output_file=tflite_convert --output_file=F:/mobilenet_v1_0.50_128/frozen_graph.tflite --graph_def_file=F:/mobilenet_v1_0.50_128/frozen_graph.pb --input_arrays=input --output_arrays=MobilenetV1/Predictions/Reshape_1

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16

Most upvoted comments

not sure if this approach is right. im using mobilnetv2 i tried printing available values from convert_saved_model.py print(tensor_name_to_tensor) - this will give all the valid values. i used --input_arrays=module_apply_default/MobilenetV2/input (which is available in print) this is working for me. converted model tested in android device.

Hello,

I’m facing same problem here

Here is the command that i’m executing to generate .pb i am successfully generate it.

IMAGE_SIZE=224
ARCHITECTURE="mobilenet_1_1.0_${IMAGE_SIZE}"

python retrain.py  
 --bottleneck_dir=tf_files/bottlenecks   
 --how_many_training_steps=500   
 --model_dir=tf_files/models/   
 --summaries_dir=tf_files/training_summaries/"${ARCHITECTURE}"  
  --output_graph=tf_files/retrained_graph.pb   
  --output_labels=tf_files/retrained_labels.txt   
  --architecture="${ARCHITECTURE}"  
  --image_dir=tf_files/flower_photos

Once i am trying to create that .pb to .tflite get fail with same error “ValueError: Invalid tensors ‘input’ were found.”

tflite_convert \
  --output_file=foo.tflite \
  --graph_def_file=retrained_graph.pb \
  --input_arrays=input \
  --output_arrays=MobilenetV1/Predictions/Reshape_1