1
votes

I am following this tutorial tensorflow for poets and i created custom training data and converted it to .pb but when i try to convert .pb to .tflite using toco I am getting an error

2018-10-10 13:56:40.442130: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1233] Converting unsupported operation: DecodeJpeg 2018-10-10 13:56:40.471545: I tensorflow/contrib/lite/toco/graph_transformations/graph_transformations.cc:39] Before Removing unused ops: 706 operators, 1102 arrays (0 quantized) 2018-10-10 13:56:40.485896: I tensorflow/contrib/lite/toco/graph_transformations/graph_transformations.cc:39] After Removing unused ops pass 1: 607 operators, 1003 arrays (0 quantized) 2018-10-10 13:56:40.502109: I tensorflow/contrib/lite/toco/graph_transformations/graph_transformations.cc:39] Before general graph transformations: 607 operators, 1003 arrays (0 quantized) 2018-10-10 13:56:40.581854: I tensorflow/contrib/lite/toco/graph_transformations/graph_transformations.cc:39] After general graph transformations pass 1: 129 operators, 327 arrays (0 quantized) 2018-10-10 13:56:40.584067: I tensorflow/contrib/lite/toco/graph_transformations/graph_transformations.cc:39] After general graph transformations pass 2: 126 operators, 321 arrays (0 quantized) 2018-10-10 13:56:40.586222: I tensorflow/contrib/lite/toco/graph_transformations/graph_transformations.cc:39] After general graph transformations pass 3: 125 operators, 319 arrays (0 quantized) 2018-10-10 13:56:40.588344: I tensorflow/contrib/lite/toco/graph_transformations/graph_transformations.cc:39] Before dequantization graph transformations: 125 operators, 319 arrays (0 quantized) 2018-10-10 13:56:40.590472: I tensorflow/contrib/lite/toco/allocate_transient_arrays.cc:311] Total transient array allocated size: 0 bytes, theoretical optimal value: 0 bytes. 2018-10-10 13:56:40.591866: F tensorflow/contrib/lite/toco/tflite/export.cc:304] Some of the operators in the model are not supported by the standard TensorFlow Lite runtime. If you have a custom implementation for them you can disable this error with --allow_custom_ops. Here is a list of operators for which you will need custom implementations: DecodeJpeg, ExpandDims. Aborted (core dumped)

1
i solved the above error by upgrading from tensor flow 1.7 to 1.11 but now i am getting a new error toco: error: one of the arguments --graph_def_file --saved_model_dir --keras_model_file is required - Natansh Pandya
Please provide the command you are running for reference. You will likely have to change --input_file to --graph_def_file. An example command line is available here. - Nupur Garg
i changed the input file to --graph_def_file and its now giving me a different error Error Message File "/home/infinity/.local/lib/python3.6/site-packages/tensorflow/contrib/lite/python/lite.py", line 271, in from_frozen_graph sess.graph, input_arrays) File "/home/infinity/.local/lib/python3.6/site-packages/tensorflow/contrib/lite/python/convert_saved_model.py", line 189, in get_tensors_from_tensor_names ",".join(invalid_tensors))) ValueError: Invalid tensors 'input' were found. - Natansh Pandya
solved it I guess the syntax errors were because of python version mix just compiled everything with python3 and successfully converted .pb file to .tflite - Natansh Pandya

1 Answers

0
votes
toco \
  --input_format=TENSORFLOW_GRAPHDEF \
  --graph_def_file=tf_files/object_graph.pb \
  --output_format=TFLITE \
  --output_file=tf_files/qobject.lite \
  --inference_type=QUANTIZED_UINT8 \
  --inference_input_type=QUANTIZED_UINT8 \
  --input_arrays=input \
  --output_arrays=final_result \
  --input_shapes=1,224,224,3\
  --mean_values=128 \
  --std_dev_values=128 \
  --default_ranges_min=0 \
  --default_ranges_max=6

just use this this code convert .pb file in to lite and also quantized