Я создал файл .tflite из MLKit и использовал его в приложении tenor, но приложение вылетает с ошибкой:
java.lang.IllegalArgumentException: Cannot convert between a TensorFlowLite buffer with 150528 bytes and a ByteBuffer with 786432 bytes.
at org.tensorflow.lite.Tensor.throwIfShapeIsIncompatible(Tensor.java:281)
at org.tensorflow.lite.Tensor.throwIfDataIsIncompatible(Tensor.java:258)
at org.tensorflow.lite.Tensor.setTo(Tensor.java:119)
at org.tensorflow.lite.NativeInterpreterWrapper.run(NativeInterpreterWrapper.java:167)
at org.tensorflow.lite.Interpreter.runForMultipleInputsOutputs(Interpreter.java:275)
at org.tensorflow.lite.examples.detection.tflite.TFLiteObjectDetectionAPIModel.recognizeImage(TFLiteObjectDetectionAPIModel.java:193)
at org.tensorflow.lite.examples.detection.DetectorActivity$2.run(DetectorActivity.java:181)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.os.HandlerThread.run(HandlerThread.java:65)
Ниже приведен код приложения tenorFlow.
if (isQuantized) {
numBytesPerChannel = 1; // Quantized
} else {
numBytesPerChannel = 4; // Floating point
}
d.imgData = ByteBuffer.allocateDirect(1 * d.inputSize * d.inputSize * 3 * numBytesPerChannel);
d.imgData.order(ByteOrder.nativeOrder());