[Python] ONNX Model conversion to TF then TFLite Error

Discussão em 'Python' iniciado por Stack, Maio 2, 2025.

  1. Stack

    Stack Membro Participativo

    I've been trying to convert this onnx model to Tensorflow so I can convert it into tflite that I will then use in my flutter app

    import onnx

    from onnx_tf.backend import prepare
    import tensorflow

    onnx_model = onnx.load('vit_trashnet.onnx')
    tf_rep = prepare(onnx_model)
    tf_rep.export_graph('vit_trashnet_tf')


    but I keep getting this error

    AttributeError: module 'keras._tf_keras.keras' has no attribute '__internal__'


    not just this error but different errors are appearing depending on the version of the dependency I'm fixing. Is there any workaround this I'm trying to convert it to tflite since the flutter app is much comfortable in tflite models due to the library (at least that's what I know). Also, the size of the model is 340mb+- which is kinda big if ever I will use it directly on my app since I want to try and make the model usable at offline mode or whatever.

    Continue reading...

Compartilhe esta Página