error --> error picture
When ı try to process my model ı have an error " java.lang.IncompatibleClassChangeError: Found interface org.tensorflow.lite.Tensor, but class was expected"
I have a mobilenet tflite model which is I trained, and I created a function to convert bitmap to bytebuffe and ı try to process my model but ı had this error and ı can't solve it, can you help me to solve this ?
the error is on this line "val outputs = model.process(inputFeature0)"
a part of outputgenerator func code --> you can click and see the line which causes this error
val byteBuffer = convertBitmapToByteBuffer(bitmap)
byteBuffer!!.rewind()
bitmap.copyPixelsToBuffer(byteBuffer)
val inputFeature0 =
TensorBuffer.createFixedSize(intArrayOf(1, 224, 224, 3), DataType.FLOAT32)
inputFeature0.loadBuffer(byteBuffer)
val outputs = model.process(inputFeature0)
val outputFeature0 = outputs.outputFeature0AsTensorBuffer
convertBitmapToByteBuffer function
val byteBuffer =
ByteBuffer.allocateDirect( 4 * 1 * 224 * 224 * 3)
byteBuffer.order(ByteOrder.nativeOrder())
val intValues = IntArray(224 * 224 )
bitmap.getPixels(intValues, 0, bitmap.width, 0, 0, bitmap.width, bitmap.height)
var pixel = 0
for (i in 0 until 224) {
for (j in 0 until 224) {
val `val` = intValues[pixel++]
byteBuffer.putFloat(((`val` shr 16 and 0xFF) - 1) / 255.0f)
byteBuffer.putFloat(((`val` shr 8 and 0xFF) - 1) / 255.0f)
byteBuffer.putFloat(((`val` and 0xFF) - 1) / 255.0f)
}
}
return byteBuffer
}