Android MLKit-执行Firebase ML任务时发生内部错误 [英] Android MLKit - Internal error has occurred when executing Firebase ML tasks
问题描述
我有一个自定义模型,我在android应用中使用了该模型,但是无论何时尝试运行它,都会抛出MLkitExceptions,该错误的日志输出如下:
Hi I have a custom model that im using in an android app, how ever when i try to run it, an MLkitExceptions is thrown, the log output for said error is the following:
Internal error has occurred when executing Firebase ML tasks
我的应用程序的Java代码如下:
My java code for my app looks like the following:
FirebaseLocalModel localModel = new FirebaseLocalModel.Builder("local_places_recommend")
.setAssetFilePath("recsys.tflite").build();
FirebaseModelManager.getInstance().registerLocalModel(localModel);
FirebaseModelOptions options = new FirebaseModelOptions.Builder()
.setLocalModelName("local_places_recommend")
.build();
FirebaseModelInterpreter firebaseInterpreter = FirebaseModelInterpreter.getInstance(options);
FirebaseModelInputOutputOptions inputOutputOptions =
new FirebaseModelInputOutputOptions.Builder()
.setInputFormat(0, FirebaseModelDataType.FLOAT32, new int[]{1, 3})
.setOutputFormat(0, FirebaseModelDataType.FLOAT32, new int[]{1, 1, 34})
.build();
float[][] input = new float[1][3];
input[0][0] = d1;
input[0][1] = d2;
input[0][2] = d3;
FirebaseModelInputs inputs = new FirebaseModelInputs.Builder()
.add(input)
.build();
每当我尝试运行FirebaseModelInterpreter时,我都会收到该错误,而没有其他内容.
whenever i try to run the FirebaseModelInterpreter I get that error and nothing else.
输入张量和输出张量的形状分别为:
The shape of the input tensor and output tensor are the following respectively:
[1 3]
<class 'numpy.float32'>
[ 1 1 34]
<class 'numpy.int64'>
对于此问题的任何帮助或见解,我们将不胜感激.
Any help or insight about this issue would be gladly appreciated.
推荐答案
如Firebase文档中所述: https://firebase.google.com/docs/reference/android/com/google/firebase/ml/custom/FirebaseModelDataType
As mentioned in the documentation of Firebase : https://firebase.google.com/docs/reference/android/com/google/firebase/ml/custom/FirebaseModelDataType
没有类型INT64,请尝试编写INT32而不是FLOAT32.
There is no type INT64, please try to write INT32 instead of FLOAT32.
FirebaseModelInputOutputOptions inputOutputOptions =
new FirebaseModelInputOutputOptions.Builder()
.setInputFormat(0, FirebaseModelDataType.FLOAT32, new int[]{1, 3})
.setOutputFormat(0, FirebaseModelDataType.FLOAT32, new int[]{1, 1, 34})// try to change FLOAT32 to Int32
.build();
这篇关于Android MLKit-执行Firebase ML任务时发生内部错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!