-
Notifications
You must be signed in to change notification settings - Fork 75.3k
Probability is mismatching for the image classification example #49893
Description
used same code what given in the below url ,
https://www.tensorflow.org/tutorials/images/classification
created the .tflite for Android and imported the tflite but while executing the code Probability is not matching with the python code.
Percentage in python is ,
This image most likely belongs to sunflowers with a 95.65 percent confidence.
The android code:
val model = Model.newInstance(this)
val bitmap: Bitmap =
BitmapFactory.decodeResource(resources, R.drawable.image)
// Creates inputs for reference.
val image = TensorImage.fromBitmap(bitmap)
// Runs model inference and gets result.
val outputs = model.process(image)
val probability = outputs.probabilityAsCategoryList
// Releases model resources if no longer used.
model.close()
val outputsProbability = probability.apply {
sortByDescending { it.score } // Sort with highest confidence first
}.take(5)
val items = mutableListOf<Recognition>()
for (output in outputsProbability) {
items.add(Recognition(output.label, output.score))
}
Log.d("propability", items.toString())
o/p:
D/propability: [dandelion / 554.4%, daisy / 61.7%, roses / -75.3%, tulips / -282.9%, sunflowers / -426.3%]