title: object detection tensorflow lite android studio
body: <p>I'm currently making object detection app with android studio for mobile device.. I am currently stuck with how to show only the confidence instead of showing the names of the classes too.. I hope someone can enlighten me what to do.</p>
  <p>Here's the code.</p>
  <pre><code>    **public void classifyImage(Bitmap image){
      try {
          Model model = Model.newInstance(getApplicationContext());
  
          // Creates inputs for reference.
          TensorBuffer inputFeature0 = TensorBuffer.createFixedSize(new int[]{1, 224, 224, 3}, DataType.FLOAT32);
          ByteBuffer byteBuffer = ByteBuffer.allocateDirect(4 * imageSize * imageSize * 3);
          byteBuffer.order(ByteOrder.nativeOrder());
  
          int [] intValues = new int[imageSize * imageSize];
          image.getPixels(intValues, 0, image.getWidth(), 0, 0, image.getWidth(), image.getHeight());
          int pixel = 0;
          for(int i=0; i&lt;imageSize; i++){
              for(int j=0; j&lt;imageSize; j++){
                  int val=intValues[pixel++];
                  byteBuffer.putFloat(((val&gt;&gt;16)&amp;0xFF)*(1.f/255.f));
                  byteBuffer.putFloat(((val&gt;&gt;8)&amp;0xFF)*(1.f/255.f));
                  byteBuffer.putFloat((val&amp;0xFF)*(1.f/255.f));
              }
          }
          inputFeature0.loadBuffer(byteBuffer);
  
          // Runs model inference and gets result.
          Model.Outputs outputs = model.process(inputFeature0);
          TensorBuffer outputFeature0 = outputs.getOutputFeature0AsTensorBuffer();
  
          float[] confidences = outputFeature0.getFloatArray();
          int maxPos=0;
          float maxConfidence=0;
          for(int i=0;i&lt;confidences.length;i++){
              if(confidences[i]&gt;maxConfidence){
                  maxConfidence=confidences[i];
                  maxPos=i;
              }
          }
          String[] classes = {&quot;Mouse&quot;,&quot;Keyboard&quot;,&quot;Speaker&quot;,&quot;Laptop&quot;};
          result.setText(classes[maxPos]);
  
          String s = &quot;&quot;;
          for(int i=0;i&lt;classes.length;i++){
              s+=String.format(&quot;%s:%.1f%%\n&quot;,classes[i],confidences[i]*100);
          }
          confidence.setText(s);
  
  
          // Releases model resources if no longer used.
          model.close();
      } catch (IOException e) {
          // TODO Handle the exception
      }
  
  }**
  </code></pre>