Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Problem of genderage.onnx converted to .tflite #18

Open
MMantis opened this issue May 17, 2024 · 0 comments
Open

Problem of genderage.onnx converted to .tflite #18

MMantis opened this issue May 17, 2024 · 0 comments

Comments

@MMantis
Copy link

MMantis commented May 17, 2024

I want to use genderage.onnx to recognize the age and gender of photos on Android, so I used the onnx2tflite tool to convert genderage.onnx to genderage.tflite, and loaded it with TensorFlow Lite. It ran normally and output the results, but the results were not accurate at all. I want to know where I went wrong. Here is my kotlin code
<
val interpreter = Interpreter(FileUtil.loadMappedFile( applicationContext , "genderage.tflite"), options )
val inputImageProcessor =
ImageProcessor.Builder()
.add(ResizeOp(inputImageSize, inputImageSize, ResizeOp.ResizeMethod.BILINEAR))
.add(NormalizeOp(0f, 255f))
.build()
val tensorInputImage = TensorImage.fromBitmap(image)
val ageOutputArray = Array(1){ FloatArray(3) }
val processedImageBuffer = inputImageProcessor.process(tensorInputImage).buffer
interpreter?.run(
processedImageBuffer,
ageOutputArray
)
Log.d("test","predictAge out [0]:${ageOutputArray[0][0]} [1]:${ageOutputArray[0][1]} [2]:${ageOutputArray[0][2]}")
Log.d("test","age:${ageOutputArray[0][2] * 100}")

The out put all ways like :
| predictAge out [0]:0.36035335 [1]:-0.3603145 [2]:0.35510007
| age:35.510006
The three output values are always around 0.35

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant