title: TfLite Image classification score is not consistent it keeps increasing for same image untill it reaches to some saturation(actual score)
body: <p>With same instance of 'interpreter' score is getting increased for same image until  it reaches at some saturation.</p>
  
  <pre><code>Interpreter tflite = new Interpreter(loadModelFile(context));
  </code></pre>
  
  <p>Create Instance for ImageClassifier and use the same instance to classify Frame and run inference for the same image.</p>
  
  <pre><code>ImageClassifier(Activity activity) throws IOException {
      tflite = new Interpreter(loadModelFile(activity));
      labelList = loadLabelList(activity);
      imgData =
          ByteBuffer.allocateDirect(
              DIM_BATCH_SIZE
                  * getImageSizeX()
                  * getImageSizeY()
                  * DIM_PIXEL_SIZE
                  * getNumBytesPerChannel());
      imgData.order(ByteOrder.nativeOrder());
      filterLabelProbArray = new float[FILTER_STAGES][getNumLabels()];
      Log.d(TAG, "Created a Tensorflow Lite Image Classifier.");
    }
  </code></pre>
  
  <p>Classifies a frame for the same image. Same image can be picked up from the Sd card.</p>
  
  <pre><code>private void classifyImage() {
      if (classifier == null || getActivity() == null || cameraDevice == null) {
        showToast("Uninitialized Classifier or invalid context.");
        return;
      }
      String imgPath =  "/storage/emulated/0/DCIM/test.jpg";
      Log.d("Image Path is %s", imgPath);
      Bitmap bitmap = BitmapFactory.decodeFile(imgPath);
      Bitmap newbitmap = Bitmap.createScaledBitmap(bitmap, 299, 299, false);
      String textToShow = classifier.classifyFrame(newbitmap);
      bitmap.recycle();
      showToast(textToShow);
    }
  </code></pre>
  
  <p>classifyFrame() Method of ImageClassifier.java</p>
  
  <pre><code>String classifyFrame(Bitmap bitmap) {
      if (tflite == null) {
        Log.e(TAG, "Image classifier has not been initialized; Skipped.");
        return "Uninitialized Classifier.";
      }
      convertBitmapToByteBuffer(bitmap);
      // Here's where the magic happens!!!
      long startTime = SystemClock.uptimeMillis();
      runInference();
      long endTime = SystemClock.uptimeMillis();
      Log.d(TAG, "Timecost to run model inference: " + Long.toString(endTime - startTime));
  
      // Smooth the results across frames.
      applyFilter();
  
      // Print the results.
      String textToShow = printTopKLabels();
      textToShow = Long.toString(endTime - startTime) + "ms" + textToShow;
      return textToShow;
    }
  </code></pre>
  
  <p>applyFilter() method of ImageClassifier.java</p>
  
  <pre><code>void applyFilter() {
      int numLabels = getNumLabels();
  
      // Low pass filter `labelProbArray` into the first stage of the filter.
      for (int j = 0; j &lt; numLabels; ++j) {
        filterLabelProbArray[0][j] +=
            FILTER_FACTOR * (getProbability(j) - filterLabelProbArray[0][j]);
      }
      // Low pass filter each stage into the next.
      for (int i = 1; i &lt; FILTER_STAGES; ++i) {
        for (int j = 0; j &lt; numLabels; ++j) {
          filterLabelProbArray[i][j] +=
              FILTER_FACTOR * (filterLabelProbArray[i - 1][j] - filterLabelProbArray[i][j]);
        }
      }
  
      // Copy the last stage filter output back to `labelProbArray`.
      for (int j = 0; j &lt; numLabels; ++j) {
        setProbability(j, filterLabelProbArray[FILTER_STAGES - 1][j]);
      }
    }
  </code></pre>
  
  <p>Prints top-K labels, to be shown in UI as the results.</p>
  
  <pre><code>  private String printTopKLabels() {
      for (int i = 0; i &lt; getNumLabels(); ++i) {
        sortedLabels.add(
            new AbstractMap.SimpleEntry&lt;&gt;(labelList.get(i), getNormalizedProbability(i)));
        if (sortedLabels.size() &gt; RESULTS_TO_SHOW) {
          sortedLabels.poll();
        }
      }
      String textToShow = "";
      final int size = sortedLabels.size();
      for (int i = 0; i &lt; size; ++i) {
        Map.Entry&lt;String, Float&gt; label = sortedLabels.poll();
        textToShow = String.format("\n%s: %4.2f", label.getKey(), label.getValue()) + textToShow;
      }
      return textToShow;
    }
  </code></pre>
  
  <p>At the first time when application gets launched score the image classification is 0.06 and then again if we called classifyImage() on some event click score gets increased to 0.13 and with same  process it keeps increasing until it reached to 0.86(saturation). </p>
  
  <p>I am not sure why its happening but it happened for both type of TfLite models inceptionV3 and MobileNet.</p>