【问题标题】:Is it possible to apply GradCam to a TF Lite model是否可以将 GradCam 应用于 TF Lite 模型
【发布时间】:2021-07-19 22:21:59
【问题描述】:

我一直在研究 GradCam,我注意到大多数案例都用于 Keras/Tensorflow 模型。但是,我有一个已编译为 .tflite 格式的 tensorflow lite 模型。我不确定在编译后是否可以访问我的 CNN 层,因为我尝试使用 keras 库加载模型并且它只接受特定的文件类型,而不是 .tflite,因为它会引发错误:

from tensorflow.keras.models import load_model
model = load_model("/content/drive/My Drive/tensorflow_lite_model.tflite")

它给出了错误:

OSError: SavedModel file does not exist

我试图做的是使用 model.summary 打印 .tflite 模型,以确认我是否可以对模型层执行任何操作。如果是这样,那么我认为不可能将 Grad-Cam 与 tensorflow lite 模型一起使用。

因此,我想知道这是真的,还是我只是尝试验证它,错误的方式?

【问题讨论】:

    标签: python python-3.x tensorflow machine-learning tensorflow-lite


    【解决方案1】:

    TFLite 模型文件是与 TensorFlow 模型格式、keras 和保存模型不同的序列化格式。

    由于您已经有了 TFLite 模型,因此您需要使用 TensorFlow Lite Interpreter API,而不是使用 TensorFlow API。

    interpreter = tf.lite.Interpreter(model_path="converted_model.tflite")
    interpreter.allocate_tensors()
    

    详情请参考link

    TF GradCam 模型可以转换为 TFLite 模型。在技​​术上可以将任何 TF 模型转换为相应的 TFLite 模型。如果您对转换有任何问题,请在 tensorflow github 提交错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-16
      • 2019-10-16
      • 2017-11-30
      • 2021-06-14
      • 2022-10-07
      • 2010-12-27
      • 2021-12-20
      • 2018-02-06
      相关资源
      最近更新 更多