I want to convert an .onnx file to tflite file but it is giving me this error .
AttributeError: module 'tensorflow.python.framework.type_spec' has no attribute '_NAME_TO_TYPE_SPEC'
here is my code:
import os
import onnx
from onnx_tf.backend import prepare
# Define input and output paths
input_path = "model.onnx"
output_path = "output_model"
try:
# Check if input file exists
if not os.path.exists(input_path):
raise FileNotFoundError(f"ONNX model not found at: {input_path}")
# Load the ONNX model
onnx_model = onnx.load(input_path)
tf_rep = prepare(onnx_model)
tf_rep.export_graph(output_path)
print("Conversion completed successfully!")
except Exception as e:
print(f"Error during conversion: {e}")
raise