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

The shape of the output layer is different from the result of the tensorflow2onnx transformation. #25

Closed ichigosyakure closed 2 years ago

ichigosyakure commented 2 years ago

Issue Type

Bug

OS

Ubuntu

OS architecture

x86_64

Programming Language

Python

Framework

ONNX

Download URL for tflite file

VertexAI Auto ML classification TFlite Format model

Convert Script

●tflite2tensorflow

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

tflite2tensorflow \ --model_path model.tflite \ --flatc_path ../flatc \ --schema_path ../schema.fbs \ --output_pb \ --optimizing_for_openvino_and_myriad \ --rigorous_optimization_for_myriad

tflite2tensorflow \ --model_path model.tflite \ --flatc_path ../flatc \ --schema_path ../schema.fbs \ --output_onnx \ --onnx_opset 13 \ --output_openvino_and_myriad

●tensorflow2onnx pip install git+https://github.com/onnx/tensorflow-onnx

python -m tf2onnx.convert --opset 13 --tflite model.tflite --output model.onnx --dequantize

Description

I'm trying to convert the attached file from tflite to onnx. (Eventually I want to run it in myriad). In the conversion source tflite, the input to sortmax is [1×8], but in tflite2tensorflow, it is [7×7×8]. If you try tensorflow2tflite, the input to sortmax becomes [1×8] as in tflite. I think [1×8] is correct because it is an 8-class classification model.

[tflite] tflite_netron

[tflite2tensorflow(savedmodel and onnx)] tflite2tensorflow_onnx

[tensorflow2onnx] tensorflow2onnx_onnx

Relevant Log Output

None.

Source code for simple inference testing code

No response

PINTO0309 commented 2 years ago

Please attach the tflite. I know that the structure of the tflite model generated by Auto ML is special.

ichigosyakure commented 2 years ago

Sorry. I forgot to attach the file. I will attach it later.

ichigosyakure commented 2 years ago

file.zip Sorry. I've re-uploaded it.

PINTO0309 commented 2 years ago

commit: 18b3e8880ddf3be5a9e9b70e3fe581bc981ab7a6

PINTO0309 commented 2 years ago

image

PINTO0309 commented 2 years ago

Release: https://github.com/PINTO0309/tflite2tensorflow/releases/tag/v1.18.1

PINTO0309 commented 2 years ago

Please upgrade the package to v1.18.1 and try again.

ichigosyakure commented 2 years ago

I've confirmed the fix. Thank you.