首页 > 解决方案 > 它需要指定 NormalizationOptions 元数据来预处理输入图像

问题描述

Yolov3-tiny-416.tflite 是 yolov3 tiny 模型的 tflite 模型,由 yolov3-tiny.weights 创建,我曾尝试使用 google 在 android 中提供的 ML kit Vision 模块。在回购:https ://github.com/googlesamples/mlkit/tree/master/android/vision-quickstart

这是我为 yolo v3 tiny tflite 模型加载和选择检测选项的方式。

LocalModel localModel = new LocalModel.Builder()
              .setAssetFilePath("yolov3-tiny-416.tflite")
              .build();
CustomObjectDetectorOptions customObjectDetectorOptions = PreferenceUtils.getCustomObjectDetectorOptionsForLivePreview(this,localModel);
cameraSource.setMachineLearningFrameProcessor(new ObjectDetectorProcessor(this,customObjectDetectorOptions));

现在,我遇到了一个错误,上面写着:

E/MobileVisionBase: Error preloading model resource
b.a.d.a.a: Failed to initialize detector. Input tensor has type kTfLiteFloat32: it requires specifying NormalizationOptions metadata to preprocess input images. 

正如我从错误中知道的那样,我需要指定 NormalizationOptions 元数据来处理 Image。那么,如何解决这个问题呢?有什么建议吗?

标签: androidtensorflowyologoogle-mlkit

解决方案


这是 ML Kit 自定义对象检测和跟踪的自定义模型要求。https://developers.google.com/ml-kit/custom-models 如果您检查页面底部的元数据部分,它有一些关于添加 NormalizationOptions 元数据的说明。

但是,ML Kit 自定义对象检测和跟踪的最基本要求是模型需要是图像分类模型,而 yolov3 则不是。

如果您想使用 ML Kit 对更多对象进行分类,您可以尝试使用 TFHub 上带有 ML Kit 标签的自定义图像分类器模型之一。 https://tfhub.dev/ml-kit/collections/image-classification/1或使用 AutoML 或 TFLite ModelMaker 训练您自己的分类器(请参阅https://developers.google.com/ml-kit/custom-models#automl_vision_edge)。

最好的,


推荐阅读