0

I have a model that predicts the age and gender of the input image of size 160X160. I am creating a byte buffer to input the image to the model and everything works just fine when using a model with only one output.

But when I am using the tflite.runForMultipleInputsOutputs(), I am getting garbage values which are of the form -> [[F@e233 etc.

I have followed the documentation and the sample apps to the detail and have been stuck at this for almost 2 days. Please help.

I am posting my code below for reference.

The model has 2 outputs:

Edit:

age -> float32 [1, 101]

gender -> float32 [1,2]

P.S - I am not doing anything with the output as of now. I just want to see the result of the model.

String classifyImage(Bitmap bitmap){
        try{
            ByteBuffer byteBuffer = convertBitmaptoByteBuffer(bitmap);

            float[][] out_gender = new float[1][2];
            float[][] out_age = new float[1][101];
            Object[] input = {byteBuffer};

            Map<Integer, Object> outputs = new HashMap();
            outputs.put(0, out_age);
            outputs.put(1, out_gender);

            interpreter.runForMultipleInputsOutputs(input, outputs);
            
        }catch (Exception e){
            e.printStackTrace();
        }
        return "";
    }

1 Answer 1

2

First, I would suggest that you double-check that the outputs from your model match your output map. It seems strange to me that the gender would be a 101-dimensional array and the age a 2-dimensional one. Have you by any chance mixed those up?

Secondly, I think you are calling toString() on the float arrays. Consider using e.g. System.out.println(Arrays.deepToString(out_age)); to present the result.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the suggestion @Joel. the age and gender shape was my mistake in question. I have corrected it. I will try the string suggestion and let you know

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.