PINTO0309 / tflite2tensorflow

Generate saved_model, tfjs, tf-trt, EdgeTPU, CoreML, quantized tflite, ONNX, OpenVINO, Myriad Inference Engine blob and .pb from .tflite. Support for building environments with Docker. It is possible to directly access the host PC GUI and the camera to verify the operation. NVIDIA GPU (dGPU) support. Intel iHD GPU (iGPU) support. Supports inverse quantization of INT8 quantization model.
https://qiita.com/PINTO
MIT License
258 stars 38 forks source link

Convert palm_detection_lite.tflite : ValueError: Tensor data is null. Run allocate_tensors() first #19

Closed geaxgx closed 2 years ago

geaxgx commented 2 years ago

Issue Type

Bug

OS

Ubuntu

OS architecture

x86_64

Programming Language

Python

Framework

OpenVINO

Download URL for tflite file

https://github.com/google/mediapipe/blob/master/mediapipe/modules/palm_detection/palm_detection_lite.tflite https://github.com/google/mediapipe/blob/master/mediapipe/modules/palm_detection/palm_detection_full.tflite

Description

Hi @PINTO0309 ! I have just noticed that Goggle has updated the palm detection model a few weeks ago (I missed them because does not appear in release notes). Now there are 2 models (lite and full). Naturally I would like to test them :-) So after running docker pull ghcr.io/pinto0309/tflite2tensorflow:latest , when running: tflite2tensorflow --model_path palm_detection_lite.tflite --model_output_path palm_detection_lite --flatc_path ../../flatc --schema_path ../../schema.fbs --output_pb --optimizing_for_openvino_and_myriad --rigorous_optimization_for_myriad I get : ValueError: Tensor data is null. Run allocate_tensors() first

Relevant Log Output

...
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ op: DEQUANTIZE
{'builtin_options_type': 'NONE',
 'custom_options_format': 'FLEXBUFFERS',
 'inputs': [68],
 'opcode_index': 9,
 'outputs': [319]}
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ op: PRELU
{'builtin_options_type': 'NONE',
 'custom_options_format': 'FLEXBUFFERS',
 'inputs': [121, 319],
 'opcode_index': 1,
 'outputs': [122]}
Traceback (most recent call last):
  File "/usr/local/bin/tflite2tensorflow", line 6402, in <module>
    main()
  File "/usr/local/bin/tflite2tensorflow", line 5759, in main
    TFLite_Detection_PostProcess_flg = make_graph(
  File "/usr/local/bin/tflite2tensorflow", line 877, in make_graph
    alpha_array = interpreter.get_tensor(alpha_detail['index'])
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/lite/python/interpreter.py", line 858, in get_tensor
    return self._interpreter.GetTensor(tensor_index)
ValueError: Tensor data is null. Run allocate_tensors() first

Source code for simple inference testing code

No response

PINTO0309 commented 2 years ago

Fixes. PyPI has been updated, but the Docker container will take the remaining 20 minutes to complete the GitHub Action CI. https://github.com/PINTO0309/tflite2tensorflow/releases/tag/v1.16.2

PINTO0309 commented 2 years ago

Commited. :smile: Thank you! https://github.com/PINTO0309/PINTO_model_zoo/tree/main/033_Hand_Detection_and_Tracking/21_new_full_lite

geaxgx commented 2 years ago

Thanks @PINTO0309 ! A quick feedback: the new models work on a 192x192 image vs 128x128 for the older version. They are significantly slower. On MyriadX (depthai):

Difficult to judge accuracy on only one test, but this what I get on this image:

-full: snapshot_full

Strangely, full is worse than lite on this image. I am not sure yet I will update my hand tracker repo with these models (I am a bit disappointed :-).