PINTO0309 / PINTO_model_zoo

A repository for storing models that have been inter-converted between various frameworks. Supported frameworks are TensorFlow, PyTorch, ONNX, OpenVINO, TFJS, TFTRT, TensorFlowLite (Float32/16/INT8), EdgeTPU, CoreML.
https://qiita.com/PINTO
MIT License
3.5k stars 566 forks source link

Will you provide the int8 version of new hand track models ? #310

Closed Stephenfang51 closed 1 year ago

Stephenfang51 commented 1 year ago

Issue Type

Feature Request

OS

Ubuntu

OS architecture

aarch64

Programming Language

Python

Framework

TensorFlowLite

Model name and Weights/Checkpoints URL

NO

Description

Hi I wonder if you will provide the integer version for new mediapipe palm detection and hand landmark models since your link is for previous version.

I try using tflite2tensorflow to quantize the models myself but got error like below

user@9fa01df81f96:~/workdir$ tflite2tensorflow --model_path palm_detection_lite.tflite --flatc_path ../flatc --schema_path ../schema.fbs --output_integer_quant_tflite --load_dest_file_path_for_the_calib_npy sample_npy/calibration.npy 
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': 239,
 'name': 'Identity',
 'quantization': (0.0, 0),
 'quantization_parameters': {'quantized_dimension': 0,
                             'scales': array([], dtype=float32),
                             'zero_points': array([], dtype=int32)},
 'shape': array([   1, 2016,   18], dtype=int32),
 'shape_signature': array([   1, 2016,   18], dtype=int32),
 'sparsity_parameters': {}}
{'dtype': <class 'numpy.float32'>,
 'index': 236,
 'name': 'Identity_1',
 'quantization': (0.0, 0),
 'quantization_parameters': {'quantized_dimension': 0,
                             'scales': array([], dtype=float32),
                             'zero_points': array([], dtype=int32)},
 'shape': array([   1, 2016,    1], dtype=int32),
 'shape_signature': array([   1, 2016,    1], dtype=int32),
 'sparsity_parameters': {}}
numpy dataset load started ==========================================================
numpy dataset load complete!
Integer Quantization started ========================================================
Estimated count of arithmetic ops: 573.845 M  ops, equivalently 286.922 M  MACs
ERROR: a bytes-like object is required, not 'NoneType'
Traceback (most recent call last):
  File "/usr/local/bin/tflite2tensorflow", line 6211, in main
    w.write(tflite_model)
TypeError: a bytes-like object is required, not 'NoneType'

Relevant Log Output

No response

URL or source code for simple inference testing code

No response

PINTO0309 commented 1 year ago

Please read the README seriously.

tflite2tensorflow \
--model_path palm_detection_lite.tflite \
--flatc_path ../flatc \
--schema_path ../schema.fbs \
--output_pb

tflite2tensorflow \
--model_path palm_detection_lite.tflite \
--flatc_path ../flatc \
--schema_path ../schema.fbs \
--output_dynamic_range_quant_tflite \
--output_integer_quant_tflite \
--string_formulas_for_normalization 'data / 255.0'
Stephenfang51 commented 1 year ago

@PINTO0309 Thanks for the reply, I follow the second one and it stuck at

numpy dataset load started ==============

I guess the internet connection bad for docker

so I create a npy and its shape be line (498, 192, 192 ,3) now the calibration dataset load sucessfully but still got the error

floating point exception (core dumped)

here's my full command line

--model_path palm_detection_lite.tflite \
--flatc_path ../flatc \
--schema_path ../schema.fbs \
--output_dynamic_range_quant_tflite 
--output_full_integer_quant_tflite
--load_dest_file_path_for_the_calib_npy sample_npy/calibration.npy
--string_formulas_for_normalization 'data' //I did nothing with the dataset

Any suggestion ? Thanks in advanced ! PS. my npy dataset always done normalizations ( divided by 255) and padd the image with zero value to be send to palm detection