title: Issue in creating Tflite model populated with metadata (for object detection)
body: <p>I am trying to run a tflite model on Android for object detection. For the same,</p>
  <ol>
  <li>I have successfully trained the model with my sets of images as follows:</li>
  </ol>
  <p>(a) Training:</p>
  <pre><code>!python3 object_detection/model_main.py \
  --pipeline_config_path=/content/drive/My\ Drive/Detecto\ Tutorial/models/research/object_detection/samples/configs/ssd_mobilenet_v2_coco.config \
  --model_dir=training/
  </code></pre>
  <p>(modifying the config file to point to where my specific TFrecords are mentioned)</p>
  <p>(b) Export inference graph</p>
  <pre><code>!python /content/drive/'My Drive'/'Detecto Tutorial'/models/research/object_detection/export_inference_graph.py \
  --input_type=image_tensor \
  --pipeline_config_path=/content/drive/My\ Drive/Detecto\ Tutorial/models/research/object_detection/samples/configs/ssd_mobilenet_v2_coco.config \
  --output_directory={output_directory} \
  --trained_checkpoint_prefix={last_model_path}
  </code></pre>
  <p>(c) Create tflite ready graph</p>
  <pre><code>!python /content/drive/'My Drive'/'Detecto Tutorial'/models/research/object_detection/export_tflite_ssd_graph.py \
    --pipeline_config_path=/content/drive/My\ Drive/Detecto\ Tutorial/models/research/object_detection/samples/configs/ssd_mobilenet_v2_coco.config \
    --output_directory={output_directory} \
    --trained_checkpoint_prefix={last_model_path} \
    --add_postprocessing_op=true
  </code></pre>
  <ol start="2">
  <li><p>I have created a tflite model using tflite_convert from the graph file as follows</p>
  <p>!tflite_convert <br />
  --graph_def_file=/content/drive/My\ Drive/Detecto\ Tutorial/models/research/fine_tuned_model/tflite_graph.pb <br />
  --output_file=/content/drive/My\ Drive/Detecto\ Tutorial/models/research/fine_tuned_model/detect3.tflite <br />
  --output_format=TFLITE <br />
  --input_shapes=1,300,300,3 <br />
  --input_arrays=normalized_input_image_tensor <br />
  --output_arrays='TFLite_Detection_PostProcess','TFLite_Detection_PostProcess:1','TFLite_Detection_PostProcess:2','TFLite_Detection_PostProcess:3'  <br />
  --inference_type=FLOAT  <br />
  --allow_custom_ops</p>
  </li>
  </ol>
  <p>The above tflite model is validated independently and works fine (outside of Android).</p>
  <p>There is a requirement now to populate the tflite model with metadata so that it can be processed in the sample Android code provided as per link below (as I am getting an error otherwise: not a valid Zip file and does not have associated files when run on Android studio).</p>
  <p><a href="https://github.com/tensorflow/examples/blob/master/lite/examples/object_detection/android/README.md" rel="nofollow noreferrer">https://github.com/tensorflow/examples/blob/master/lite/examples/object_detection/android/README.md</a></p>
  <p>The sample .TFlite provided as part of the same link is populated with metadata and works fine.</p>
  <p>When I try to use the following link:
  <a href="https://www.tensorflow.org/lite/convert/metadata#deep_dive_into_the_image_classification_example" rel="nofollow noreferrer">https://www.tensorflow.org/lite/convert/metadata#deep_dive_into_the_image_classification_example</a></p>
  <pre><code>populator = _metadata.MetadataPopulator.with_model_file('/content/drive/My Drive/Detecto Tutorial/models/research/fine_tuned_model/detect3.tflite')
  populator.load_metadata_buffer(metadata_buf)
  populator.load_associated_files(['/content/drive/My Drive/Detecto Tutorial/models/research/fine_tuned_model/labelmap.txt'])
  populator.populate()
  </code></pre>
  <p>to add metadata (rest of the code is practically the same with some changes of meta description to Object detection instead of Image classification and specifying the location of labelmap.txt), it gives the following error:</p>
  <pre><code>&lt;ipython-input-6-173fc798ea6e&gt; in &lt;module&gt;()
    1 populator = _metadata.MetadataPopulator.with_model_file('/content/drive/My Drive/Detecto Tutorial/models/research/fine_tuned_model/detect3.tflite')
    ----&gt; 2 populator.load_metadata_buffer(metadata_buf)
          3 populator.load_associated_files(['/content/drive/My Drive/Detecto Tutorial/models/research/fine_tuned_model/labelmap.txt'])
          4 populator.populate()
  
  1 frames
  /usr/local/lib/python3.6/dist-packages/tensorflow_lite_support/metadata/metadata.py in _validate_metadata(self, metadata_buf)
      540           &quot;The number of output tensors ({0}) should match the number of &quot;
      541           &quot;output tensor metadata ({1})&quot;.format(num_output_tensors,
  --&gt; 542                                                 num_output_meta))
      543 
      544 
  
  ValueError: The number of output tensors (4) should match the number of output tensor metadata (1)
  </code></pre>
  <p>The 4 output tensors are the ones mentioned in the output_arrays in step 2 (someone may correct me there). I am not sure how to update output tensor metadata accordingly.</p>
  <p>Can anyone who has recently used object detection using custom model (and then apply on Android) help? Or help understand how to update tensor metadata to 4 instead of 1.</p>