Skip to content

Probability is mismatching for the image classification example #49893

@spadiyar67

Description

@spadiyar67

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%]

Metadata

Metadata

Assignees

Labels

TF 2.4for issues related to TF 2.4comp:liteTF Lite related issuesstaleThis label marks the issue/pr stale - to be closed automatically if no activitystat:awaiting responseStatus - Awaiting response from authortype:supportSupport issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions