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
266 stars 41 forks source link

OSError: SavedModel file does not exist at: saved_model/{saved_model.pbtxt|saved_model.pb} #34

Closed hewumars closed 2 years ago

hewumars commented 2 years ago

Issue Type

Bug

OS

Ubuntu

OS architecture

x86_64

Programming Language

Python

Framework

TensorFlowLite

Download URL for tflite file

https://github.com/google/mediapipe/blob/0.8.0/mediapipe/modules/face_landmark/face_landmark.tflite

https://github.com/google/mediapipe/blob/0.8.0/mediapipe/modules/face_detection/face_detection_front.tflite

https://github.com/google/mediapipe/blob/0.8.0/mediapipe/modules/hand_landmark/hand_landmark.tflite

Convert Script

~/workdir $ tflite2tensorflow --model_path face_landmark.tflite --flatc_path ../flatc --schema_path ../schema.fbs --output_no_quant_float32_tflite

Description

docker pull ghcr.io/pinto0309/tflite2tensorflow:latest

docker run -it --rm \ -v pwd:/home/user/workdir \ ghcr.io/pinto0309/tflite2tensorflow:latest

Relevant Log Output

user@4cd1e8cc1577:~/workdir$ tflite2tensorflow --model_path tflite2tensorflow/resources/face_landmark_with_attention.tflite --flatc_path ../flatc --schema_path ../schema.fbs --output_no_quant_float32_tflite 
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
inputs:
{'dtype': <class 'numpy.float32'>,
 'index': 0,
 'name': 'input_1',
 'quantization': (0.0, 0),
 'quantization_parameters': {'quantized_dimension': 0,
                             'scales': array([], dtype=float32),
                             'zero_points': array([], dtype=int32)},
 'shape': array([  1, 192, 192,   3], dtype=int32),
 'shape_signature': array([  1, 192, 192,   3], dtype=int32),
 'sparsity_parameters': {}}
outputs:
{'dtype': <class 'numpy.float32'>,
 'index': 719,
 'name': 'output_mesh_identity',
 'quantization': (0.0, 0),
 'quantization_parameters': {'quantized_dimension': 0,
                             'scales': array([], dtype=float32),
                             'zero_points': array([], dtype=int32)},
 'shape': array([   1,    1,    1, 1404], dtype=int32),
 'shape_signature': array([   1,    1,    1, 1404], dtype=int32),
 'sparsity_parameters': {}}
{'dtype': <class 'numpy.float32'>,
 'index': 720,
 'name': 'output_lips',
 'quantization': (0.0, 0),
 'quantization_parameters': {'quantized_dimension': 0,
                             'scales': array([], dtype=float32),
                             'zero_points': array([], dtype=int32)},
 'shape': array([  1,   1,   1, 160], dtype=int32),
 'shape_signature': array([  1,   1,   1, 160], dtype=int32),
 'sparsity_parameters': {}}
{'dtype': <class 'numpy.float32'>,
 'index': 721,
 'name': 'output_left_eye',
 'quantization': (0.0, 0),
 'quantization_parameters': {'quantized_dimension': 0,
                             'scales': array([], dtype=float32),
                             'zero_points': array([], dtype=int32)},
 'shape': array([  1,   1,   1, 142], dtype=int32),
 'shape_signature': array([  1,   1,   1, 142], dtype=int32),
 'sparsity_parameters': {}}
{'dtype': <class 'numpy.float32'>,
 'index': 723,
 'name': 'output_right_eye',
 'quantization': (0.0, 0),
 'quantization_parameters': {'quantized_dimension': 0,
                             'scales': array([], dtype=float32),
                             'zero_points': array([], dtype=int32)},
 'shape': array([  1,   1,   1, 142], dtype=int32),
 'shape_signature': array([  1,   1,   1, 142], dtype=int32),
 'sparsity_parameters': {}}
{'dtype': <class 'numpy.float32'>,
 'index': 722,
 'name': 'output_left_iris',
 'quantization': (0.0, 0),
 'quantization_parameters': {'quantized_dimension': 0,
                             'scales': array([], dtype=float32),
                             'zero_points': array([], dtype=int32)},
 'shape': array([ 1,  1,  1, 10], dtype=int32),
 'shape_signature': array([ 1,  1,  1, 10], dtype=int32),
 'sparsity_parameters': {}}
{'dtype': <class 'numpy.float32'>,
 'index': 724,
 'name': 'output_right_iris',
 'quantization': (0.0, 0),
 'quantization_parameters': {'quantized_dimension': 0,
                             'scales': array([], dtype=float32),
                             'zero_points': array([], dtype=int32)},
 'shape': array([ 1,  1,  1, 10], dtype=int32),
 'shape_signature': array([ 1,  1,  1, 10], dtype=int32),
 'sparsity_parameters': {}}
{'dtype': <class 'numpy.float32'>,
 'index': 710,
 'name': 'conv_faceflag',
 'quantization': (0.0, 0),
 'quantization_parameters': {'quantized_dimension': 0,
                             'scales': array([], dtype=float32),
                             'zero_points': array([], dtype=int32)},
 'shape': array([1, 1, 1, 1], dtype=int32),
 'shape_signature': array([1, 1, 1, 1], dtype=int32),
 'sparsity_parameters': {}}
tflite Float32 convertion started ===================================================
ERROR: SavedModel file does not exist at: saved_model/{saved_model.pbtxt|saved_model.pb}
Traceback (most recent call last):
  File "/usr/local/bin/tflite2tensorflow", line 6046, in main
    converter = tf.lite.TFLiteConverter.from_saved_model(model_output_path)
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/lite/python/lite.py", line 1786, in from_saved_model
    saved_model = _load(saved_model_dir, tags)
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/python/saved_model/load.py", line 782, in load
    result = load_partial(export_dir, None, tags, options)["root"]
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/python/saved_model/load.py", line 887, in load_partial
    loader_impl.parse_saved_model_with_debug_info(export_dir))
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/python/saved_model/loader_impl.py", line 57, in parse_saved_model_with_debug_info
    saved_model = parse_saved_model(export_dir)
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/python/saved_model/loader_impl.py", line 115, in parse_saved_model
    raise IOError(
OSError: SavedModel file does not exist at: saved_model/{saved_model.pbtxt|saved_model.pb}

Source code for simple inference testing code

No response

PINTO0309 commented 2 years ago