java - 如何使用 TFlite 安卓工作室
问题描述
大家好,关注的人!)。我是机器学习的新手,遇到了一个问题。我有一个预训练的图像分类器神经网络转换为 tflite,我想在 android studio 中使用它。在我的输入中是来自 Camera Photo 的位图。我使用了本指南https://www.tensorflow.org/lite/guide/android。我这样更改的示例代码
try {
ConvertedModel model = ConvertedModel.newInstance(this);
// Creates inputs for reference.
TensorImage image = TensorImage.fromBitmap(Photo_bitMap);
// Runs model inference and gets result.
ConvertedModel.Outputs outputs = model.process(image);
List<Category> probability = outputs.getProbabilityAsCategoryList();
// Releases model resources if no longer used.
model.close();
//see probability chance
System.out.println(probability);
}
catch (IOException e) {
//catch error
}
ConvertedModel - IDE 自动找到模型并将其放入。它是我的转换模型,位于 ml 在此处输入图像描述 但作为响应,我打印概率结果并得到一个完全错误的概率,这是我在转换之前没有在预测试中得到的。每次输入相同的图像时,它也会给出相同的概率。例如,我们输入白色图片,对于这个图片的概率在我们输入它的任何时候都是相同的,kile const。
我的概率错误,因为我使用的模型不正确?如果我没有正确使用模型,为什么我得到概率,并且对同一张图片得到相同的概率?如何解决这个问题
解决方案
我的代码是正确的,问题出在我的网络上。我用元数据下载了这个网络,一切正常。
推荐阅读
- c# - 如何对从较大的 XDocument 中提取的 XElement 执行 XPath 选择?
- javascript - 当我向选定列中的单元格添加值时,我希望它复制到另一个 Google 表格
- css - 在可变大小的框中调整图像大小并保持纵横比
- python - 交互式绘图 Jupyter Lab 2.0
- android - JSON 格式的 Android Volley 数组
- reactjs - 成帧器运动 | 在最后一个动画加载后视点“useAnimation”触发
- c# - SqlException:INSERT 语句与使用 EF 代码优先 C# 的 FOREIGN KEY 约束冲突
- javascript - 为什么我无法填充帖子字段?
- javascript - 根据当前月份打开特定选项卡
- python - Python:递归获取二维数组的排列