Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help Needed to convert the frozen graph to Tensorflow lite model #55

Open
Suraj520 opened this issue Jul 18, 2019 · 4 comments
Open

Help Needed to convert the frozen graph to Tensorflow lite model #55

Suraj520 opened this issue Jul 18, 2019 · 4 comments

Comments

@Suraj520
Copy link

Suraj520 commented Jul 18, 2019

Hi @victordibia,
I am currently trying to convert the frozen inference graph in the repo to .tflite for integrating with an android application. However, I am trying to do that I am facing errors.

Below is the script that I am using to convert the frozen graph to tflite and the error log is also reference below. It would be great if you can share some insights.

Thanks,
Suraj

Code
`
import tensorflow as tf

localpb = 'frozen_inference_graph.pb'
tflite_file = 'hand_detector.lite'

print("{} -> {}".format(localpb, tflite_file))

converter = tf.lite.TFLiteConverter.from_frozen_graph(
#converter =tf.contrib.lite.TocoConverter.from_frozen_graph(
localpb,
['Const'],
['num_detections'])

tflite_model = converter.convert()
`

Error Log

`frozen_inference_graph.pb -> hand_detector.lite
2019-07-18 14:50:50.053195: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-07-18 14:50:50.077006: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3192000000 Hz
2019-07-18 14:50:50.077666: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x4b47c90 executing computations on platform Host. Devices:
2019-07-18 14:50:50.077680: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): ,
2019-07-18 14:50:50.515219: I tensorflow/core/grappler/devices.cc:60] Number of eligible GPUs (core count >= 8, compute capability >= 0.0): 0 (Note: TensorFlow was not compiled with CUDA support)
2019-07-18 14:50:50.515312: I tensorflow/core/grappler/clusters/single_machine.cc:356] Starting new session
2019-07-18 14:50:50.782857: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:716] Optimization results for grappler item: graph_to_optimize
2019-07-18 14:50:50.782885: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:718] constant folding: Graph size after: 978 nodes (-1201), 1257 edges (-1368), time = 192.627ms.
2019-07-18 14:50:50.782890: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:718] constant folding: Graph size after: 978 nodes (0), 1257 edges (0), time = 33.785ms.
Traceback (most recent call last):
File "HandTfliteConverter.py", line 14, in
tflite_model = converter.convert()
File "/usr/local/lib/python2.7/dist-packages/tensorflow_core/lite/python/lite.py", line 983, in convert
**converter_kwargs)
File "/usr/local/lib/python2.7/dist-packages/tensorflow_core/lite/python/convert.py", line 437, in toco_convert_impl
enable_mlir_converter=enable_mlir_converter)
File "/usr/local/lib/python2.7/dist-packages/tensorflow_core/lite/python/convert.py", line 188, 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.
2019-07-18 14:50:52.037299: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.037338: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.037351: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.037359: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.037402: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayV3
2019-07-18 14:50:52.037412: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 20
2019-07-18 14:50:52.037419: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayV3
2019-07-18 14:50:52.037425: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 20
2019-07-18 14:50:52.037432: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayV3
2019-07-18 14:50:52.037437: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 20
2019-07-18 14:50:52.037443: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.037451: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.037457: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 20
2019-07-18 14:50:52.037462: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.037468: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.037473: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 20
2019-07-18 14:50:52.037478: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.037484: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.037489: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 20
2019-07-18 14:50:52.037496: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayScatterV3
2019-07-18 14:50:52.037507: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.037513: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: LoopCond
2019-07-18 14:50:52.037528: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Exit
2019-07-18 14:50:52.037536: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Exit
2019-07-18 14:50:52.037553: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayReadV3
2019-07-18 14:50:52.037560: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArraySizeV3
2019-07-18 14:50:52.037566: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArraySizeV3
2019-07-18 14:50:52.037573: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayWriteV3
2019-07-18 14:50:52.037592: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayGatherV3
2019-07-18 14:50:52.037600: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayGatherV3
2019-07-18 14:50:52.037612: I tensorflow/lite/toco:/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayWriteV3
2019-07-18 14:50:52.038263: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayV3
2019-07-18 14:50:52.038274: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 20
2019-07-18 14:50:52.038282: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayV3
2019-07-18 14:50:52.038288: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 20
2019-07-18 14:50:52.038294: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayV3
2019-07-18 14:50:52.038300: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 20
2019-07-18 14:50:52.038306: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayV3
2019-07-18 14:50:52.038311: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 20
2019-07-18 14:50:52.038317: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayV3
2019-07-18 14:50:52.038323: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 20
2019-07-18 14:50:52.038329: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayV3
2019-07-18 14:50:52.038335: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 20
2019-07-18 14:50:52.038341: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayV3
2019-07-18 14:50:52.038346: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 20
2019-07-18 14:50:52.038352: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayV3
2019-07-18 14:50:52.038358: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 20
2019-07-18 14:50:52.038364: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.038374: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.038379: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 20
2019-07-18 14:50:52.038385: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayScatterV3
2019-07-18 14:50:52.038392: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.038397: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 20
2019-07-18 14:50:52.038403: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayScatterV3
2019-07-18 14:50:52.038409: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.038431: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 20
2019-07-18 14:50:52.038437: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.038442: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 20:
2019-07-18 14:50:52.038448: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.038455: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.038460: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 20
2019-07-18 14:50:52.038466: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.038473: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.038478: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 20
2019-07-18 14:50:52.038484: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.038491: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.038496: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 20
2019-07-18 14:50:52.038502: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.038509: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.038514: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 20
2019-07-18 14:50:52.038522: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayScatterV3
2019-07-18 14:50:52.038544: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.038551: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.038564: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.038572: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: LoopCond
2019-07-18 14:50:52.038594: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Exit
2019-07-18 14:50:52.038797: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayReadV3
2019-07-18 14:50:52.038806: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayReadV3
2019-07-18 14:50:52.038813: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayReadV3
2019-07-18 14:50:52.038819: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArraySizeV3
2019-07-18 14:50:52.038826: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayScatterV3
2019-07-18 14:50:52.038851: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Enter
2019-07-18 14:50:52.038860: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayGatherV3
2019-07-18 14:50:52.038868: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayReadV3
2019-07-18 14:50:52.038901: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: NonMaxSuppressionV3
2019-07-18 14:50:52.038918: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Size
2019-07-18 14:50:52.039017: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayWriteV3
2019-07-18 14:50:52.039091: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayWriteV3
2019-07-18 14:50:52.039107: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayWriteV3
2019-07-18 14:50:52.039114: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: TensorArrayWriteV3
2019-07-18 14:50:52.039127: F tensorflow/lite/toco/tooling_util.cc:1462] Check failed: batch == 1 (2 vs. 1)
Fatal Python error: Aborted

Current thread 0x00007fefa7cb0700 (most recent call first):
File "/usr/local/lib/python3.5/dist-packages/tensorflow_core/lite/toco/python/toco_from_protos.py", line 52 in execute
File "/home/nxgdl/.local/lib/python3.5/site-packages/absl/app.py", line 251 in _run_main
File "/home/nxgdl/.local/lib/python3.5/site-packages/absl/app.py", line 300 in run
File "/usr/local/lib/python3.5/dist-packages/tensorflow_core/python/platform/app.py", line 40 in run
File "/usr/local/lib/python3.5/dist-packages/tensorflow_core/lite/toco/python/toco_from_protos.py", line 89 in main
File "/usr/local/bin/toco_from_protos", line 11 in
Aborted (core dumped)
`

@srishtigoelroposo
Copy link

srishtigoelroposo commented Aug 22, 2019

Hi even i am stuck with the same problem. Were you able to find any solution?

I use the following command:

toco --output_file=trained_model.tflite --graph_def_file=./hand_inference_graph/frozen_inference_graph.pb --input_format=TENSORFLOW_GRAPHDEF --input_arrays=image_tensor --output_arrays=num_detections --input_shapes=1,224,224,3

Error:
2019-08-22 16:03:51.049737: F tensorflow/contrib/lite/toco/graph_transformations/resolve_constant_slice.cc:59] Check failed: dim_size >= 1 (0 vs. 1)

None

@MHX792
Copy link

MHX792 commented Feb 29, 2020

@Suraj520 @srishtigoelroposo I am facing the same problem. Did you guys have any luck?

@samsgates
Copy link

same issue..! any alternative solution ?

@tgforever97
Copy link

sad! same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants