简体   繁体   English

使用用于 object 检测的元数据创建 tflite model

[英]create tflite model with metadata for object detection

pip install tflite_support_nightly

from tflite_support.metadata_writers import object_detector
from tflite_support.metadata_writers import writer_utils
from tflite_support import metadata

ObjectDetectorWriter = object_detector.MetadataWriter
_MODEL_PATH = "mypath.tflite"
_LABEL_FILE = "labelmap.txt"
_SAVE_TO_PATH = "mypath_metadata.tflite"

writer = ObjectDetectorWriter.create_for_inference(
    writer_utils.load_file(_MODEL_PATH), [127.5], [127.5], [_LABEL_FILE])
writer_utils.save_file(writer.populate(), _SAVE_TO_PATH)

# Verify the populated metadata and associated files.
displayer = metadata.MetadataDisplayer.with_model_file(_SAVE_TO_PATH)
print("Metadata populated:")
print(displayer.get_metadata_json())
print("Associated file(s) populated:")
print(displayer.get_packed_associated_file_list())

I tried to create tflite model with metadat using this code.我尝试使用此代码使用元数据创建 tflite model。 But I got this error但我得到了这个错误

The number of output tensors (1) should match the number of output tensor metadata (4)

How can I solve this problem??我怎么解决这个问题??

Basically, the object detector API requires the following requirements:基本上,object检测器API需要以下要求:

(1) There should be only one input tensor for representing an uncompressed image. (1) 应该只有一个输入张量来表示未压缩的图像。

(2) There should be four output tensors for locations, classes, scores, and number of detection. (2)位置、类别、分数、检测次数应该有四个output张量。

The above requirements actually reflect the object detection tasks.上述要求实际上反映了object检测任务。 See more the details at the link .链接中查看更多详细信息。

If you have a difficulty on crafting the model, that is qualified to the above requirements, I would suggest using the pretrained models from TF hub or AutoML Vision Edge object detection solution .如果您在制作符合上述要求的 model 时遇到困难,我建议您使用来自 TF hub 或AutoML Vision Edge object 检测解决方案预训练模型

See more the details at the guide page as well.也可以在指南页面上查看更多详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 创建填充有元数据的 Tflite 模型时出现问题(用于对象检测) - Issue in creating Tflite model populated with metadata (for object detection) 无法使用 tflite object 检测 model 推断结果 - Unable to infer results using tflite object detection model 创建自定义检测 model - 图像 Object 检测 - Create custom detection model - Image Object Detection 如何从 tflite model 中提取元数据 - How to extract metadata from tflite model 如何将对象检测模型(在其冻结图形中)转换为.tflite,而不需要任何输入和输出数组的知识 - How to convert an object detection model, in it's frozen graph, to a .tflite, without any knowledge of input and output arrays 将 SSD object 检测 model 转换为 TFLite 并将其从 float 量化为 uint8 用于 EdgeTPU - Converting SSD object detection model to TFLite and quantize it from float to uint8 for EdgeTPU Tensorflow对象检测-将.pb文件转换为tflite - Tensorflow Object Detection - Convert .pb file to tflite tflite object 检测中的 Raspberry Pi GPIO 引脚问题 - Raspberry Pi GPIO pin issue in tflite object detection 如何从 TFLite Object Detection Python 中获取有用的数据 - How to get useful data from TFLite Object Detection Python 使用 opencv 检测 object 后保存元数据 - Saving Metadata after object detection with opencv
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM