android - 它需要指定 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。那么,如何解决这个问题呢?有什么建议吗?
解决方案
这是 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)。
最好的,
推荐阅读
- r - tree.cv 回归的变量重要性图
- python - 如何在python中打印变量“new_text”
- apache2 - WSL2 Apache2 反向代理仅排除子域的根
- python - 不存在频率中的 SciPy 离散余弦变换 (DCT) 功率
- java - 与在 iframe 页面中嵌入 pdf 的兼容性
- android - 如何避免在 Compose 中硬编码“Log”标签
- bash - 读取 txt 文件在 bash 脚本中返回字符串而不是 int。算术运算符无效
- html - 实现 CSS:导航栏由于侧导航而崩溃 - 如何防止?
- r - 如果 df 不为空,则 dplyr 负选择
- javascript - Javascript RegExp 验证字符串是否以 html 开放标签 + 除标签外的任何内容结束