insightface icon indicating copy to clipboard operation
insightface copied to clipboard

Problem of genderage.onnx converted to .tflite

Open MMantis opened this issue 9 months ago • 0 comments

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

MMantis avatar May 17 '24 09:05 MMantis