Android: tflite.runForMultipleInputsOutputs returns NaN

Viewed 323

This is the tflite model being used

This is the tflite model being used

This is the code to run tflite model

Object[] inputArray = {imgData};
outputMap = new HashMap<>(1);
outputMap.put(0, outputLocations);
tflite.runForMultipleInputsOutputs(inputArray, outputMap);

Since there is only one output tensor, I have inserted only one element in the outputMap

and this is the shape of the outputLocations

outputLocations = new float[1][2535][6];

Below is the code to extract information

//labels.size() = 1;
NUM_BOXES_PER_BLOCK = 1;
     int outputWidth = 2535;
     float [][] out = ((float [][][]) Objects.requireNonNull(outputMap.get(0)))[0];       
     final int labelSizeWithResult = labels.size() + 5; // 1 + 5

    
      for(int x = 0; x < outputWidth; x++)
           for (int b = 0; b < NUM_BOXES_PER_BLOCK; b++) {
                final float confidence = sigmoid(out[x][b * labelSizeWithResult + 4]);
                 Log.d("Confidence "," "+confidence); //Return NaN  (all values inside the array is Nan
               }

Where am I going wrong? Please help!

0 Answers
Related