我正在用 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'
。
如何提取?
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句