我正在Python中加载此目标检测模型。 我可以使用以下代码行进行加载:
import tflite_runtime.interpreter as tflite
model_path = 'path_to_model_file.tf'
interpreter = tflite.Interpreter(model_path)
我能够对此进行推理而没有任何问题。然而,根据模型文档,标签应该包含在元数据中,但我无法提取出来。
最接近的一次是当我参照这个时:
from tflite_support import metadata as _metadata
displayer = _metadata.MetadataDisplayer.with_model_file(model_path)
export_json_file = "extracted_metadata.json")
json_file = displayer.get_metadata_json()
# Optional: write out the metadata as a json file
with open(export_json_file, "w") as f:
f.write(json_file)
但是第一行代码会出现这个错误:{AtributeError} 'int' object has no attribute 'tobytes'
。
如何提取它?