当我在Android中使用tensorflow-lite时,更改正式支持的模型后,发生了错误
我模型的输入有两个输入,分别是32 * 128 * 128 * 1,我模仿了输入的方式,但是失败了
这是我项目中的一些代码
@Override
protected void processImage() {
try {
float[][][][] stft=readTxt("file:///android_asset/stft.txt");
float[][][][] mfcc=readTxt("file:///android_asset/mfcc.txt");
final List<Classifier.Recognition> results = detector.recognizeImage(stft, mfcc);
}
catch(Exception e)
{
e.printStackTrace();
System.out.print("can't get Bitmap");
}
}
@Override
public List<Recognition> recognizeImage(final float[][][][] stft,final float[][][][] mfcc) {
// Log this method so that it can be analyzed with systrace.
Trace.beginSection("recognizeImage");
Trace.beginSection("preprocessBitmap");
// Preprocess the image data from 0-255 int to normalized float based
// on the provided parameters.
LOGGER.i("begin run model");
Trace.endSection(); // preprocessBitmap
// Copy the input data into TensorFlow.
Trace.beginSection("feed");
imgDatam.rewind();
imgDatas.rewind();
for(int i=0; i<32; i++){
for(int j=0;j<128;j++){
for(int k =0;k<128;k++){
imgDatam.putFloat(mfcc[i][j][k][0]);
imgDatas.putFloat(stft[i][j][k][0]);
}
}
}
outputClasses = new float[32][NUM_DETECTIONS];
Object[] inputArray = {imgDatas,imgDatam};
Map<Integer, Object> outputMap = new HashMap<>();
outputMap.put(0, outputClasses);
Trace.endSection();
// Run the inference call.
Trace.beginSection("run");
try{
tfLite.runForMultipleInputsOutputs(inputArray, outputMap);
}
catch(Exception e)
{
e.printStackTrace();
}
LOGGER.i("finished");
Trace.endSection();
// Show the best detections.
// after scaling them back to the input size.
final ArrayList<Recognition> recognitions = new ArrayList<>(NUM_DETECTIONS);
Trace.endSection(); // "recognizeImage"
return recognitions;
}
错误显示:
org.tensorflow.lite.examples.detection A / libc:致命信号6(SIGABRT),代码-6(SI_TKILL)在tid 23610(mpls.detection),pid 23610(mples.detection)中 ? A / DEBUG:pid:23610,tid:23610,名称:mples.detection >>> org.tensorflow.lite.examples.detection <<< ? A /调试:#01 pc 00000000001220b4 /data/app/org.tensorflow.lite.examples.detection-kKVx47dAvHYDUZmU-_Wkag==/lib/arm64/libtensorflowlite_jni.so ? A /调试:#02 pc 00000000001216e4 /data/app/org.tensorflow.lite.examples.detection-kKVx47dAvHYDUZmU-_Wkag==/lib/arm64/libtensorflowlite_jni.so ? A /调试:#03 pc 00000000001624ac /data/app/org.tensorflow.lite.examples.detection-kKVx47dAvHYDUZmU-_Wkag==/lib/arm64/libtensorflowlite_jni.so ? A /调试:#04 pc 0000000000165974 /data/app/org.tensorflow.lite.examples.detection-kKVx47dAvHYDUZmU-_Wkag==/lib/arm64/libtensorflowlite_jni.so ? A /调试:#05 pc 000000000000ed10 /data/app/org.tensorflow.lite.examples.detection-kKVx47dAvHYDUZmU-_Wkag==/lib/arm64/libtensorflowlite_jni.so(Java_org_tensorflow_lite_NativeInterpreterWrapper_run + 32) ? A /调试:#13 pc 00000000001770ee /dev/ashmem/dalvik-classes.dex从/data/app/org.tensorflow.lite.examples.detection-kKVx47dAvHYDUZmU-_Wkag == / split_lib_dependencies_apk.apk(已删除)在内存中提取org.tensorflow.lite.NativeInterpreterWrapper.run + 158) ? A /调试:#19 pc 00000000001768f6 /dev/ashmem/dalvik-classes.dex从/data/app/org.tensorflow.lite.examples.detection-kKVx47dAvHYDUZmU-_Wkag == / split_lib_dependencies_apk.apk(已删除)在内存中提取org.tensorflow.lite.Interpreter.runForMultipleInputsOutputs + 10) ? A /调试:#23 pc 0000000000007234 / dev / ashmem / dalvik-jit-code-cache(已删除)(org.tensorflow.lite.examples.detection.tflite.TFLiteObjectDetectionAPIModel.recognizeImage + 1428) ? A /调试:#28 pc 000000000000200e /dev/ashmem/dalvik-classes.dex从/data/app/org.tensorflow.lite.examples.detection-kKVx47dAvHYDUZmU-_Wkag == / split_lib_slice_4_apk.apk(已删除)在内存中提取org.tensorflow.lite.examples.detection.tflite.TFLiteObjectDetectionAPIModel.recognizeImage + 206) ? A /调试:#34 pc 000000000001d408 /dev/ashmem/dalvik-classes.dex从/data/app/org.tensorflow.lite.examples.detection-kKVx47dAvHYDUZmU-_Wkag == / split_lib_slice_7_apk.apk(已删除)在内存中提取org.tensorflow.lite.examples.detection.DetectorActivity.processImage + 60) ? A /调试:#40 pc 0000000000015c6a /dev/ashmem/dalvik-classes.dex从/data/app/org.tensorflow.lite.examples.detection-kKVx47dAvHYDUZmU-_Wkag == / split_lib_slice_7_apk.apk(已删除)在内存中提取org.tensorflow.lite.examples.detection.CameraActivity.onCreate + 174) ? E / adbd:无法连接至套接字'localabstract:org.tensorflow.lite.examples.detection':连接被拒绝
无论如何,谢谢您的帮助,我知道这可能很难,因为我什至找不到关于tensorflow lite的指南