0
I am working on an Android app that performs classification using a trained TensorFlow Lite model. The model has been loaded using the getModelByteBuffer function, and the input features are being classified using the loaded model. However, when I try to initialize the TensorFlow Lite interpreter using the loaded model, the app crashes. The app crashes with no specific error message when this code is executed. I have tried looking for solutions online, but I haven’t been able to find any that work.
Can anyone help me identify the cause of the app crash and suggest a possible solution?it for a uni project i would be extermely gratful if any of you would help me Thank you.
the log that i wrote after initializing the interpreter is not displaying so i think the problem is around there Here is the relevant code snippet:
private fun classification(uid: String) {
val password = findViewById<EditText>(R.id.passET)
val mdw = moyenne(dwelltime)
val mft2= moyenne(flight_time2)
val mft3= moyenne(flight_time3)
val Moyenne = arrayListOf(mdw,mft2,mft3)
Log.d("tflite", "interpreter before initilizing ")
tflite = Interpreter(getModelByteBuffer())
Log.d("tflite", "interpreter afterinitilizing ")
try {
val input = getInputTensor(Moyenne)
val output = Array(1) { LongArray(NUM_CLASSES) }
tflite?.run(input, output)
// Get predicted class index
val predictedClassIndex = output[0].indices.maxByOrNull { output[0][it] } ?: -1
val predictedClassName = getClassNames()[predictedClassIndex]
store.collection("users").document(uid).get().addOnSuccessListener {user->
val nom = user.getString("nom")
if (predictedClassName == nom){
startActivity(Intent(this, Activity_expert::class.java))
}else{
password.error = "Try Again"
password.text = null
tentative++
onResume()
if (tentative==3){
store.collection("users").document(uid).update("blacklist",true)
warning.blacklist(uid)
val builder = AlertDialog.Builder(this)
builder.setMessage("you are blocked !!!")
builder.setNeutralButton("ok",{ dialogInterface: DialogInterface, i: Int ->
finish()
})
builder.show()
}
warning.dynamic(nom, predictedClassName, algo!!)
}
}
} catch (e: Exception) {
e.printStackTrace()
Log.d("tflite", "error")
Log.e("tflite", "Exception caught: ${e.message}")
}
i tried upgrading my tensorflow lite depedencies in the the gradle app file but no luck