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.43k stars 560 forks source link

Mismatch between BlendshapeV2 TensorFlow and TFLite Model #411

Open electricdr4gon opened 1 month ago

electricdr4gon commented 1 month ago

Issue Type

Bug

OS

Ubuntu

OS architecture

x86_64

Programming Language

Python

Framework

TensorFlow, TensorFlowLite

Model name and Weights/Checkpoints URL

390_BlendshapeV2

Description

TensorFlow Saved Model format version of the BlendshapeV2 model yields significantly different results from the TFLite Version (face_blendshapes.tflite)

Relevant Log Output

No response

URL or source code for simple inference testing code

import tensorflow as tf
import numpy as np

test_data = np.random.rand((1, 146, 2))

model = tf.saved_model.load("BlendshapesV2/saved_model")
model_sd = model.signatures["serving_default"]

interp = tf.lite.Interpreter("BlendshapeV2/face_blendshapes.tflite")
interp.allocate_tensors()
input_tensor = interp.get_input_details()[0]["index"]
output_tensor = interp.get_output_details()[0]["index"]

interp.set_tensor(input_tensor, test_data)
interp.invoke()
out_tflite = interp.get_tensor(output_tensor)

out_tf = model_sd(input_points = test_data)["output"]

# Comparing the "out_tf" and "out_tflite" tensors, it can be observed that results will be off by a significant margin.