title: Convert Mask-RCNN model for android with tflite
body: <p>I am trying to deploy this mask-rcnn model in android. I was able to load the keras weight, freeze the model and convert it to .tflite model using tflite 1.13 toco using <a href="https://gist.github.com/bmabir17/754a6e0450ec4fd5e25e462af949cde6" rel="nofollow noreferrer">this script</a>.</p>
  
  <p>It seems this model uses some tf_ops that is not supported in tflite. Thus I had to use </p>
  
  <pre><code>converter.target_ops = [tf.lite.OpsSet.TFLITE_BUILTINS,tf.lite.OpsSet.SELECT_TF_OPS]
  </code></pre>
  
  <p>to convert the model. Now when I try to infer this model using python interpreter, I get segmentation error in interpreter.invoke() and the python script crashes.</p>
  
  <pre><code>def run_tf_model(model_path="mask_rcnn_coco.tflite"):
      interpreter = tf.lite.Interpreter(model_path)
      interpreter.allocate_tensors()
  
      # Get input and output tensors.
      input_details = interpreter.get_input_details()[0]
      output_details = interpreter.get_output_details()[0]
      print(" input_details", input_details)
      print("output_details",output_details)
  
      # Test model on random input data.
      input_shape = input_details['shape']
      print("input_shape tflite",input_shape)
      input_data = np.array(np.random.random_sample(input_shape), dtype=np.float32)
      interpreter.set_tensor(input_details['index'], input_data)
      interpreter.invoke()
  
      # The function `get_tensor()` returns a copy of the tensor data.
      # Use `tensor()` in order to get a pointer to the tensor.
      output_data = interpreter.get_tensor(output_details['index'])
      print(output_data)
  </code></pre>
  
  <p>Thus I am unable to find out if my converted model has been converted correctly or not.</p>
  
  <p>P.S. I am planning to use this model in android, but I have little experience with android(java or kotlin) tflite api. If any one can point out any resources for learning about that would be also be helpful.</p>
  
  <p>Edit: I also tried to run the inference on android with java api. But get the following error <code>tensorflow/lite/kernels/gather.cc:80 0 &lt;= axis &amp;&amp; axis &lt; NumDimensions(input).</code>
  <a href="https://github.com/tensorflow/tensorflow/issues/39179" rel="nofollow noreferrer">Detailed in this tensorflow issue</a></p>