问题
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
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();
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.
回答1:
As mentioned in the documentation of Firebase : https://firebase.google.com/docs/reference/android/com/google/firebase/ml/custom/FirebaseModelDataType
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();
来源:https://stackoverflow.com/questions/56214555/android-mlkit-internal-error-has-occurred-when-executing-firebase-ml-tasks