我有一个TFLite模型。如何获取用于创建模型的TFLite版本?
在自动化过程中,我试图获取TFLite模型并对其运行推理。目前,我使用的是TFLite 2.4.1库。此版本以上创建的模型存在不支持的操作,需要输出错误。
最好的处理方式是什么?如何从模型中获取TFLite版本。
发布于 2021-06-08 14:21:19
TFLite模式文件中的"min_runtime_version“模型元数据包含描述能够运行给定模型的最小运行时版本的信息。
Python模式中的上述值可以被现有的C++和TFLite模式库读取。例如,
from tensorflow.lite.python import schema_py_generated as schema_fb
tflite_model = schema_fb.Model.GetRootAsModel(model_buf, 0)
# Gets metadata from the model file.
for i in range(tflite_model.MetadataLength()):
meta = tflite_model.Metadata(i)
if meta.Name().decode("utf-8") == "min_runtime_version":
buffer_index = meta.Buffer()
metadata = tflite_model.Buffers(buffer_index)
min_runtime_version_bytes = metadata.DataAsNumpy().tobytes()参考文献:
https://stackoverflow.com/questions/67881794
复制相似问题