title: Why accuracy of tflite model is so different from keras model?
body: <p>I made a model that predict a character on an image, to do license plate recognition. It works very well on my computer, but I need to put this work in an Android app. So I developped a little application and convert my keras model to tflite. And now it's always predicting the same character.</p>
  <p>I converted the model using :</p>
  <pre><code>mod_path = &quot;License_character_recognition.h5&quot;
  
  def load_model(path,custom_objects={},verbose=0):
      #from tf.keras.models import model_from_json
  
      path = splitext(path)[0]
      with open('MobileNets_character_recognition.json','r') as json_file:
          model_json = json_file.read()
      model = tf.keras.models.model_from_json(model_json, custom_objects=custom_objects)
      model.load_weights('%s.h5' % path)
      if verbose: print('Loaded from %s' % path)
      return model
  
  keras_mod = load_model(mod_path)
  
  converter = tf.lite.TFLiteConverter.from_keras_model(keras_mod)
  tflite_model = converter.convert()
  
  # Save the TF Lite model.
  with tf.io.gfile.GFile('ocr.tflite', 'wb') as f:
      f.write(tflite_model)
  </code></pre>
  <p>Is there a better way to convert the model, or am I missing something ?</p>
  <p><strong>EDIT :</strong> This is what I did to manage the bitmap</p>
  <pre><code>        try {
              Mat bis = Utils.loadResource(MainActivity.this, R.drawable.plaque, Imgcodecs.IMREAD_COLOR);
              cvtColor(bis, bis, COLOR_BGR2RGB);
  
              Mat m = Utils.loadResource(MainActivity.this, R.drawable.plaque,Imgcodecs.IMREAD_GRAYSCALE);
  
              blur(m, blur, new Size(2,2));
  
              threshold(blur, bin, 0, 255, THRESH_BINARY_INV + THRESH_OTSU);
  
              ArrayList&lt;MatOfPoint&gt; contours;
              contours = getContours(bin);
  
              //Try to sort from left to right
              Collections.sort(contours, new SortByTopLeft());
              Log.d(&quot;Contour&quot;, String.valueOf(contours.size()));
              int i = 0;
              for (MatOfPoint c : contours){
                  Rect cont = boundingRect(c);
                  float ratio = (float) (cont.height/cont.width);
                  Log.d(&quot;Ratio&quot;, String.valueOf(ratio));
                  float pourcent =  ((float) cont.height/ (float) bin.height());
                  Log.d(&quot;pourcent&quot;, String.valueOf(pourcent));
                  if (ratio &gt;= 1 &amp;&amp; ratio &lt;= 2.5){
                      if(pourcent &gt;=0.5){
                          Log.d(&quot;Ui&quot;, String.valueOf(cont));
                          rectangle(bis, cont, new Scalar(0,255,0), 2);
  
                          //Separate numbers
                          Mat curr_num = new Mat(bin, cont);
                          Bitmap curbit = Bitmap.createBitmap(curr_num.cols(), curr_num.rows(), Bitmap.Config.ARGB_8888);
                          Utils.matToBitmap(curr_num, curbit);
                          images[i].setImageBitmap(curbit);
                          int charac = classifier.classify(curbit);
                          Log.d(&quot;Result&quot;, String.valueOf(charac));
                          result.setText(String.valueOf(charac));
                          if (i &lt; 6){
                              i++;
                          }
                      }
  
                  }
  </code></pre>