【发布时间】:2021-02-27 20:31:07
【问题描述】:
大家好,关注的人!)。我是机器学习的新手,遇到了一个问题。我有一个预训练的图像分类器神经网络转换为 tflite,我想在 android studio 中使用它。我的输入是来自相机照片的位图。我使用了本指南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 enter image description here 但是作为回应,我打印了概率结果并得到了一个完全错误的概率,这是我在转换之前没有在预测试中得到的。每次输入相同的图像时,它也会给出相同的概率。例如,我们输入白色图片,并且对于这个图片的概率在我们输入它的任何时候都是相同的,kile const。
我的概率是错误的,因为我使用的模型不正确? 如果我没有正确使用模型,为什么我得到概率,并且对同一张图片得到相同的概率? 如何解决这个问题
【问题讨论】:
标签: java android-studio tensorflow tensorflow-lite image-classification